Skip to content

Commit

Permalink
pkp/pkp-lib#8598 DB Migration changes
Browse files Browse the repository at this point in the history
  • Loading branch information
defstat committed Feb 14, 2023
1 parent 95bf2bc commit db6c02a
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
71 changes: 71 additions & 0 deletions classes/migration/upgrade/v3_4_0/MergeLocalesMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* @file classes/migration/upgrade/v3_4_0/MergeLocalesMigration.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class MergeLocalesMigration
*
* @brief Change Locales from locale_countryCode localization folder notation to locale localization folder notation
*/

namespace APP\migration\upgrade\v3_4_0;

use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use PKP\install\DowngradeNotSupportedException;

class MergeLocalesMigration extends \PKP\migration\upgrade\v3_4_0\MergeLocalesMigration
{
protected string $CONTEXT_TABLE = 'journals';
protected string $CONTEXT_SETTINGS_TABLE = 'journal_settings';
protected string $CONTEXT_COLUMN = 'journal_id';

/**
* Run the migrations.
*/
public function up(): void
{
parent::up();

// issue_galleys
$issueGalleys = DB::table('issue_galleys')
->get();

foreach ($issueGalleys as $issueGalley) {
$this->updateSingleValueLocale($issueGalley->locale, 'issue_galleys', 'locale', 'galley_id', $issueGalley->galley_id);
}

// publication_galleys
$publicationGalleys = DB::table('publication_galleys')
->get();

foreach ($publicationGalleys as $publicationGalley) {
$this->updateSingleValueLocale($publicationGalley->locale, 'publication_galleys', 'locale', 'galley_id', $publicationGalley->galley_id);
}
}

/**
* Reverse the migrations.
*/
public function down(): void
{
throw new DowngradeNotSupportedException();
}

protected function getSettingsTables(): Collection
{
return collect([
'issue_galley_settings' => 'galley_id',
'issue_settings' => 'issue_id',
'journal_settings' => 'journal_id',
'publication_galley_settings' => 'galley_id',
'section_settings' => 'section_id',
'static_page_settings' => 'static_page_id',
'subscription_type_settings' => 'type_id',
])->merge(parent::getSettingsTables());
}
}
2 changes: 1 addition & 1 deletion config.TEMPLATE.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
[i18n]

; Default locale
locale = en_US
locale = en

; Database connection character set
connection_charset = utf8
Expand Down
1 change: 1 addition & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
<migration class="APP\migration\upgrade\v3_4_0\I7513_DoiSettings"/>
<migration class="PKP\migration\upgrade\v3_4_0\I7486_RenameUnconsideredColumnToConsidered"/>
<migration class="PKP\migration\upgrade\v3_4_0\I7486_RemoveItemViewsTable"/>
<migration class="APP\migration\upgrade\v3_4_0\MergeLocalesMigration"/>
<data file="dbscripts/xml/upgrade/3.4.0_preupdate_email_templates.xml" />
<note file="docs/release-notes/README-3.4.0" />
</upgrade>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ArticlePubMedXmlFilter
*
* @brief Class that converts a Article to a PubMed XML document.
*/

Expand Down Expand Up @@ -88,7 +89,7 @@ public function &process(&$submissions)
$publication = $submission->getCurrentPublication();

$locale = $publication->getData('locale');
if ($locale == 'en_US') {
if ($locale == 'en') {
$articleNode->appendChild($doc->createElement('ArticleTitle'))->appendChild($doc->createTextNode($publication->getLocalizedTitle($locale)));
} else {
$articleNode->appendChild($doc->createElement('VernacularTitle'))->appendChild($doc->createTextNode($publication->getLocalizedTitle($locale)));
Expand Down

0 comments on commit db6c02a

Please sign in to comment.