From f27d3667679e1b4b20cad358fae658f853d57327 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Feb 2023 13:34:44 +0100 Subject: [PATCH 1/6] fix(CI): Run repair steps against Oracle DB Signed-off-by: Joas Schilling --- .github/workflows/oci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/oci.yml b/.github/workflows/oci.yml index ef1782342ed4f..924196b3e90a6 100644 --- a/.github/workflows/oci.yml +++ b/.github/workflows/oci.yml @@ -45,6 +45,10 @@ jobs: ./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin php -f index.php + - name: Run repair steps + run: | + ./occ maintenance:repair --include-expensive + - name: PHPUnit working-directory: tests run: phpunit --configuration phpunit-autotest.xml --group DB,SLOWDB From 75ecdd77e8920dde507e9f420090dcd0b2e976af Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 23 Feb 2023 16:58:15 +0100 Subject: [PATCH 2/6] First run unit tests so they don't fail Signed-off-by: Joas Schilling --- .github/workflows/oci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/oci.yml b/.github/workflows/oci.yml index 924196b3e90a6..470e80859d51a 100644 --- a/.github/workflows/oci.yml +++ b/.github/workflows/oci.yml @@ -45,14 +45,14 @@ jobs: ./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin php -f index.php - - name: Run repair steps - run: | - ./occ maintenance:repair --include-expensive - - name: PHPUnit working-directory: tests run: phpunit --configuration phpunit-autotest.xml --group DB,SLOWDB + - name: Run repair steps + run: | + ./occ maintenance:repair --include-expensive + summary: permissions: contents: none From 9904e7b72a656f693c26c56a942c151d1ca5aaf7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Feb 2023 14:33:06 +0100 Subject: [PATCH 3/6] Fail the repair command when an error happened Signed-off-by: Joas Schilling --- core/Command/Maintenance/Repair.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/Command/Maintenance/Repair.php b/core/Command/Maintenance/Repair.php index 01e62f2cd3232..a1d97476f9412 100644 --- a/core/Command/Maintenance/Repair.php +++ b/core/Command/Maintenance/Repair.php @@ -53,6 +53,7 @@ class Repair extends Command { private ProgressBar $progress; private OutputInterface $output; private IAppManager $appManager; + protected bool $errored = false; public function __construct(\OC\Repair $repair, IConfig $config, IEventDispatcher $dispatcher, IAppManager $appManager) { $this->repair = $repair; @@ -104,6 +105,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } + + $maintenanceMode = $this->config->getSystemValueBool('maintenance'); $this->config->setSystemValue('maintenance', true); @@ -120,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->repair->run(); $this->config->setSystemValue('maintenance', $maintenanceMode); - return 0; + return $this->errored ? 1 : 0; } public function handleRepairFeedBack(Event $event): void { @@ -139,6 +142,7 @@ public function handleRepairFeedBack(Event $event): void { $this->output->writeln(' - WARNING: ' . $event->getMessage() . ''); } elseif ($event instanceof RepairErrorEvent) { $this->output->writeln(' - ERROR: ' . $event->getMessage() . ''); + $this->errored = true; } } } From f333c7f23198b655305ca2d7ca31b14b91943881 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Feb 2023 14:40:50 +0100 Subject: [PATCH 4/6] fix(OCC): Don't throw in the repair step for phone validation Signed-off-by: Joas Schilling --- lib/private/Repair/NC21/ValidatePhoneNumber.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/Repair/NC21/ValidatePhoneNumber.php b/lib/private/Repair/NC21/ValidatePhoneNumber.php index 3217a1f082c53..964d62ad0abb1 100644 --- a/lib/private/Repair/NC21/ValidatePhoneNumber.php +++ b/lib/private/Repair/NC21/ValidatePhoneNumber.php @@ -56,7 +56,8 @@ public function getName(): string { public function run(IOutput $output): void { if ($this->config->getSystemValueString('default_phone_region', '') === '') { - throw new \Exception('Can not validate phone numbers without `default_phone_region` being set in the config file'); + $output->warning('Can not validate phone numbers without `default_phone_region` being set in the config file'); + return; } $numUpdated = 0; From 3e46245eca4d36a99d63ecd823f49bfd6355ee18 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Feb 2023 14:44:42 +0100 Subject: [PATCH 5/6] fix(Repair): Fix repair step compatibility with Oracle DB Signed-off-by: Joas Schilling --- apps/dav/lib/Migration/RemoveObjectProperties.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dav/lib/Migration/RemoveObjectProperties.php b/apps/dav/lib/Migration/RemoveObjectProperties.php index c72dfbebfea3c..b771b70e68404 100644 --- a/apps/dav/lib/Migration/RemoveObjectProperties.php +++ b/apps/dav/lib/Migration/RemoveObjectProperties.php @@ -57,7 +57,7 @@ public function run(IOutput $output) { $query = $this->connection->getQueryBuilder(); $updated = $query->delete('properties') ->where($query->expr()->in('propertyname', $query->createNamedParameter([self::RESOURCE_TYPE_PROPERTY, self::ME_CARD_PROPERTY, self::CALENDAR_TRANSP_PROPERTY], IQueryBuilder::PARAM_STR_ARRAY))) - ->andWhere($query->expr()->eq('propertyvalue', $query->createNamedParameter('Object'))) + ->andWhere($query->expr()->eq('propertyvalue', $query->createNamedParameter('Object'), IQueryBuilder::PARAM_STR)) ->executeStatement(); $output->info("$updated invalid object properties removed."); From 1f4a0529e23a41d68096dea45f975b59c0ad6629 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Feb 2023 14:46:00 +0100 Subject: [PATCH 6/6] Fix appconfig compatibility with Oracle DB Signed-off-by: Joas Schilling --- lib/private/AppConfig.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index 325220823b89e..e5d081444e1b8 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -34,6 +34,7 @@ use OC\DB\Connection; use OC\DB\OracleConnection; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IAppConfig; use OCP\IConfig; @@ -300,7 +301,7 @@ public function setValue($app, $key, $value) { $sql->andWhere( $sql->expr()->orX( $sql->expr()->isNull('configvalue'), - $sql->expr()->neq('configvalue', $sql->createNamedParameter($value)) + $sql->expr()->neq('configvalue', $sql->createNamedParameter($value), IQueryBuilder::PARAM_STR) ) ); }