summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2023-03-15 17:05:32 -0100
committerGitHub <noreply@github.com>2023-03-15 17:05:32 -0100
commit3b2e834dc33559332732fe2f6879da6a15031288 (patch)
treef49f5c07ecd6aa60b851dc13190ca539b4e68ea8
parent3fc14ced4f6c04b6720dfbb25ebb0788c9dc1b0f (diff)
parentdd0ef70b749d17f2e71532ff3aa7959f7da44c5e (diff)
Merge pull request #1662 from nextcloud/fix/noid/avatar-2
use id_prim on icon_id
-rw-r--r--lib/Command/CacheRefresh.php6
-rw-r--r--lib/Db/CacheActorsRequest.php13
-rw-r--r--lib/Db/SocialCrossQueryBuilder.php2
-rw-r--r--lib/Service/CacheActorService.php4
4 files changed, 14 insertions, 11 deletions
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 {