diff --git a/lib/Command/CacheRefresh.php b/lib/Command/CacheRefresh.php index 5108ee1a..b53b47a9 100644 --- a/lib/Command/CacheRefresh.php +++ b/lib/Command/CacheRefresh.php @@ -38,6 +38,7 @@ use OCA\Social\Service\CacheActorService; use OCA\Social\Service\DocumentService; use OCA\Social\Service\HashtagService; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class CacheRefresh extends Base { @@ -61,7 +62,8 @@ class CacheRefresh extends Base { protected function configure() { parent::configure(); $this->setName('social:cache:refresh') - ->setDescription('Update the cache'); + ->setDescription('Update the cache') + ->addOption('force', 'f', InputOption::VALUE_NONE, 'enforce update of cached account'); } /** @@ -80,7 +82,7 @@ class CacheRefresh extends Base { $result = $this->cacheActorService->missingCacheRemoteActors(); $output->writeLn($result . ' remote accounts created'); - $result = $this->cacheActorService->manageCacheRemoteActors(); + $result = $this->cacheActorService->manageCacheRemoteActors($input->getOption('force')); $output->writeLn($result . ' remote accounts updated'); $result = $this->documentService->manageCacheDocuments(); diff --git a/lib/Db/CacheActorsRequest.php b/lib/Db/CacheActorsRequest.php index 462f52eb..86266a46 100644 --- a/lib/Db/CacheActorsRequest.php +++ b/lib/Db/CacheActorsRequest.php @@ -91,7 +91,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { $iconId = $actor->getIconId(); } - $qb->setValue('icon_id', $qb->createNamedParameter($iconId)); + $qb->setValue('icon_id', $qb->createNamedParameter($qb->prim($iconId))); $qb->generatePrimaryKey($actor->getId()); try { @@ -143,9 +143,8 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { $iconId = $actor->getIconId(); } - $qb->set('icon_id', $qb->createNamedParameter($iconId)); - - $this->limitToIdString($qb, $actor->getId()); + $qb->set('icon_id', $qb->createNamedParameter($qb->prim($iconId))); + $qb->limitToIdString($actor->getId()); return $qb->executeStatement(); } @@ -226,10 +225,12 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { * @return Person[] * @throws Exception */ - public function getRemoteActorsToUpdate(): array { + public function getRemoteActorsToUpdate(bool $force = false): array { $qb = $this->getCacheActorsSelectSql(); $this->limitToLocal($qb, false); - $this->limitToCreation($qb, self::CACHE_TTL); + if (!$force) { + $this->limitToCreation($qb, self::CACHE_TTL); + } return $this->getCacheActorsFromRequest($qb); } diff --git a/lib/Db/SocialCrossQueryBuilder.php b/lib/Db/SocialCrossQueryBuilder.php index 86fde0ef..39487768 100644 --- a/lib/Db/SocialCrossQueryBuilder.php +++ b/lib/Db/SocialCrossQueryBuilder.php @@ -185,7 +185,7 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder { ->selectAlias('cd.creation', 'cachedocument_creation') ->leftJoin( $this->getDefaultSelectAlias(), CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'cd', - $expr->eq($func->lower($pf . '.' . $fieldDocumentId), $func->lower('cd.id')) + $expr->eq($pf . '.' . $fieldDocumentId, 'cd.id_prim') ); } diff --git a/lib/Service/CacheActorService.php b/lib/Service/CacheActorService.php index b8635f97..9c78bee9 100644 --- a/lib/Service/CacheActorService.php +++ b/lib/Service/CacheActorService.php @@ -291,8 +291,8 @@ class CacheActorService { * @return int * @throws Exception */ - public function manageCacheRemoteActors(): int { - $update = $this->cacheActorsRequest->getRemoteActorsToUpdate(); + public function manageCacheRemoteActors(bool $force = false): int { + $update = $this->cacheActorsRequest->getRemoteActorsToUpdate($force); foreach ($update as $item) { try {