diff --git a/app/Console/Commands/ReclassifyDocumentContent.php b/app/Console/Commands/ReclassifyDocumentContent.php index fbe08e1..71ea2f1 100644 --- a/app/Console/Commands/ReclassifyDocumentContent.php +++ b/app/Console/Commands/ReclassifyDocumentContent.php @@ -4,7 +4,6 @@ namespace App\Console\Commands; use App\Models\Article; use App\Models\ArticleCategory; -use App\Services\SiteRevalidationService; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; @@ -121,11 +120,20 @@ class ReclassifyDocumentContent extends Command }); $revalidated = 0; + $revalidateServiceClass = '\\App\\Services\\SiteRevalidationService'; + $canRevalidate = class_exists($revalidateServiceClass); + + if (! $canRevalidate) { + $this->warn('SiteRevalidationService not found. Skipping cache revalidation.'); + } + foreach ($articles as $article) { - if ($article->isPublished()) { - SiteRevalidationService::revalidateArticle($article->slug); - $revalidated++; + if (! $article->isPublished() || ! $canRevalidate) { + continue; } + + $revalidateServiceClass::revalidateArticle($article->slug); + $revalidated++; } $this->newLine();