Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#9892 upgrade to laravel 11 and PHP 8.2+ #1669

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion classes/install/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace APP\install;

use APP\core\Application;
use Illuminate\Support\Facades\Schema;
use PKP\db\DAORegistry;
use PKP\install\Installer;
use PKP\navigationMenu\NavigationMenuItemDAO;
Expand Down Expand Up @@ -61,7 +62,7 @@ public function isUpgrade()
*/
public function migrateStaticPagesToNavigationMenuItems()
{
if ($this->tableExists('static_pages')) {
if (Schema::hasTable('static_pages')) {
$contextDao = Application::getContextDAO();
$navigationMenuItemDao = DAORegistry::getDAO('NavigationMenuItemDAO'); /** @var NavigationMenuItemDAO $navigationMenuItemDao */

Expand Down
29 changes: 13 additions & 16 deletions classes/migration/install/MetricsMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,15 @@ public function up(): void
$table->integer('metric_unique');

$table->index(['context_id', 'submission_id'], 'msgd_context_id_submission_id');
switch (DB::getDriverName()) {
case 'mysql':
match (DB::getDriverName()) {
'mysql', 'mariadb' =>
// See "Create a database table" here: https://db-ip.com/db/format/ip-to-city-lite/csv.html
// where city is defined as varchar(80)
$table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date');
break;
case 'pgsql':
$table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date');
break;
}
$table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date'),

'pgsql' =>
$table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date'),
};
});
Schema::create('metrics_submission_geo_monthly', function (Blueprint $table) {
$table->comment('Monthly statistics by country, region and city for views and downloads of published submissions and files.');
Expand All @@ -269,16 +268,14 @@ public function up(): void
$table->integer('metric_unique');

$table->index(['context_id', 'submission_id'], 'msgm_context_id_submission_id');
switch (DB::getDriverName()) {
case 'mysql':
match (DB::getDriverName()) {
'mysql', 'mariadb' =>
// See "Create a database table" here: https://db-ip.com/db/format/ip-to-city-lite/csv.html
// where city is defined as varchar(80)
$table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month');
break;
case 'pgsql':
$table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month');
break;
}
$table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month'),
'pgsql' =>
$table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month'),
};
});

// Usage stats total book and chapter item temporary records
Expand Down
12 changes: 6 additions & 6 deletions classes/migration/install/OMPMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function up(): void
$table->string('publication_date_type', 32)->default('pub')->nullable();
// PUBLICATION_TYPE_PUBLICATION
$table->string('publication_type', 32)->default('publication')->nullable();
$table->float('seq', 8, 2)->default(0);
$table->float('seq')->default(0);

// FK relationship is defined where series table is created
$table->bigInteger('series_id')->nullable();
Expand Down Expand Up @@ -81,7 +81,7 @@ public function up(): void

$table->smallInteger('physical_format')->default(1)->nullable();
$table->string('entry_key', 64)->nullable();
$table->float('seq', 8, 2)->default(0);
$table->float('seq')->default(0);
$table->string('file_size', 255)->nullable();
$table->string('front_matter', 255)->nullable();
$table->string('back_matter', 255)->nullable();
Expand Down Expand Up @@ -267,7 +267,7 @@ public function up(): void
$table->index(['review_form_id'], 'series_review_form_id');

// NOT NULL not included for the sake of 1.1 upgrade, which didn't include this column
$table->float('seq', 8, 2)->default(0)->nullable();
$table->float('seq')->default(0)->nullable();

$table->smallInteger('featured')->default(0);
$table->smallInteger('editor_restricted')->default(0);
Expand Down Expand Up @@ -310,7 +310,7 @@ public function up(): void
$table->foreign('publication_id', 'submission_chapters_publication_id')->references('publication_id')->on('publications')->onDelete('cascade');
$table->index(['publication_id'], 'submission_chapters_publication_id');

$table->float('seq', 8, 2)->default(0);
$table->float('seq')->default(0);

// FK defined below (circular reference)
$table->bigInteger('source_chapter_id')->nullable();
Expand Down Expand Up @@ -352,7 +352,7 @@ public function up(): void
$table->index(['chapter_id'], 'submission_chapter_authors_chapter_id');

$table->smallInteger('primary_contact')->default(0);
$table->float('seq', 8, 2)->default(0);
$table->float('seq')->default(0);

$table->unique(['author_id', 'chapter_id'], 'chapter_authors_pkey');
});
Expand Down Expand Up @@ -391,7 +391,7 @@ public function up(): void

