From 79ce8f35b81a7d959a51ebf00057d480c521b747 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 11 Aug 2026 10:20:18 +0200 Subject: [PATCH 1/2] fix(tests): Fix migration tests The test was hardcoding DBAL Table in method type hinting and this was changed to ITable now. And while not required, also adapt migrations to new code signature Assisted-by: Claude Code:claude-opus-5 Signed-off-by: Carl Schwan --- .../Version2006Date20170808154933.php | 42 ++++----- .../Version2006Date20170808155040.php | 2 +- .../Version2007Date20181107114613.php | 2 +- .../Version2008Date20181011095117.php | 4 +- .../Version2011Date20201006132544.php | 8 +- .../Version2011Date20201006132545.php | 4 +- .../Version2011Date20201006132546.php | 3 +- psalm.xml | 5 - .../Version8000Date20260603120000Test.php | 7 +- vendor-bin/psalm/composer.lock | 93 ++++++++++++++++++- 10 files changed, 125 insertions(+), 45 deletions(-) diff --git a/lib/Migration/Version2006Date20170808154933.php b/lib/Migration/Version2006Date20170808154933.php index ed98e142a..565663220 100644 --- a/lib/Migration/Version2006Date20170808154933.php +++ b/lib/Migration/Version2006Date20170808154933.php @@ -7,8 +7,8 @@ namespace OCA\Activity\Migration; -use Doctrine\DBAL\Types\Types; use OCP\DB\ISchemaWrapper; +use OCP\DB\Types; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; @@ -32,55 +32,55 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op 'notnull' => true, 'length' => 20, ]); - $table->addColumn('timestamp', 'integer', [ + $table->addColumn('timestamp', Types::INTEGER, [ 'notnull' => true, 'length' => 4, 'default' => 0, ]); - $table->addColumn('priority', 'integer', [ + $table->addColumn('priority', Types::INTEGER, [ 'notnull' => true, 'length' => 4, 'default' => 0, ]); - $table->addColumn('type', 'string', [ + $table->addColumn('type', Types::STRING, [ 'notnull' => false, 'length' => 255, ]); - $table->addColumn('user', 'string', [ + $table->addColumn('user', Types::STRING, [ 'notnull' => false, 'length' => 64, ]); - $table->addColumn('affecteduser', 'string', [ + $table->addColumn('affecteduser', Types::STRING, [ 'notnull' => true, 'length' => 64, ]); - $table->addColumn('app', 'string', [ + $table->addColumn('app', Types::STRING, [ 'notnull' => true, 'length' => 32, ]); - $table->addColumn('subject', 'string', [ + $table->addColumn('subject', Types::STRING, [ 'notnull' => true, 'length' => 255, ]); - $table->addColumn('subjectparams', 'text', [ + $table->addColumn('subjectparams', Types::TEXT, [ 'notnull' => true, ]); - $table->addColumn('message', 'string', [ + $table->addColumn('message', Types::STRING, [ 'notnull' => false, 'length' => 255, ]); - $table->addColumn('messageparams', 'text', [ + $table->addColumn('messageparams', Types::TEXT, [ 'notnull' => false, ]); - $table->addColumn('file', 'string', [ + $table->addColumn('file', Types::STRING, [ 'notnull' => false, 'length' => 4000, ]); - $table->addColumn('link', 'string', [ + $table->addColumn('link', Types::STRING, [ 'notnull' => false, 'length' => 4000, ]); - $table->addColumn('object_type', 'string', [ + $table->addColumn('object_type', Types::STRING, [ 'notnull' => false, 'length' => 255, ]); @@ -105,33 +105,33 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op 'notnull' => true, 'length' => 20, ]); - $table->addColumn('amq_timestamp', 'integer', [ + $table->addColumn('amq_timestamp', Types::INTEGER, [ 'notnull' => true, 'length' => 4, 'default' => 0, ]); - $table->addColumn('amq_latest_send', 'integer', [ + $table->addColumn('amq_latest_send', Types::INTEGER, [ 'notnull' => true, 'length' => 4, 'default' => 0, ]); - $table->addColumn('amq_type', 'string', [ + $table->addColumn('amq_type', Types::STRING, [ 'notnull' => true, 'length' => 255, ]); - $table->addColumn('amq_affecteduser', 'string', [ + $table->addColumn('amq_affecteduser', Types::STRING, [ 'notnull' => true, 'length' => 64, ]); - $table->addColumn('amq_appid', 'string', [ + $table->addColumn('amq_appid', Types::STRING, [ 'notnull' => true, 'length' => 255, ]); - $table->addColumn('amq_subject', 'string', [ + $table->addColumn('amq_subject', Types::STRING, [ 'notnull' => true, 'length' => 255, ]); - $table->addColumn('amq_subjectparams', 'text', [ + $table->addColumn('amq_subjectparams', Types::TEXT, [ 'notnull' => true, ]); $table->setPrimaryKey(['mail_id']); diff --git a/lib/Migration/Version2006Date20170808155040.php b/lib/Migration/Version2006Date20170808155040.php index 50e573ffe..92aedd8b8 100644 --- a/lib/Migration/Version2006Date20170808155040.php +++ b/lib/Migration/Version2006Date20170808155040.php @@ -17,7 +17,7 @@ class Version2006Date20170808155040 extends SimpleMigrationStep { * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options * @return null|ISchemaWrapper - * @throws \Doctrine\DBAL\Schema\SchemaException + * @throws \OCP\DB\Schema\SchemaException * @since 13.0.0 */ #[\Override] diff --git a/lib/Migration/Version2007Date20181107114613.php b/lib/Migration/Version2007Date20181107114613.php index ccdca55cf..2b8f6db49 100644 --- a/lib/Migration/Version2007Date20181107114613.php +++ b/lib/Migration/Version2007Date20181107114613.php @@ -9,8 +9,8 @@ namespace OCA\Activity\Migration; use Closure; -use Doctrine\DBAL\Types\Types; use OCP\DB\ISchemaWrapper; +use OCP\DB\Types; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; diff --git a/lib/Migration/Version2008Date20181011095117.php b/lib/Migration/Version2008Date20181011095117.php index a89939970..ca9bcb77d 100644 --- a/lib/Migration/Version2008Date20181011095117.php +++ b/lib/Migration/Version2008Date20181011095117.php @@ -9,9 +9,9 @@ namespace OCA\Activity\Migration; use Closure; -use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Types; use OCP\DB\ISchemaWrapper; +use OCP\DB\Schema\SchemaException; +use OCP\DB\Types; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; diff --git a/lib/Migration/Version2011Date20201006132544.php b/lib/Migration/Version2011Date20201006132544.php index fed6b1368..1bdbcf823 100644 --- a/lib/Migration/Version2011Date20201006132544.php +++ b/lib/Migration/Version2011Date20201006132544.php @@ -9,8 +9,8 @@ namespace OCA\Activity\Migration; use Closure; -use Doctrine\DBAL\Types\Type; use OCP\DB\ISchemaWrapper; +use OCP\DB\Types; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; @@ -37,14 +37,14 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $table = $schema->getTable('activity_mq'); $column = $table->getColumn('amq_appid'); - $column->setType(Type::getType('string')); + $column->setType(Types::STRING); $column->setNotnull(true); $column->setLength(32); $column = $table->getColumn('amq_subjectparams'); // Can't switch from Long to clob on Oracle, so we need an intermediate column - if ($column->getType() !== Type::getType('text')) { - $table->addColumn('amq_subjectparams2', 'text', [ + if ($column->getType()->getName() !== Types::TEXT) { + $table->addColumn('amq_subjectparams2', Types::TEXT, [ 'notnull' => false, ]); } diff --git a/lib/Migration/Version2011Date20201006132545.php b/lib/Migration/Version2011Date20201006132545.php index 13ce41688..9fbcb53b5 100644 --- a/lib/Migration/Version2011Date20201006132545.php +++ b/lib/Migration/Version2011Date20201006132545.php @@ -9,8 +9,8 @@ namespace OCA\Activity\Migration; use Closure; -use Doctrine\DBAL\Types\Type; use OCP\DB\ISchemaWrapper; +use OCP\DB\Types; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; @@ -28,7 +28,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $table = $schema->getTable('activity_mq'); $column = $table->getColumn('amq_subjectparams'); - if ($column->getType() !== Type::getType('text')) { + if ($column->getType()->getName() !== Types::TEXT) { $table->dropColumn('amq_subjectparams'); return $schema; } diff --git a/lib/Migration/Version2011Date20201006132546.php b/lib/Migration/Version2011Date20201006132546.php index 68940e7fb..30fc009c4 100644 --- a/lib/Migration/Version2011Date20201006132546.php +++ b/lib/Migration/Version2011Date20201006132546.php @@ -10,6 +10,7 @@ use Closure; use OCP\DB\ISchemaWrapper; +use OCP\DB\Types; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; @@ -35,7 +36,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $table = $schema->getTable('activity_mq'); if (!$table->hasColumn('amq_subjectparams')) { - $table->addColumn('amq_subjectparams', 'text', [ + $table->addColumn('amq_subjectparams', Types::TEXT, [ 'notnull' => false, ]); return $schema; diff --git a/psalm.xml b/psalm.xml index 87f648069..0dfcf7ff1 100644 --- a/psalm.xml +++ b/psalm.xml @@ -42,11 +42,6 @@ - - - - - diff --git a/tests/Migration/Version8000Date20260603120000Test.php b/tests/Migration/Version8000Date20260603120000Test.php index 969d3449c..067a0c4ed 100644 --- a/tests/Migration/Version8000Date20260603120000Test.php +++ b/tests/Migration/Version8000Date20260603120000Test.php @@ -12,6 +12,7 @@ use OCA\Activity\Migration\Version8000Date20260603120000; use OCA\Activity\Tests\TestCase; use OCP\DB\ISchemaWrapper; +use OCP\DB\Schema\ITable; use OCP\Migration\IOutput; use PHPUnit\Framework\MockObject\MockObject; @@ -34,7 +35,7 @@ protected function setUp(): void { * migration adds the covering composite index and drops the now-redundant one. */ public function testAddsCompositeIndexAndDropsRedundantOne(): void { - $table = $this->createMock(Table::class); + $table = $this->createMock(ITable::class); $table->method('hasIndex') ->willReturnMap([ ['amp_user_send', false], @@ -58,7 +59,7 @@ public function testAddsCompositeIndexAndDropsRedundantOne(): void { * must be a no-op so re-runs / fresh installs are not touched. */ public function testIsIdempotentWhenAlreadyMigrated(): void { - $table = $this->createMock(Table::class); + $table = $this->createMock(ITable::class); $table->method('hasIndex') ->willReturnMap([ ['amp_user_send', true], @@ -91,7 +92,7 @@ public function testSkipsWhenTableIsMissing(): void { $this->assertNull($result); } - protected function getSchemaMock(Table&MockObject $table): ISchemaWrapper&MockObject { + protected function getSchemaMock(ITable&MockObject $table): ISchemaWrapper&MockObject { $schema = $this->createMock(ISchemaWrapper::class); $schema->method('hasTable') ->with('activity_mq') diff --git a/vendor-bin/psalm/composer.lock b/vendor-bin/psalm/composer.lock index d2cdc8aa3..bad0e721d 100644 --- a/vendor-bin/psalm/composer.lock +++ b/vendor-bin/psalm/composer.lock @@ -1638,12 +1638,12 @@ "source": { "type": "git", "url": "https://github.com/nextcloud-deps/ocp.git", - "reference": "cba9ce148ee675a84f659024d0362f47193e5230" + "reference": "db762274e838d1cc0149a3e4718f27823f306646" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/cba9ce148ee675a84f659024d0362f47193e5230", - "reference": "cba9ce148ee675a84f659024d0362f47193e5230", + "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/db762274e838d1cc0149a3e4718f27823f306646", + "reference": "db762274e838d1cc0149a3e4718f27823f306646", "shasum": "" }, "require": { @@ -1652,7 +1652,10 @@ "psr/container": "^2.0.2", "psr/event-dispatcher": "^1.0", "psr/http-client": "^1.0.3", - "psr/log": "^3.0.2" + "psr/log": "^3.0.2", + "symfony/polyfill-intl-normalizer": "^1.38", + "symfony/polyfill-php84": "^1.38", + "symfony/polyfill-php85": "^1.41" }, "default-branch": true, "type": "library", @@ -1680,7 +1683,7 @@ "issues": "https://github.com/nextcloud-deps/ocp/issues", "source": "https://github.com/nextcloud-deps/ocp/tree/master" }, - "time": "2026-08-09T00:51:34+00:00" + "time": "2026-08-11T07:17:04+00:00" }, { "name": "nikic/php-parser", @@ -3219,6 +3222,86 @@ ], "time": "2026-05-26T12:51:13+00:00" }, + { + "name": "symfony/polyfill-php85", + "version": "v1.41.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php85.git", + "reference": "255fab485aaa1006ed411040c42aecd7b5302d7a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/255fab485aaa1006ed411040c42aecd7b5302d7a", + "reference": "255fab485aaa1006ed411040c42aecd7b5302d7a", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php85\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.5+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php85/tree/v1.41.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-07-01T12:47:55+00:00" + }, { "name": "symfony/service-contracts", "version": "v3.7.1", From c703a0b7fbccd7f4c0c5cd01eba724f268bad4e2 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 11 Aug 2026 10:39:08 +0200 Subject: [PATCH 2/2] fix: Port to getDatabaseProvider Signed-off-by: Carl Schwan --- lib/Data.php | 4 +--- tests/Migration/Version8000Date20260603120000Test.php | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/Data.php b/lib/Data.php index 1fb908990..0dc82e3eb 100644 --- a/lib/Data.php +++ b/lib/Data.php @@ -9,7 +9,6 @@ namespace OCA\Activity; -use Doctrine\DBAL\Platforms\MySQLPlatform; use OCA\Activity\Filter\AllFilter; use OCP\Activity\Exceptions\FilterNotFoundException; use OCP\Activity\IEvent; @@ -526,8 +525,7 @@ public function expire($expireDays = 365) { * @psalm-param list $conditions */ public function deleteActivities(array $conditions): void { - $platform = $this->connection->getDatabasePlatform(); - if ($platform instanceof MySQLPlatform) { + if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL) { $this->logger->debug('Choosing chunked activity delete for MySQL/MariaDB', ['app' => 'activity']); $this->deleteActivitiesForMySQL($conditions); return; diff --git a/tests/Migration/Version8000Date20260603120000Test.php b/tests/Migration/Version8000Date20260603120000Test.php index 067a0c4ed..2704accd7 100644 --- a/tests/Migration/Version8000Date20260603120000Test.php +++ b/tests/Migration/Version8000Date20260603120000Test.php @@ -8,7 +8,6 @@ namespace OCA\Activity\Tests\Migration; -use Doctrine\DBAL\Schema\Table; use OCA\Activity\Migration\Version8000Date20260603120000; use OCA\Activity\Tests\TestCase; use OCP\DB\ISchemaWrapper;