FIX Broken builds

This commit is contained in:
Sabina Talipova 2023-02-15 19:07:06 +13:00
parent cf2fa0ab0c
commit 4f92bcdbf5

View File

@ -2,6 +2,7 @@
namespace SilverStripe\FullTextSearch\Search\Variants; namespace SilverStripe\FullTextSearch\Search\Variants;
use InvalidArgumentException;
use SilverStripe\Assets\File; use SilverStripe\Assets\File;
use SilverStripe\CMS\Model\SiteTree; use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex; use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex;
@ -71,6 +72,12 @@ class SearchVariantSubsites extends SearchVariant
return; return;
} }
if (is_numeric($state)) {
$state = (int) $state;
} else {
throw new InvalidArgumentException("Invalid state ID. State ID should be number.");
}
// Note: Setting directly to the SubsiteState because we don't want the subsite ID to be persisted // Note: Setting directly to the SubsiteState because we don't want the subsite ID to be persisted
// like Subsite::changeSubsite would do. // like Subsite::changeSubsite would do.
SubsiteState::singleton()->setSubsiteId($state); SubsiteState::singleton()->setSubsiteId($state);