Skip to content

Commit

Permalink
Merge branch 'withanage:main' into ops-main-i9214-Dm3RBeU0kYrklrK
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlFlow authored Apr 15, 2024
2 parents 5f520b6 + 20b8259 commit 0230934
Show file tree
Hide file tree
Showing 43 changed files with 157 additions and 152 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cypress/tests/**/*
lib/pkp/cypress/**/*
cypress/support/**/*
package.json
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
- cp -r datasets/${APPLICATION}/${DATASET_BRANCH}/${TEST}/public/* public/
- cp datasets/${APPLICATION}/${DATASET_BRANCH}/${TEST}/config.inc.php .
- ./datasets/tools/dbclient.sh < datasets/${APPLICATION}/${DATASET_BRANCH}/${TEST}/database.sql
- source ./lib/pkp/tools/travis/migration/v3_4_0/prepare-logs.sh
- php tools/upgrade.php check
- php tools/upgrade.php upgrade

Expand All @@ -101,6 +102,7 @@ jobs:
- patch -p1 < datasets/upgrade/3_4_0-add-email-config.diff
- patch -p1 < datasets/upgrade/3_4_0-update-locale.diff
- ./datasets/tools/dbclient.sh < datasets/${APPLICATION}/${DATASET_BRANCH}/${TEST}/database.sql
- source ./lib/pkp/tools/travis/migration/v3_4_0/prepare-logs.sh
- php tools/upgrade.php check
- php tools/upgrade.php upgrade

Expand All @@ -113,6 +115,7 @@ jobs:
- cp -r datasets/${APPLICATION}/${DATASET_BRANCH}/${TEST}/public/* public/
- cp datasets/${APPLICATION}/${DATASET_BRANCH}/${TEST}/config.inc.php .
- ./datasets/tools/dbclient.sh < datasets/${APPLICATION}/${DATASET_BRANCH}/${TEST}/database.sql
- source ./lib/pkp/tools/travis/migration/v3_4_0/prepare-logs.sh
- php tools/upgrade.php check
- php tools/upgrade.php upgrade

Expand All @@ -127,6 +130,7 @@ jobs:
- patch -p1 < datasets/upgrade/3_4_0-add-email-config.diff
- patch -p1 < datasets/upgrade/3_4_0-update-locale.diff
- ./datasets/tools/dbclient.sh < datasets/${APPLICATION}/${DATASET_BRANCH}/${TEST}/database.sql
- source ./lib/pkp/tools/travis/migration/v3_4_0/prepare-logs.sh
- php tools/upgrade.php check
- php tools/upgrade.php upgrade

Expand Down
18 changes: 12 additions & 6 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

## Supported Versions

| Version | Supported | End Of Life |
| ------- | ----------------------------------------------------- | ------------- |
| 3.5.x | :x: Pre-release | 2026 (est) |
| 3.4.x | :heavy_check_mark: Active development | 2025 (est) |
| 3.3.x | :heavy_check_mark: Active maintenance | 2026 (est) |
| 3.2.x | :x: Not supported | 2023 |
| Version | Supported | Released | End Of Life | Support |
| ------- | ----------------------------------------------------- | ------------- | ------------- | :-----: |
| 3.5.x | :hourglass: Pre-release | 2025 (est) | 2028 (est) | LTS |
| 3.4.x | :heavy_check_mark: Active development | 2023 | 2025 (est) | |
| 3.3.x | :heavy_check_mark: Active maintenance | 2021 | 2026 (est) | LTS |
| 3.2.x | :x: Not supported | 2020 | 2023 | |

PKP usually supports current major release and the last major release.
Other releases receive bug fixes for about two years. However, that is not guaranteed.

[LTS versions](https://pkp.sfu.ca/2022/02/15/pkp-announces-long-term-support-lts-software-releases/) are an exception to this general rule, that don't include new features but receive security patches and bug fixes for 3-5 years.
At least 12 months before a LTS version reaches EOL, a new LTS version is designated, so that you have one year to perform an upgrade.# Security Policy

## Reporting a Vulnerability

Expand Down
6 changes: 3 additions & 3 deletions classes/migration/install/OPSMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function up(): void
$table->foreign('section_id')->references('section_id')->on('sections')->onDelete('cascade');
$table->index(['section_id'], 'section_settings_section_id');

$table->string('locale', 14)->default('');
$table->string('locale', 28)->default('');
$table->string('setting_name', 255);
$table->text('setting_value')->nullable();

Expand Down Expand Up @@ -110,7 +110,7 @@ public function up(): void
Schema::create('publication_galleys', function (Blueprint $table) {
$table->comment('Publication galleys are representations of publications in a particular format, such as a PDF file.');
$table->bigInteger('galley_id')->autoIncrement();
$table->string('locale', 14)->nullable();
$table->string('locale', 28)->nullable();

$table->bigInteger('publication_id');
$table->foreign('publication_id', 'publication_galleys_publication_id')->references('publication_id')->on('publications')->onDelete('cascade');
Expand Down Expand Up @@ -143,7 +143,7 @@ public function up(): void
$table->foreign('galley_id')->references('galley_id')->on('publication_galleys');
$table->index(['galley_id'], 'publication_galley_settings_galley_id');

$table->string('locale', 14)->default('');
$table->string('locale', 28)->default('');
$table->string('setting_name', 255);
$table->text('setting_value')->nullable();

Expand Down
4 changes: 2 additions & 2 deletions classes/migration/install/ServersMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function up(): void
$table->bigInteger('server_id')->autoIncrement();
$table->string('path', 32);
$table->float('seq', 8, 2)->default(0)->comment('Used to order lists of servers');
$table->string('primary_locale', 14);
$table->string('primary_locale', 28);
$table->tinyInteger('enabled')->default(1)->comment('Controls whether or not the server is considered "live" and will appear on the website. (Note that disabled servers may still be accessible, but only if the user knows the URL.)');
$table->unique(['path'], 'servers_path');
});
Expand All @@ -44,7 +44,7 @@ public function up(): void
$table->foreign('server_id', 'server_settings_server_id')->references('server_id')->on('servers')->onDelete('cascade');
$table->index(['server_id'], 'server_settings_server_id');

$table->string('locale', 14)->default('');
$table->string('locale', 28)->default('');
$table->string('setting_name', 255);
$table->text('setting_value')->nullable();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* @file classes/migration/upgrade/v3_5_0/I9425_SeparateUIAndSubmissionLocales.php
*
* Copyright (c) 2024 Simon Fraser University
* Copyright (c) 2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I9425_SeparateUIAndSubmissionLocales
*
* @brief pkp/pkp-lib#9425 Make submission language selection and metadata forms independent from website language settings
*/