// NOTE: assoc_id NOT numeric to incorporate file idents
$table->string('assoc_id', 16)->nullable();
$table->float('amount', 8, 2);
$table->decimal('amount', 8, 2);
$table->string('currency_code_alpha', 3)->nullable();
$table->string('payment_method_plugin_name', 80)->nullable();
});
Expand Down
2 changes: 1 addition & 1 deletion classes/migration/install/PressMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function up(): void
$table->comment('A list of presses managed by the system.');
$table->bigInteger('press_id')->autoIncrement();
$table->string('path', 32);
$table->float('seq', 8, 2)->default(0);
$table->float('seq')->default(0);
$table->string('primary_locale', 28);
$table->smallInteger('enabled')->default(1);
$table->unique(['path'], 'press_path');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
namespace APP\migration\upgrade\v3_4_0;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class I9039_DropDeprecatedFields extends \PKP\migration\upgrade\v3_4_0\I9039_DropDeprecatedFields
Expand All @@ -28,7 +27,7 @@ public function up(): void
parent::up();

// Release the index assigned to the column before dropping it
if (DB::getDoctrineSchemaManager()->introspectTable('publication_formats')->hasIndex('publication_format_submission_id')) {
if (Schema::hasIndex('publication_formats', 'publication_format_submission_id')) {
Schema::table('publication_formats', fn (Blueprint $table) => $table->dropIndex('publication_format_submission_id'));
}

Expand Down
28 changes: 12 additions & 16 deletions classes/migration/upgrade/v3_4_0/I9231_FixMetricsIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,21 @@ public function up(): void
// and create new ones using city column prefix for MySQL
Schema::table('metrics_submission_geo_daily', function (Blueprint $table) {
$table->dropUnique('msgd_uc_load_context_submission_c_r_c_date');
switch (DB::getDriverName()) {
case 'mysql':
$table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date');
break;
case 'pgsql':
$table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date');
break;
}
match (DB::getDriverName()) {
'mysql', 'mariadb' =>
$table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date'),
'pgsql' =>
$table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date'),
};
});
Schema::table('metrics_submission_geo_monthly', function (Blueprint $table) {
$table->dropUnique('msgm_uc_context_submission_c_r_c_month');
switch (DB::getDriverName()) {
case 'mysql':
$table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month');
break;
case 'pgsql':
$table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month');
break;
}
match (DB::getDriverName()) {
'mysql', 'mariadb' =>
$table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month'),
'pgsql' =>
$table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month'),
};
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ public function up(): void
{
parent::up();

$sm = Schema::getConnection()->getDoctrineSchemaManager();
Schema::table('usage_stats_unique_title_investigations_temporary_records', function (Blueprint $table) use ($sm) {
$indexesFound = $sm->listTableIndexes('usage_stats_unique_title_investigations_temporary_records');
if (!array_key_exists('usti_load_id_context_id_ip', $indexesFound)) {
Schema::table('usage_stats_unique_title_investigations_temporary_records', function (Blueprint $table) {
if (!Schema::hasIndex('usage_stats_unique_title_investigations_temporary_records', 'usti_load_id_context_id_ip')) {
$table->index(['load_id', 'context_id', 'ip'], 'usti_load_id_context_id_ip');
}
});
Schema::table('usage_stats_unique_title_requests_temporary_records', function (Blueprint $table) use ($sm) {
$indexesFound = $sm->listTableIndexes('usage_stats_unique_title_requests_temporary_records');
if (!array_key_exists('ustr_load_id_context_id_ip', $indexesFound)) {

Schema::table('usage_stats_unique_title_requests_temporary_records', function (Blueprint $table) {
if (!Schema::hasIndex('usage_stats_unique_title_investigations_temporary_records', 'ustr_load_id_context_id_ip')) {
$table->index(['load_id', 'context_id', 'ip'], 'ustr_load_id_context_id_ip');
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* @file classes/migration/upgrade/v3_5_0/I9892_FloatToDecimalColumnTypeUpdate.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 I9892_FloatToDecimalColumnTypeUpdate
*
* @brief Changes columns types from to float to decimal
*
* @see https://laravel.com/docs/11.x/upgrade#floating-point-types
*/

namespace APP\migration\upgrade\v3_5_0;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class I9892_FloatToDecimalColumnTypeUpdate extends \PKP\migration\Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('completed_payments', function (Blueprint $table) {
$table->decimal('amount', 8, 2)->unsigned()->change();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('completed_payments', function (Blueprint $table) {
$table->double('amount')->change();
});
}
}
2 changes: 2 additions & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<migration class="APP\migration\upgrade\v3_4_0\I8151_ExtendSettingValues"/>
<migration class="PKP\migration\upgrade\v3_4_0\I8151_ExtendSettingValues"/>
<migration class="PKP\migration\upgrade\v3_4_0\I7366_UpdateUserAPIKeySettings"/>
<migration class="PKP\migration\upgrade\v3_4_0\I7463_LocaleColumn"/>
<migration class="PKP\migration\upgrade\v3_4_0\I8093_UpdateUserGroupRelationTablesFK"/>
<migration class="APP\migration\upgrade\v3_4_0\I7725_DecisionConstantsUpdate"/>
<migration class="PKP\migration\upgrade\v3_4_0\I4789_AddReviewerRequestResentColumns"/>
Expand Down Expand Up @@ -118,6 +119,7 @@
<upgrade minversion="3.1.0.0" maxversion="3.4.9.9">
<migration class="PKP\migration\upgrade\v3_5_0\PreflightCheckMigration" fallback="3.4.9.9" />
<migration class="APP\migration\upgrade\v3_5_0\I8333_AddMissingForeignKeys" />
<migration class="APP\migration\upgrade\v3_5_0\I9892_FloatToDecimalColumnTypeUpdate" />
<migration class="PKP\migration\upgrade\v3_5_0\I9895_AddAppKeyToConfigFile"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9678_RemoveScheduledTasksTable"/>
<migration class="PKP\migration\upgrade\v3_5_0\InstallEmailTemplates"/>
Expand Down
2 changes: 1 addition & 1 deletion lib/pkp
Submodule pkp updated 88 files
+1 −0 .gitignore
+1 −0 classes/core/DataObject.php
+10 −4 classes/core/PKPApplication.php
+39 −36 classes/core/PKPContainer.php
+2 −2 classes/core/PKPSessionGuard.php
+22 −0 classes/core/PKPUserProvider.php
+1 −4 classes/db/DBDataXMLParser.php
+0 −35 classes/install/Installer.php
+2 −6 classes/install/PKPInstall.php
+2 −1 classes/install/form/InstallForm.php
+12 −2 classes/middleware/ValidateCsrfToken.php
+11 −0 classes/migration/Migration.php
+3 −0 classes/migration/install/CommonMigration.php
+1 −1 classes/migration/install/ControlledVocabMigration.php
+6 −6 classes/migration/install/LogMigration.php
+2 −2 classes/migration/install/ReviewFormsMigration.php
+8 −8 classes/migration/install/SubmissionsMigration.php
+9 −18 classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php
+1 −1 classes/migration/upgrade/v3_4_0/I3573_AddPrimaryKeys.php
+1 −2 classes/migration/upgrade/v3_4_0/I6093_AddForeignKeys.php
+4 −4 classes/migration/upgrade/v3_4_0/I8073_RemoveNotesWithoutQueriesAndRelatedObjects.php
+4 −12 classes/migration/upgrade/v3_4_0/I8866_DispatchRegionCodesFixingJobs.php
+8 −10 classes/migration/upgrade/v3_4_0/I9627_AddUsageStatsTemporaryTablesIndexes.php
+6 −6 classes/migration/upgrade/v3_4_0/PreflightCheckMigration.php
+4 −4 classes/migration/upgrade/v3_5_0/I8333_AddMissingForeignKeys.php
+3 −3 classes/migration/upgrade/v3_5_0/I9462_UserUserGroupsStartEndDate.php
+3 −3 classes/notification/PKPNotificationManager.php
+4 −6 classes/services/queryBuilders/PKPStatsEditorialQueryBuilder.php
+1 −1 classes/task/ProcessQueueJobs.php
+13 −3 classes/user/Collector.php
+25 −5 classes/user/User.php
+9 −9 composer.json
+1,322 −1,597 composer.lock
+19 −4 tests/PKPTestHelper.php
+2 −3 tests/classes/citation/CitationListTokenizerFilterTest.php
+16 −20 tests/classes/config/ConfigTest.php
+6 −11 tests/classes/core/DataObjectTest.php
+6 −7 tests/classes/core/DispatcherTest.php
+3 −3 tests/classes/core/EntityDAOTest.php
+2 −3 tests/classes/core/JSONTest.php
+19 −79 tests/classes/core/PKPComponentRouterTest.php
+13 −47 tests/classes/core/PKPPageRouterTest.php
+17 −80 tests/classes/core/PKPRequestTest.php
+20 −46 tests/classes/core/PKPRouterTestCase.php
+2 −3 tests/classes/filter/ClassTypeDescriptionTest.php
+2 −3 tests/classes/filter/FilterDAOTest.php
+2 −3 tests/classes/filter/FilterGroupDAOTest.php
+2 −3 tests/classes/filter/FilterHelperTest.php
+4 −8 tests/classes/filter/FilterTest.php
+2 −3 tests/classes/filter/PersistableFilterTest.php
+7 −14 tests/classes/filter/PrimitiveTypeDescriptionTest.php
+2 −3 tests/classes/filter/TypeDescriptionFactoryTest.php
+5 −19 tests/classes/form/validation/FormValidatorArrayCustomTest.php
+3 −4 tests/classes/form/validation/FormValidatorArrayTest.php
+2 −4 tests/classes/form/validation/FormValidatorBooleanTest.php
+5 −6 tests/classes/form/validation/FormValidatorControlledVocabTest.php
+2 −4 tests/classes/form/validation/FormValidatorCustomTest.php
+2 −4 tests/classes/form/validation/FormValidatorEmailTest.php
+2 −4 tests/classes/form/validation/FormValidatorInSetTest.php
+2 −4 tests/classes/form/validation/FormValidatorLengthTest.php
+2 −5 tests/classes/form/validation/FormValidatorLocaleEmailTest.php
+2 −6 tests/classes/form/validation/FormValidatorLocaleTest.php
+2 −4 tests/classes/form/validation/FormValidatorPostTest.php
+2 −4 tests/classes/form/validation/FormValidatorRegExpTest.php
+2 −19 tests/classes/form/validation/FormValidatorTest.php
+2 −4 tests/classes/form/validation/FormValidatorUrlTest.php
+2 −4 tests/classes/form/validation/FormValidatorUsernameTest.php
+3 −21 tests/classes/i18n/LocaleTest.php
+3 −3 tests/classes/metadata/MetadataDescriptionTest.php
+2 −48 tests/classes/metadata/MetadataPropertyTest.php
+4 −12 tests/classes/publication/PublicationTest.php
+6 −9 tests/classes/scheduledTask/ScheduledTaskHelperTest.php
+4 −17 tests/classes/security/authorization/AuthorizationDecisionManagerTest.php
+2 −3 tests/classes/security/authorization/AuthorizationPolicyTest.php
+4 −4 tests/classes/security/authorization/PKPPublicAccessPolicyTest.php
+2 −3 tests/classes/security/authorization/PolicySetTest.php
+3 −3 tests/classes/security/authorization/PolicyTestCase.php
+2 −3 tests/classes/security/authorization/RoleBasedHandlerOperationPolicyTest.php
+4 −5 tests/classes/validation/ValidatorControlledVocabTest.php
+2 −4 tests/classes/validation/ValidatorEmailTest.php
+2 −5 tests/classes/validation/ValidatorISSNTest.php
+2 −5 tests/classes/validation/ValidatorORCIDTest.php
+5 −18 tests/classes/validation/ValidatorTypeDescriptionTest.php
+2 −5 tests/classes/validation/ValidatorUrlTest.php
+5 −6 tests/classes/xslt/XMLTypeDescriptionTest.php
+20 −12 tests/phpunit.xml
+10 −9 tests/plugins/PluginTestCase.php
+2 −2 tools/runAllTests.sh
4 changes: 2 additions & 2 deletions plugins/paymethod/paypal/composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"require": {
"symfony/event-dispatcher" : "^6.0",
"symfony/event-dispatcher" : "^7.0",
"omnipay/paypal": "^3.0",
"guzzlehttp/guzzle": "^7.0",
"php-http/guzzle7-adapter": "^1.0"
},
"config": {
"platform": {
"php": "8.1.0"
"php": "8.2.0"
},
"allow-plugins": {
"php-http/discovery": true
Expand Down
Loading