Merge pull request #340 from creative-commoners/pulls/4.0/fix-broken-builds

FIX Check type is number before pass to setSubsiteId method
This commit is contained in:
Guy Sartorelli 2023-02-16 11:27:01 +13:00 committed by GitHub
commit 2f56d944c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);