diff --git a/composer.json b/composer.json index 1c5a4c8..d951f25 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": "^8", - "symbiote/silverstripe-queuedjobs": "^5", + "symbiote/silverstripe-queuedjobs": "^4 || ^5", "algolia/algoliasearch-client-php": "^3", "ramsey/uuid": "^4", "masterminds/html5": "^2.7" diff --git a/src/Service/AlgoliaPageCrawler.php b/src/Service/AlgoliaPageCrawler.php index 0aa6843..e847bfe 100644 --- a/src/Service/AlgoliaPageCrawler.php +++ b/src/Service/AlgoliaPageCrawler.php @@ -13,6 +13,7 @@ use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Configurable; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Versioned\Versioned; use SilverStripe\View\Requirements; use SilverStripe\View\SSViewer; use Throwable; @@ -64,6 +65,10 @@ public function getMainContent(): string $useXpath = false; $selector = $this->config()->get('content_element_tag'); } + + $originalStage = Versioned::get_stage(); + //Always set to live to ensure we don't pick up draft content in our render eg. draft elemental blocks + Versioned::set_stage(Versioned::LIVE); // Enable frontend themes in order to correctly render the elements as // they would be for the frontend @@ -117,6 +122,8 @@ public function getMainContent(): string Requirements::restore(); Config::unnest(); + Versioned::set_stage($originalStage); + return $output; } }