diff --git a/public/modules/custom/helfi_google_api/src/GoogleApi.php b/public/modules/custom/helfi_google_api/src/GoogleApi.php index 3b0d6236..1904ae79 100644 --- a/public/modules/custom/helfi_google_api/src/GoogleApi.php +++ b/public/modules/custom/helfi_google_api/src/GoogleApi.php @@ -49,7 +49,7 @@ public function __construct( } /** - * Correct environment and key is set. + * Correct environment and key is set and enabled is true. * * @return bool * The api is set up @@ -59,7 +59,7 @@ public function isDryRun(): bool { $key = $config->get('indexing_api_key') ?: ''; $isEnabled = $config->get('enabled') ?: FALSE; - return $key && $isEnabled; + return !$key && !$isEnabled; } /** @@ -74,8 +74,8 @@ public function isDryRun(): bool { * Object which holds the handled urls and request errors. */ public function indexBatch(array $urls, bool $update): Response { - if (!$this->isDryRun()) { - return new Response($urls, debug: TRUE); + if ($this->isDryRun()) { + return new Response($urls, dryRun: TRUE); } $batch = $this->indexingService->createBatch(); diff --git a/public/modules/custom/helfi_google_api/src/JobIndexingService.php b/public/modules/custom/helfi_google_api/src/JobIndexingService.php index 8b1a2b07..490635d3 100644 --- a/public/modules/custom/helfi_google_api/src/JobIndexingService.php +++ b/public/modules/custom/helfi_google_api/src/JobIndexingService.php @@ -228,6 +228,11 @@ public function checkEntityIndexStatus(JobListing $entity): string { * Has temporary redirect. */ public function hasTemporaryRedirect(JobListing $entity, string $langcode): bool { + // In case of dry run, we can always say FALSE. + if ($this->googleApi->isDryRun()) { + return FALSE; + } + $job_alias = $this->getEntityAlias($entity, $langcode); $query = $this->entityTypeManager->getStorage('redirect')