mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
FIX Correctly decode page type blacklist from JSON
This commit is contained in:
parent
8398a361cd
commit
afd23be64c
@ -19,6 +19,7 @@ use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\SiteConfig\SiteConfig;
|
||||
use SilverStripe\Subsites\Model\Subsite;
|
||||
@ -478,20 +479,17 @@ class SiteTreeSubsites extends DataExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member
|
||||
* @param Member $member
|
||||
* @return boolean|null
|
||||
*/
|
||||
public function canCreate($member = null)
|
||||
{
|
||||
// Typically called on a singleton, so we're not using the Subsite() relation
|
||||
$subsite = Subsite::currentSubsite();
|
||||
|
||||
if ($subsite && $subsite->exists() && $subsite->PageTypeBlacklist) {
|
||||
$blacklist = str_replace(['[', '"', ']'], '', $subsite->PageTypeBlacklist);
|
||||
$blacklist = str_replace(['\\\\'], '\\', $blacklist);
|
||||
$blacklisted = explode(',', $blacklist);
|
||||
$blacklist = Convert::json2array($subsite->PageTypeBlacklist) ?: [];
|
||||
|
||||
if (in_array(get_class($this->owner), $blacklisted)) {
|
||||
if (in_array(get_class($this->owner), $blacklist)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
||||
$s2 = $this->objFromFixture(Subsite::class, 'domaintest2');
|
||||
$page = singleton(SiteTree::class);
|
||||
|
||||
$s1->PageTypeBlacklist = implode(',', [TestClassA::class, ErrorPage::class]);
|
||||
$s1->PageTypeBlacklist = json_encode([TestClassA::class, ErrorPage::class]);
|
||||
$s1->write();
|
||||
|
||||
Subsite::changeSubsite($s1);
|
||||
@ -257,7 +257,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
||||
$s1 = $this->objFromFixture(Subsite::class, 'domaintest1');
|
||||
$s2 = $this->objFromFixture(Subsite::class, 'domaintest2');
|
||||
|
||||
$s1->PageTypeBlacklist = implode(',', [TestClassA::class, ErrorPage::class]);
|
||||
$s1->PageTypeBlacklist = json_encode([TestClassA::class, ErrorPage::class]);
|
||||
$s1->write();
|
||||
|
||||
Subsite::changeSubsite($s1);
|
||||
|
Loading…
Reference in New Issue
Block a user