Skip to content

Commit

Permalink
Merge pull request #36886 from nextcloud/backport/36781/stable25
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored Mar 6, 2023
2 parents 077143a + 1f4a052 commit b4a1631
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/oci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ jobs:
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
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Migration/RemoveObjectProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
6 changes: 5 additions & 1 deletion core/Command/Maintenance/Repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -104,6 +105,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}



$maintenanceMode = $this->config->getSystemValueBool('maintenance');
$this->config->setSystemValue('maintenance', true);

Expand All @@ -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 {
Expand All @@ -139,6 +142,7 @@ public function handleRepairFeedBack(Event $event): void {
$this->output->writeln('<comment> - WARNING: ' . $event->getMessage() . '</comment>');
} elseif ($event instanceof RepairErrorEvent) {
$this->output->writeln('<error> - ERROR: ' . $event->getMessage() . '</error>');
$this->errored = true;
}
}
}
3 changes: 2 additions & 1 deletion lib/private/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

use OC\DB\Connection;
use OC\DB\OracleConnection;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IAppConfig;
use OCP\IConfig;

Expand Down Expand Up @@ -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)
)
);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Repair/NC21/ValidatePhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b4a1631

Please sign in to comment.