namespace APP\migration\upgrade\v3_5_0;

class I9425_SeparateUIAndSubmissionLocales extends \PKP\migration\upgrade\v3_5_0\I9425_SeparateUIAndSubmissionLocales
{
protected function getContextTable(): string
{
return 'servers';
}
protected function getContextSettingsTable(): string
{
return 'server_settings';
}
protected function getContextIdColumn(): string
{
return 'server_id';
}
}
11 changes: 5 additions & 6 deletions classes/publication/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ public function getCollector(): Collector
public function validate($publication, array $props, Submission $submission, Context $context): array
{
$errors = parent::validate($publication, $props, $submission, $context);

$allowedLocales = $context->getSupportedSubmissionLocales();
$primaryLocale = $submission->getData('locale');
$submissionLocale = $submission->getData('locale');

// Ensure that the specified section exists
$section = null;
Expand All @@ -63,21 +61,22 @@ public function validate($publication, array $props, Submission $submission, Con
if ($section && !$submission->getData('submissionProgress')) {
// Require abstracts if the section requires them
if (is_null($publication) && !$section->getData('abstractsNotRequired') && empty($props['abstract'])) {
$errors['abstract'][$primaryLocale] = [__('author.submit.form.abstractRequired')];
$errors['abstract'][$submissionLocale] = [__('author.submit.form.abstractRequired')];
}

if (isset($props['abstract']) && empty($errors['abstract'])) {
// Require abstracts in the primary language if the section requires them
if (!$section->getData('abstractsNotRequired')) {
if (empty($props['abstract'][$primaryLocale])) {
if (empty($props['abstract'][$submissionLocale])) {
if (!isset($errors['abstract'])) {
$errors['abstract'] = [];
};
$errors['abstract'][$primaryLocale] = [__('author.submit.form.abstractRequired')];
$errors['abstract'][$submissionLocale] = [__('author.submit.form.abstractRequired')];
}
}

// Check the word count on abstracts
$allowedLocales = $submission->getPublicationLanguages($context->getSupportedSubmissionMetadataLocales());
foreach ($allowedLocales as $localeKey) {
if (empty($props['abstract'][$localeKey])) {
continue;
Expand Down
4 changes: 3 additions & 1 deletion classes/publication/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ protected function mapByProperties(array $props, Publication $publication, bool
);
}

$output = $this->schemaService->addMissingMultilingualValues(PKPSchemaService::SCHEMA_PUBLICATION, $output, $this->context->getSupportedSubmissionLocales());
$locales = $this->submission->getPublicationLanguages($this->context->getSupportedSubmissionMetadataLocales());

$output = $this->schemaService->addMissingMultilingualValues(PKPSchemaService::SCHEMA_PUBLICATION, $output, $locales);

ksort($output);

Expand Down
3 changes: 2 additions & 1 deletion classes/submission/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public function validateSubmit(Submission $submission, Context $context): array
$abstracts = $publication->getData('abstract');
if ($abstracts) {
$abstractErrors = [];
foreach ($context->getSupportedSubmissionLocales() as $localeKey) {
$allowedLocales = $submission->getPublicationLanguages($context->getSupportedSubmissionMetadataLocales());
foreach ($allowedLocales as $localeKey) {
$abstract = $publication->getData('abstract', $localeKey);
$wordCount = $abstract ? PKPString::getWordCount($abstract) : 0;
if ($wordCount > $section->getAbstractWordCount()) {
Expand Down
8 changes: 7 additions & 1 deletion classes/submission/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ protected function mapByProperties(array $props, Submission $submission): array
);
}

$output = $this->schemaService->addMissingMultilingualValues($this->schemaService::SCHEMA_SUBMISSION, $output, $this->context->getSupportedSubmissionLocales());
$locales = $this->context->getSupportedSubmissionMetaDataLocales();

if (!in_array($submissionLocale = $submission->getData('locale'), $locales)) {
$locales[] = $submissionLocale;
}

$output = $this->schemaService->addMissingMultilingualValues($this->schemaService::SCHEMA_SUBMISSION, $output, $locales);

ksort($output);

Expand Down
23 changes: 8 additions & 15 deletions controllers/grid/preprintGalleys/form/PreprintGalleyForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use APP\core\Request;
use APP\facades\Repo;
use APP\publication\Publication;
use APP\server\Server;
use APP\submission\Submission;
use APP\template\TemplateManager;
use PKP\form\Form;
Expand Down Expand Up @@ -65,23 +64,14 @@ public function __construct($request, $submission, $publication, $preprintGalley
$this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this));

// Ensure a locale is provided and valid
$server = $request->getServer();
$locales = $submission->getPublicationLanguages($request->getServer()->getSupportedSubmissionMetadataLocales(), $preprintGalley?->getLanguages());
$this->addCheck(
new \PKP\form\validation\FormValidator(
new \PKP\form\validation\FormValidatorCustom(
$this,
'locale',
'required',
'validator.required',
new class ($server) extends Validator {
public function __construct(private Server $server)
{
}

public function isValid($locale): bool
{
return in_array($locale, $this->server->getSupportedSubmissionLocales());
}
}
fn ($locale) => in_array($locale, $locales)
)
);
}
Expand All @@ -104,9 +94,12 @@ public function fetch($request, $template = null, $display = false)
'supportsDependentFiles' => $preprintGalleyFile ? Repo::submissionFile()->supportsDependentFiles($preprintGalleyFile) : null,
]);
}
$context = $request->getContext();

$supportedLocales = $request->getContext()->getSupportedSubmissionMetadataLocaleNames() + $this->_submission->getPublicationLanguageNames() + ($this->_preprintGalley?->getLanguageNames() ?? []);
ksort($supportedLocales);

$templateMgr->assign([
'supportedLocales' => $context->getSupportedSubmissionLocaleNames(),
'supportedLocales' => $supportedLocales,
'submissionId' => $this->_submission->getId(),
'publicationId' => $this->_publication->getId(),
'formDisabled' => !$this->_isEditable
Expand Down
6 changes: 3 additions & 3 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Cypress.Commands.add('addSubmissionGalleys', (files) => {
files.forEach(file => {
cy.get('a:contains("Add File")').click();
cy.wait(2000); // Avoid occasional failure due to form init taking time
cy.get('div.pkp_modal_panel').then($modalDiv => {
cy.get('[role="dialog"]').then(($modalDiv) => {
cy.wait(3000);
$modalDiv.find('div.header:contains("Add File")');
cy.get('div.pkp_modal_panel input[id^="label-"]').type('PDF', {delay: 0});
cy.get('div.pkp_modal_panel button:contains("Save")').click();
cy.get('[role="dialog"] input[id^="label-"]').type('PDF', {delay: 0});
cy.get('[role="dialog"] button:contains("Save")').click();
cy.wait(2000); // Avoid occasional failure due to form init taking time
});
cy.get('select[id=genreId]').select(file.genre);
Expand Down
9 changes: 7 additions & 2 deletions cypress/tests/data/10-ApplicationSetup/20-CreateContext.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ describe('Data suite tests', function() {
cy.get('#appearance [role="status"]').contains('Saved');

cy.get('button[id="languages-button"]').click();
cy.get('input[id^=select-cell-fr_CA-submissionLocale]').click();
cy.contains('Locale settings saved.');
cy.get('input[id^="select-cell-fr_CA-formLocale"]').click();
cy.get('a[id^=component-grid-settings-languages-submissionlanguagegrid-addLanguageModal-button]').click();
cy.get('#locale-fr_CA').should('exist').click();
cy.get('#addLanguageForm button[name="submitFormButton"]').click();
cy.contains('Submission locales updated.').should('exist');
cy.get('input[id^="select-cell-fr_CA-submissionLocale"]').click();
cy.get('input[id^="select-cell-fr_CA-submissionMetadataLocale"]').should('be.checked');

cy.get('button[id="indexing-button"]').click();
cy.get('input[name="searchDescription-en"]').type(Cypress.env('contextDescriptions')['en'], {delay: 0});
Expand Down
4 changes: 2 additions & 2 deletions cypress/tests/data/60-content/CkwantesSubmission.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ describe('Data suite: Ckwantes', function() {
.find('h4').contains('Keywords').siblings('.submissionWizard__reviewPanel__item__value').contains('employees, survey')
.parents('.submissionWizard__reviewPanel')
.find('h4').contains('Abstract').siblings('.submissionWizard__reviewPanel__item__value').contains(submission.abstract);
cy.get('h3').contains('Details (French)')
cy.get('h3').contains('Details (French (Canada))')
.parents('.submissionWizard__reviewPanel')
.find('h4').contains('Title').siblings('.submissionWizard__reviewPanel__item__value').contains('None provided')
.parents('.submissionWizard__reviewPanel')
.find('h4').contains('Keywords').siblings('.submissionWizard__reviewPanel__item__value').contains('None provided')
.parents('.submissionWizard__reviewPanel')
.find('h4').contains('Abstract').siblings('.submissionWizard__reviewPanel__item__value').contains('None provided');
cy.get('h3').contains('For Readers (English)')
cy.get('h3').contains('For Readers (French)')
cy.get('h3').contains('For Readers (French (Canada))')

// Save for later
cy.get('button').contains('Save for Later').click();
Expand Down
8 changes: 7 additions & 1 deletion dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,18 @@
<migration class="PKP\migration\upgrade\v3_4_0\I9535_FixEmptyFileStage"/>
</upgrade>

<upgrade minversion="3.1.0.0" maxversion="3.4.0.5">
<migration class="PKP\migration\upgrade\v3_4_0\I9830_FixEmptyUserLocales" />
</upgrade>

<upgrade minversion="3.1.0.0" maxversion="3.4.9.9">
<migration class="PKP\migration\upgrade\v3_5_0\I9197_MigrateAccessKeys"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9253_SiteAnnouncements"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9262_Highlights"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9462_UserUserGroups"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9462_UserUserGroupsStartEndDate"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9552_UserGroupsMasthead"/>
<migration class="APP\migration\upgrade\v3_5_0\I9425_SeparateUIAndSubmissionLocales"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9709_UserUserGroupsMasthead"/>
</upgrade>

<!-- update plugin configuration - should be done as the final upgrade task -->
Expand Down
5 changes: 0 additions & 5 deletions jobs/statistics/CompileCounterSubmissionDailyMetrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

class CompileCounterSubmissionDailyMetrics extends BaseJob
{
/**
* The number of times the job may be attempted.
*/
public $tries = 1;

/**
* Create a new job instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

class CompileCounterSubmissionInstitutionDailyMetrics extends BaseJob
{
/**
* The number of times the job may be attempted.
*/
public $tries = 1;

/**
* Create a new job instance.
*
Expand Down
5 changes: 0 additions & 5 deletions jobs/statistics/CompileSubmissionGeoDailyMetrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@

class CompileSubmissionGeoDailyMetrics extends BaseJob
{
/**
* The number of times the job may be attempted.
*/
public $tries = 1;

/**
* Create a new job instance.
*
Expand Down
5 changes: 0 additions & 5 deletions jobs/statistics/CompileUniqueInvestigations.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@

class CompileUniqueInvestigations extends BaseJob
{
/**
* The number of times the job may be attempted.
*/
public $tries = 1;

/**
* Create a new job instance.
*
Expand Down
5 changes: 0 additions & 5 deletions jobs/statistics/CompileUniqueRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@

class CompileUniqueRequests extends BaseJob
{
/**
* The number of times the job may be attempted.
*/
public $tries = 1;

/**
* Create a new job instance.
*
Expand Down
Loading

0 comments on commit 0230934

Please sign in to comment.