Skip to content

Commit

Permalink
Merge pull request pkp#8952 from jonasraoni/bugfix/main/8951-fix-nati…
Browse files Browse the repository at this point in the history
…ve-xml-plugin

Bugfix/main/8951 fix native xml plugin
  • Loading branch information
jonasraoni authored May 14, 2023
2 parents 644ec62 + a5e466e commit c4b05fe
Show file tree
Hide file tree
Showing 80 changed files with 508 additions and 75 deletions.
2 changes: 1 addition & 1 deletion api/v1/submissions/PKPSubmissionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ public function submit(SlimRequest $slimRequest, APIResponse $response, array $a
'submission.event.copyrightAgreed',
[
'username' => $request->getUser()->getUsername(),
'name' => $request->getUser()->getFullName(Locale::getLocale()),
'name' => $request->getUser()->getFullName(true, false, Locale::getLocale()),
'copyrightNotice' => $context->getLocalizedData('copyrightNotice', Locale::getLocale()),
]
);
Expand Down
11 changes: 7 additions & 4 deletions classes/cliTool/CommandLineTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ public function __construct($argv = [])
$request->setRouter($router);

// Initialize the locale and load generic plugins.
$contextDao = Application::getContextDAO(); /** @var ContextDAO $contextDao */
$contextFactory = $contextDao->getAll(); /** @var DAOResultFactory $contextFactory */
foreach ($contextFactory->toIterator() as $context) { /** @var Context $context */
PluginRegistry::loadCategory('generic', false, $context->getId());
PluginRegistry::loadCategory('generic');
if (!$application->isUnderMaintenance()) {
$contextDao = Application::getContextDAO(); /** @var ContextDAO $contextDao */
$contextFactory = $contextDao->getAll(); /** @var DAOResultFactory $contextFactory */
foreach ($contextFactory->toIterator() as $context) { /** @var Context $context */
PluginRegistry::loadCategory('generic', false, $context->getId());
}
}

$this->argv = isset($argv) && is_array($argv) ? $argv : [];
Expand Down
2 changes: 1 addition & 1 deletion classes/core/PKPString.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public static function regexp_match_all($pattern, $subject, &$matches)
*/
public static function regexp_replace($pattern, $replacement, $subject, $limit = -1)
{
return preg_replace($pattern . 'u', $replacement, $subject, $limit);
return preg_replace($pattern . 'u', (string) $replacement, (string) $subject, $limit);
}

/**
Expand Down
26 changes: 13 additions & 13 deletions classes/filter/FilterDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ public function insertObject($filter, $contextId = \PKP\core\PKPApplication::CON

$this->update(
sprintf('INSERT INTO filters
(filter_group_id, context_id, display_name, class_name, is_template, parent_filter_id, seq)
VALUES (?, ?, ?, ?, ?, ?, ?)'),
(filter_group_id, context_id, display_name, class_name, is_template, parent_filter_id, seq)
VALUES (?, ?, ?, ?, ?, ?, ?)'),
[
(int) $filterGroup->getId(),
(int) $contextId,
Expand Down Expand Up @@ -188,8 +188,8 @@ public function getObjectById($filterId, $allowSubfilter = false)
{
$result = $this->retrieve(
'SELECT * FROM filters
WHERE ' . ($allowSubfilter ? '' : 'parent_filter_id = 0 AND ') . '
filter_id = ?',
WHERE ' . ($allowSubfilter ? '' : 'parent_filter_id = 0 AND ') . '
filter_id = ?',
[(int) $filterId]
);
$row = $result->current();
Expand All @@ -212,10 +212,10 @@ public function getObjectsByClass($className, $contextId = \PKP\core\PKPApplicat
{
$result = $this->retrieve(
'SELECT * FROM filters
WHERE context_id = ? AND
class_name = ? AND
' . ($allowSubfilters ? '' : ' parent_filter_id = 0 AND ') . '
' . ($getTemplates ? ' is_template = 1' : ' is_template = 0'),
WHERE context_id = ? AND
LOWER(class_name) = LOWER(?) AND
' . ($allowSubfilters ? '' : ' parent_filter_id = 0 AND ') . '
' . ($getTemplates ? ' is_template = 1' : ' is_template = 0'),
[(int) $contextId, $className]
);

Expand All @@ -241,7 +241,7 @@ public function getObjectsByGroupAndClass($groupSymbolic, $className, $contextId
$result = $this->retrieve(
'SELECT f.* FROM filters f' .
' INNER JOIN filter_groups fg ON f.filter_group_id = fg.filter_group_id' .
' WHERE fg.symbolic = ? AND f.context_id = ? AND f.class_name = ?' .
' WHERE fg.symbolic = ? AND f.context_id = ? AND LOWER(f.class_name) = LOWER(?)' .
' ' . ($allowSubfilters ? '' : 'AND f.parent_filter_id = 0') .
' AND ' . ($getTemplates ? 'f.is_template = 1' : 'f.is_template = 0'),
[$groupSymbolic, (int) $contextId, $className]
Expand Down Expand Up @@ -279,8 +279,8 @@ public function getObjectsByTypeDescription($inputTypeDescription, $outputTypeDe
'SELECT f.*' .
' FROM filters f' .
' INNER JOIN filter_groups fg ON f.filter_group_id = fg.filter_group_id' .
' WHERE fg.input_type like ?' .
' AND fg.output_type like ?' .
' WHERE LOWER(fg.input_type) LIKE LOWER(?)' .
' AND LOWER(fg.output_type) LIKE LOWER(?)' .
' AND f.parent_filter_id = 0 AND f.is_template = 0',
[$inputTypeDescription, $outputTypeDescription]
);
Expand Down Expand Up @@ -340,8 +340,8 @@ public function getObjectsByGroup($groupSymbolic, $contextId = \PKP\core\PKPAppl
$result = $this->retrieve(
'SELECT f.* FROM filters f' .
' INNER JOIN filter_groups fg ON f.filter_group_id = fg.filter_group_id' .
' WHERE fg.symbolic = ? AND ' . ($getTemplates ? 'f.is_template = 1' : 'f.is_template = 0') .
' ' . (is_null($contextId) ? '' : 'AND f.context_id in (0, ' . (int)$contextId . ')') .
' WHERE LOWER(fg.symbolic) = LOWER(?) AND ' . ($getTemplates ? 'f.is_template = 1' : 'f.is_template = 0') .
' ' . ($contextId ? 'AND f.context_id in (0, ' . (int)$contextId . ')' : '') .
' AND f.parent_filter_id = 0',
[$groupSymbolic]
);
Expand Down
2 changes: 1 addition & 1 deletion classes/mail/traits/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function from($address, $name = null)
*/
public function sender(User $sender, ?string $defaultLocale = null): Mailable
{
$this->setAddress($sender->getEmail(), $sender->getFullName($defaultLocale), 'from');
$this->setAddress($sender->getEmail(), $sender->getFullName(true, false, $defaultLocale), 'from');
$this->variables[] = new SenderEmailVariable($sender, $this);
$this->sender = $sender;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion classes/plugins/importexport/PKPImportExportDeployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ protected function getObjectTypes()
PKPApplication::ASSOC_TYPE_AUTHOR => __('user.role.author'),
PKPApplication::ASSOC_TYPE_PUBLICATION => __('submission.publication'),
PKPApplication::ASSOC_TYPE_SECTION => __('section.section'),
PKPApplication::ASSOC_TYPE_SUBMISSION_FILE => __('author.submit.submissionFile'),
PKPApplication::ASSOC_TYPE_SUBMISSION_FILE => __('submission.submissionFile'),
];

return $objectTypes;
Expand Down
1 change: 1 addition & 0 deletions classes/template/PKPTemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ public function initialize($request)
$this->registerPlugin('modifier', 'uniqid', 'uniqid');
$this->registerPlugin('modifier', 'substr', 'substr');
$this->registerPlugin('modifier', 'strstr', 'strstr');
$this->registerPlugin('modifier', 'strval', 'strval');
$this->registerPlugin('modifier', 'array_key_first', 'array_key_first');
$this->registerPlugin('modifier', 'fatalError', 'fatalError');
$this->registerPlugin('modifier', 'translate', [$this, 'smartyTranslateModifier']);
Expand Down
43 changes: 20 additions & 23 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ Cypress.Commands.add('getTinyMceContent', (tinyMceId, content) => {
Cypress.Commands.add('runQueueJobs', (queue, test, once) => {
let command = 'php lib/pkp/tools/jobs.php run';

if ( queue ) {
command = command + ' --queue=' + queue;
if (queue) {
command += ' --queue=' + queue;
}

if ( test || false ) {
command = command + ' --test';
if (test) {
command += ' --test';
}

if ( once || false ) {
command = command + ' --once';
if (once) {
command += ' --once';
}

cy.exec(command);
Expand All @@ -65,34 +65,31 @@ Cypress.Commands.add('runQueueJobs', (queue, test, once) => {
Cypress.Commands.add('purgeQueueJobs', (queue, all) => {
let command = 'php lib/pkp/tools/jobs.php purge';

if ( queue ) {
command = command + ' --queue=' + queue;
if (queue) {
command += ' --queue=' + queue;
}

if ( all || false ) {
command = command + ' --all';
if (all) {
command += ' --all';
}

cy.exec(command);
});

Cypress.Commands.add('dispatchTestQueueJobs', (times) => {

times = times || 1;
for (let index = 0; index < times; index++) {
for (times = Math.max(~~times, 1); times--;) {
cy.exec('php lib/pkp/tools/jobs.php test');
}
});

Cypress.Commands.add('clearFailedJobs', (queue) => {

let command = 'php lib/pkp/tools/jobs.php failed';

if ( queue ) {
command = command + ' --queue=' + queue;
if (queue) {
command += ' --queue=' + queue;
}

command = command + ' --clear';
command += ' --clear';

cy.exec(command);
});
Expand Down Expand Up @@ -605,8 +602,8 @@ Cypress.Commands.add('flushNotifications', function() {
});
});

Cypress.Commands.add('waitJQuery', function() {
cy.waitUntil(() => cy.window().then(win => win.jQuery.active == 0));
Cypress.Commands.add('waitJQuery', function(options) {
cy.waitUntil(() => cy.window().then(win => win.jQuery.active == 0), options);
});

Cypress.Commands.add('consoleLog', message => {
Expand Down Expand Up @@ -646,9 +643,9 @@ Cypress.Commands.add('checkGraph', (totalAbstractViews, abstractViews, files, to
cy.get('div.pkpStats__graphSelectors button:contains("Monthly")').click();
});

Cypress.Commands.add('checkTable', (articleDetails, articles, authors) => {
cy.get('h2:contains("' + articleDetails + '")');
cy.get('div:contains("2 of 2 ' + articles + '")');
Cypress.Commands.add('checkTable', (articleDetails, articles, authors, submissionCount, submissionCountFromAuthor) => {
cy.get('h2:contains("' + articleDetails + '")').scrollIntoView();
cy.get(`div:contains("${submissionCount} of ${submissionCount} ${articles}")`);
authors.forEach(author => {
cy.get('.pkpStats__panel .pkpTable__cell:contains("' + author + '")');
});
Expand All @@ -657,7 +654,7 @@ Cypress.Commands.add('checkTable', (articleDetails, articles, authors) => {
cy.get('div:contains("0 of 0 ' + articles + '")');
cy.get('input.pkpSearch__input').clear().type(authors[0], {delay: 0});
cy.get('.pkpStats__panel .pkpTable__cell:contains("' + authors[0] + '")');
cy.get('div:contains("1 of 1 ' + articles + '")');
cy.get(`div:contains("${submissionCountFromAuthor} of ${submissionCountFromAuthor} ${articles}")`);
cy.get('input.pkpSearch__input').clear();
});

Expand Down
4 changes: 2 additions & 2 deletions cypress/tests/integration/API.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file cypress/tests/integration/API.spec.js
* @file cypress/tests/integration/API.cy.js
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
Expand Down Expand Up @@ -33,7 +33,7 @@ describe('API tests', function() {
cy.get('a:contains("Edit Profile")').click();
cy.get('a[name="apiSettings"]').click();
cy.get("body").then($body => {
if ($body.find("button:contains(\"Delete\")").length > 0) {
if ($body.find("button:contains(\"Delete\")").length > 0) {
cy.get('form[id="apiProfileForm"] button:contains("Delete")').click();
cy.waitJQuery();
cy.on('window:confirm', (text) => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/tests/integration/Announcements.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file cypress/tests/integration/Announcements.spec.js
* @file cypress/tests/integration/Announcements.cy.js
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
Expand Down
2 changes: 1 addition & 1 deletion cypress/tests/integration/DataAvailabilityStatements.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file cypress/tests/integration/DataAvailabilityStatements.spec.js
* @file cypress/tests/integration/DataAvailabilityStatements.cy.js
*/

describe('DataAvailabilityStatements', function () {
Expand Down
4 changes: 2 additions & 2 deletions cypress/tests/integration/Filenames.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file cypress/tests/integration/Filenames.spec.js
* @file cypress/tests/integration/Filenames.cy.js
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
Expand Down Expand Up @@ -48,4 +48,4 @@

});
});
});
});
20 changes: 10 additions & 10 deletions cypress/tests/integration/Jobs.cy.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* @file cypress/tests/integration/Jobs.spec.js
* @file cypress/tests/integration/Jobs.cy.js
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
*/

describe('Jobs tests', function() {
describe('Jobs tests', function() {
it('Check if Jobs page is alive and with contents', function() {

cy.login('admin', 'admin', 'publicknowledge');
Expand Down Expand Up @@ -36,7 +36,7 @@
cy.get('.pkpTable')
.find('span:contains("queuedTestJob")')
.should('have.length', 0);

cy.logout();
});

Expand All @@ -48,7 +48,7 @@
cy.purgeQueueJobs(null, true);

// Clear all existing failed jobs
cy.clearFailedJobs()
cy.clearFailedJobs();

// Add 8 test jobs[successable(4) and failable(4)] on queue
cy.dispatchTestQueueJobs(4);
Expand Down Expand Up @@ -82,7 +82,7 @@
cy.get('.pkpTable')
.find('span:contains("queuedTestJob")')
.should('have.length', 2);

// Back to Jobs page
cy.get('a:contains("Administration")').click();
cy.get('a:contains("View Jobs")').click();
Expand All @@ -92,7 +92,7 @@
cy.get('.pkpTable')
.find('span:contains("queuedTestJob")')
.should('have.length', 1);

// Back to failed jobs page
cy.get('a:contains("Administration")').click();
cy.get('a:contains("View Failed Jobs")').click();
Expand All @@ -103,7 +103,7 @@
cy.get('.pkpTable')
.find('td:contains("Payload")')
.should('have.length', 1);

// Back to failed jobs page again
cy.go('back');
cy.waitJQuery();
Expand All @@ -116,7 +116,7 @@
cy.get('.pkpTable')
.find('span:contains("queuedTestJob")')
.should('have.length', 0);

// Confirm that 'Requeue All Failed Jobs' button has removed from view
cy.get('button:contains("Requeue All Failed Jobs")').should('not.exist');

Expand All @@ -129,7 +129,7 @@
cy.get('.pkpTable')
.find('span:contains("queuedTestJob")')
.should('have.length', 3);

// purge all existing jobs in the test queue
cy.purgeQueueJobs('queuedTestJob');

Expand All @@ -139,7 +139,7 @@
cy.get('.pkpTable')
.find('span:contains("queuedTestJob")')
.should('have.length', 0);

cy.logout();
});

Expand Down
2 changes: 1 addition & 1 deletion cypress/tests/integration/Multilingual.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file cypress/tests/integration/Multilingual.spec.js
* @file cypress/tests/integration/Multilingual.cy.js
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
Expand Down
Loading

0 comments on commit c4b05fe

Please sign in to comment.