mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Merge pull request #478 from creative-commoners/pulls/2/php81
ENH PHP 8.1 compatibility
This commit is contained in:
commit
7860a03180
@ -77,8 +77,8 @@ class FileSubsites extends DataExtension
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sect = array_values($query->getSelect());
|
$sect = array_values($query->getSelect() ?? []);
|
||||||
$isCounting = strpos($sect[0], 'COUNT') !== false;
|
$isCounting = strpos($sect[0] ?? '', 'COUNT') !== false;
|
||||||
|
|
||||||
// Ordering when deleting or counting doesn't apply
|
// Ordering when deleting or counting doesn't apply
|
||||||
if (!$isCounting) {
|
if (!$isCounting) {
|
||||||
|
@ -106,7 +106,7 @@ class GroupSubsites extends DataExtension implements PermissionProvider
|
|||||||
$subsiteMap
|
$subsiteMap
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
if (sizeof($subsiteMap) <= 1) {
|
if (sizeof($subsiteMap ?? []) <= 1) {
|
||||||
$fields->addFieldToTab('Root.Subsites', new ReadonlyField(
|
$fields->addFieldToTab('Root.Subsites', new ReadonlyField(
|
||||||
'SubsitesHuman',
|
'SubsitesHuman',
|
||||||
_t(__CLASS__ . '.ACCESSRADIOTITLE', 'Give this group access to'),
|
_t(__CLASS__ . '.ACCESSRADIOTITLE', 'Give this group access to'),
|
||||||
@ -133,10 +133,10 @@ class GroupSubsites extends DataExtension implements PermissionProvider
|
|||||||
{
|
{
|
||||||
if ($this->owner->AccessAllSubsites) {
|
if ($this->owner->AccessAllSubsites) {
|
||||||
$title = _t(__CLASS__ . '.GlobalGroup', 'global group');
|
$title = _t(__CLASS__ . '.GlobalGroup', 'global group');
|
||||||
$title = htmlspecialchars($this->owner->Title, ENT_QUOTES) . ' <i>(' . $title . ')</i>';
|
$title = htmlspecialchars($this->owner->Title ?? '', ENT_QUOTES) . ' <i>(' . $title . ')</i>';
|
||||||
} else {
|
} else {
|
||||||
$subsites = Convert::raw2xml(implode(', ', $this->owner->Subsites()->column('Title')));
|
$subsites = Convert::raw2xml(implode(', ', $this->owner->Subsites()->column('Title')));
|
||||||
$title = htmlspecialchars($this->owner->Title) . " <i>($subsites)</i>";
|
$title = htmlspecialchars($this->owner->Title ?? '') . " <i>($subsites)</i>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,10 +168,10 @@ class GroupSubsites extends DataExtension implements PermissionProvider
|
|||||||
$hasGroupSubsites = false;
|
$hasGroupSubsites = false;
|
||||||
foreach ($query->getFrom() as $item) {
|
foreach ($query->getFrom() as $item) {
|
||||||
if ((is_array($item) && strpos(
|
if ((is_array($item) && strpos(
|
||||||
$item['table'],
|
$item['table'] ?? '',
|
||||||
'Group_Subsites'
|
'Group_Subsites'
|
||||||
) !== false) || (!is_array($item) && strpos(
|
) !== false) || (!is_array($item) && strpos(
|
||||||
$item,
|
$item ?? '',
|
||||||
'Group_Subsites'
|
'Group_Subsites'
|
||||||
) !== false)
|
) !== false)
|
||||||
) {
|
) {
|
||||||
@ -227,7 +227,7 @@ class GroupSubsites extends DataExtension implements PermissionProvider
|
|||||||
|
|
||||||
// We are allowed to access this site if at we have CMS_ACCESS_SecurityAdmin permission on
|
// We are allowed to access this site if at we have CMS_ACCESS_SecurityAdmin permission on
|
||||||
// at least one of the sites
|
// at least one of the sites
|
||||||
return (bool)array_intersect($accessibleSites, $linkedSites);
|
return (bool)array_intersect($accessibleSites ?? [], $linkedSites);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function providePermissions()
|
public function providePermissions()
|
||||||
|
@ -118,7 +118,7 @@ class LeftAndMainSubsites extends LeftAndMainExtension
|
|||||||
// Find sites that satisfy all codes conjuncitvely.
|
// Find sites that satisfy all codes conjuncitvely.
|
||||||
$accessibleSites = new ArrayList();
|
$accessibleSites = new ArrayList();
|
||||||
foreach ($codesPerSite as $siteID => $siteCodes) {
|
foreach ($codesPerSite as $siteID => $siteCodes) {
|
||||||
if (count($siteCodes) == count($codes)) {
|
if (count($siteCodes ?? []) == count($codes ?? [])) {
|
||||||
$accessibleSites->push($sitesArray[$siteID]);
|
$accessibleSites->push($sitesArray[$siteID]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ class LeftAndMainSubsites extends LeftAndMainExtension
|
|||||||
|
|
||||||
public function alternateMenuDisplayCheck($controllerName)
|
public function alternateMenuDisplayCheck($controllerName)
|
||||||
{
|
{
|
||||||
if (!class_exists($controllerName)) {
|
if (!class_exists($controllerName ?? '')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ class LeftAndMainSubsites extends LeftAndMainExtension
|
|||||||
if ($record->hasMethod('NormalRelated') && ($record->NormalRelated() || $record->ReverseRelated())) {
|
if ($record->hasMethod('NormalRelated') && ($record->NormalRelated() || $record->ReverseRelated())) {
|
||||||
$this->owner->response->addHeader(
|
$this->owner->response->addHeader(
|
||||||
'X-Status',
|
'X-Status',
|
||||||
rawurlencode(_t(__CLASS__ . '.Saved', 'Saved, please update related pages.'))
|
rawurlencode(_t(__CLASS__ . '.Saved', 'Saved, please update related pages.') ?? '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ class SiteConfigSubsites extends DataExtension
|
|||||||
}
|
}
|
||||||
$regexp = '/^(.*\.)?("|`)?SubsiteID("|`)?\s?=/';
|
$regexp = '/^(.*\.)?("|`)?SubsiteID("|`)?\s?=/';
|
||||||
foreach ($query->getWhereParameterised($parameters) as $predicate) {
|
foreach ($query->getWhereParameterised($parameters) as $predicate) {
|
||||||
if (preg_match($regexp, $predicate)) {
|
if (preg_match($regexp ?? '', $predicate ?? '')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ class SiteConfigSubsites extends DataExtension
|
|||||||
}
|
}
|
||||||
|
|
||||||
$froms = $query->getFrom();
|
$froms = $query->getFrom();
|
||||||
$froms = array_keys($froms);
|
$froms = array_keys($froms ?? []);
|
||||||
$tableName = array_shift($froms);
|
$tableName = array_shift($froms);
|
||||||
if ($tableName !== SiteConfig::getSchema()->tableName(SiteConfig::class)) {
|
if ($tableName !== SiteConfig::getSchema()->tableName(SiteConfig::class)) {
|
||||||
return;
|
return;
|
||||||
|
@ -90,7 +90,7 @@ class SiteTreeSubsites extends DataExtension
|
|||||||
foreach ($query->getFrom() as $tableName => $info) {
|
foreach ($query->getFrom() as $tableName => $info) {
|
||||||
// The tableName should be SiteTree or SiteTree_Live...
|
// The tableName should be SiteTree or SiteTree_Live...
|
||||||
$siteTreeTableName = SiteTree::getSchema()->tableName(SiteTree::class);
|
$siteTreeTableName = SiteTree::getSchema()->tableName(SiteTree::class);
|
||||||
if (strpos($tableName, $siteTreeTableName) === false) {
|
if (strpos($tableName ?? '', $siteTreeTableName ?? '') === false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
|
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
|
||||||
@ -341,7 +341,7 @@ class SiteTreeSubsites extends DataExtension
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return true if they have access to this object's site
|
// Return true if they have access to this object's site
|
||||||
if (!(in_array(0, $goodSites) || in_array($subsiteID, $goodSites))) {
|
if (!(in_array(0, $goodSites ?? []) || in_array($subsiteID, $goodSites ?? []))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,7 +413,7 @@ class SiteTreeSubsites extends DataExtension
|
|||||||
// This helps deal with Link() returning an absolute URL.
|
// This helps deal with Link() returning an absolute URL.
|
||||||
$url = Director::absoluteURL($this->owner->Link($action));
|
$url = Director::absoluteURL($this->owner->Link($action));
|
||||||
if ($this->owner->SubsiteID) {
|
if ($this->owner->SubsiteID) {
|
||||||
$url = preg_replace('/\/\/[^\/]+\//', '//' . $this->owner->Subsite()->domain() . '/', $url);
|
$url = preg_replace('/\/\/[^\/]+\//', '//' . $this->owner->Subsite()->domain() . '/', $url ?? '');
|
||||||
}
|
}
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
@ -471,11 +471,13 @@ class SiteTreeSubsites extends DataExtension
|
|||||||
|
|
||||||
if ($links) {
|
if ($links) {
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
if (substr($link, 0, strlen('http://')) == 'http://') {
|
if (substr($link ?? '', 0, strlen('http://')) == 'http://') {
|
||||||
$withoutHttp = substr($link, strlen('http://'));
|
$withoutHttp = substr($link ?? '', strlen('http://'));
|
||||||
if (strpos($withoutHttp, '/') && strpos($withoutHttp, '/') < strlen($withoutHttp)) {
|
if (strpos($withoutHttp ?? '', '/') &&
|
||||||
$domain = substr($withoutHttp, 0, strpos($withoutHttp, '/'));
|
strpos($withoutHttp ?? '', '/') < strlen($withoutHttp ?? '')
|
||||||
$rest = substr($withoutHttp, strpos($withoutHttp, '/') + 1);
|
) {
|
||||||
|
$domain = substr($withoutHttp ?? '', 0, strpos($withoutHttp ?? '', '/'));
|
||||||
|
$rest = substr($withoutHttp ?? '', strpos($withoutHttp ?? '', '/') + 1);
|
||||||
|
|
||||||
$subsiteID = Subsite::getSubsiteIDForDomain($domain);
|
$subsiteID = Subsite::getSubsiteIDForDomain($domain);
|
||||||
if ($subsiteID == 0) {
|
if ($subsiteID == 0) {
|
||||||
@ -548,9 +550,9 @@ class SiteTreeSubsites extends DataExtension
|
|||||||
$subsite = Subsite::currentSubsite();
|
$subsite = Subsite::currentSubsite();
|
||||||
if ($subsite && $subsite->exists() && $subsite->PageTypeBlacklist) {
|
if ($subsite && $subsite->exists() && $subsite->PageTypeBlacklist) {
|
||||||
// SS 4.1: JSON encoded. SS 4.0, comma delimited
|
// SS 4.1: JSON encoded. SS 4.0, comma delimited
|
||||||
$blacklist = json_decode($subsite->PageTypeBlacklist, true);
|
$blacklist = json_decode($subsite->PageTypeBlacklist ?? '', true);
|
||||||
if ($blacklist === false) {
|
if ($blacklist === false) {
|
||||||
$blacklist = explode(',', $subsite->PageTypeBlacklist);
|
$blacklist = explode(',', $subsite->PageTypeBlacklist ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array(get_class($this->owner), (array) $blacklist)) {
|
if (in_array(get_class($this->owner), (array) $blacklist)) {
|
||||||
|
@ -36,7 +36,7 @@ class WildcardDomainField extends TextField
|
|||||||
*/
|
*/
|
||||||
public function checkHostname($hostname)
|
public function checkHostname($hostname)
|
||||||
{
|
{
|
||||||
return (bool)preg_match('/^([a-z0-9\*]+[\-\.\:])*([a-z0-9\*]+)$/', $hostname);
|
return (bool)preg_match('/^([a-z0-9\*]+[\-\.\:])*([a-z0-9\*]+)$/', $hostname ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Type()
|
public function Type()
|
||||||
|
@ -69,9 +69,9 @@ class InitStateMiddleware implements HTTPMiddleware
|
|||||||
{
|
{
|
||||||
$adminPaths = static::config()->get('admin_url_paths');
|
$adminPaths = static::config()->get('admin_url_paths');
|
||||||
$adminPaths[] = AdminRootController::admin_url();
|
$adminPaths[] = AdminRootController::admin_url();
|
||||||
$currentPath = rtrim($request->getURL(), '/') . '/';
|
$currentPath = rtrim($request->getURL() ?? '', '/') . '/';
|
||||||
foreach ($adminPaths as $adminPath) {
|
foreach ($adminPaths as $adminPath) {
|
||||||
if (substr($currentPath, 0, strlen($adminPath)) === $adminPath) {
|
if (substr($currentPath ?? '', 0, strlen($adminPath ?? '')) === $adminPath) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,14 +259,14 @@ class Subsite extends DataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove ports, we aren't concerned with them in terms of detecting subsites via domains
|
// Remove ports, we aren't concerned with them in terms of detecting subsites via domains
|
||||||
$hostParts = explode(':', $host, 2);
|
$hostParts = explode(':', $host ?? '', 2);
|
||||||
$host = reset($hostParts);
|
$host = reset($hostParts);
|
||||||
|
|
||||||
$matchingDomains = null;
|
$matchingDomains = null;
|
||||||
$cacheKey = null;
|
$cacheKey = null;
|
||||||
if ($host) {
|
if ($host) {
|
||||||
if (!static::config()->get('strict_subdomain_matching')) {
|
if (!static::config()->get('strict_subdomain_matching')) {
|
||||||
$host = preg_replace('/^www\./', '', $host);
|
$host = preg_replace('/^www\./', '', $host ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentUserId = Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0;
|
$currentUserId = Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0;
|
||||||
@ -301,9 +301,9 @@ class Subsite extends DataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($matchingDomains && $matchingDomains->count()) {
|
if ($matchingDomains && $matchingDomains->count()) {
|
||||||
$subsiteIDs = array_unique($matchingDomains->column('SubsiteID'));
|
$subsiteIDs = array_unique($matchingDomains->column('SubsiteID') ?? []);
|
||||||
$subsiteDomains = array_unique($matchingDomains->column('Domain'));
|
$subsiteDomains = array_unique($matchingDomains->column('Domain') ?? []);
|
||||||
if (sizeof($subsiteIDs) > 1) {
|
if (sizeof($subsiteIDs ?? []) > 1) {
|
||||||
throw new UnexpectedValueException(sprintf(
|
throw new UnexpectedValueException(sprintf(
|
||||||
"Multiple subsites match on '%s': %s",
|
"Multiple subsites match on '%s': %s",
|
||||||
$host,
|
$host,
|
||||||
@ -577,7 +577,7 @@ class Subsite extends DataObject
|
|||||||
foreach ($domains as $domain) {
|
foreach ($domains as $domain) {
|
||||||
$domainStr = $domain->Domain;
|
$domainStr = $domain->Domain;
|
||||||
if (!static::config()->get('strict_subdomain_matching')) {
|
if (!static::config()->get('strict_subdomain_matching')) {
|
||||||
$domainStr = preg_replace('/^www\./', '', $domainStr);
|
$domainStr = preg_replace('/^www\./', '', $domainStr ?? '');
|
||||||
}
|
}
|
||||||
$hostmap[$domainStr] = $subsite->domain();
|
$hostmap[$domainStr] = $subsite->domain();
|
||||||
}
|
}
|
||||||
@ -592,8 +592,8 @@ class Subsite extends DataObject
|
|||||||
$data .= "// Generated by Subsite::writeHostMap() on " . date('d/M/y') . "\n";
|
$data .= "// Generated by Subsite::writeHostMap() on " . date('d/M/y') . "\n";
|
||||||
$data .= '$subsiteHostmap = ' . var_export($hostmap, true) . ';';
|
$data .= '$subsiteHostmap = ' . var_export($hostmap, true) . ';';
|
||||||
|
|
||||||
if (is_writable(dirname($file)) || is_writable($file)) {
|
if (is_writable(dirname($file ?? '')) || is_writable($file ?? '')) {
|
||||||
file_put_contents($file, $data);
|
file_put_contents($file ?? '', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +624,7 @@ class Subsite extends DataObject
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('ADMIN', $permissionCodes)) {
|
if (!in_array('ADMIN', $permissionCodes ?? [])) {
|
||||||
$permissionCodes[] = 'ADMIN';
|
$permissionCodes[] = 'ADMIN';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -799,7 +799,7 @@ class Subsite extends DataObject
|
|||||||
if ($theme[0] == '.') {
|
if ($theme[0] == '.') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$theme = strtok($theme, '_');
|
$theme = strtok($theme ?? '', '_');
|
||||||
$themes[$theme] = $theme;
|
$themes[$theme] = $theme;
|
||||||
}
|
}
|
||||||
ksort($themes);
|
ksort($themes);
|
||||||
@ -989,7 +989,7 @@ JS;
|
|||||||
* when a page, etc, is duplicated
|
* when a page, etc, is duplicated
|
||||||
*/
|
*/
|
||||||
$stack = [[0, 0]];
|
$stack = [[0, 0]];
|
||||||
while (count($stack) > 0) {
|
while (count($stack ?? []) > 0) {
|
||||||
list($sourceParentID, $destParentID) = array_pop($stack);
|
list($sourceParentID, $destParentID) = array_pop($stack);
|
||||||
$children = Versioned::get_by_stage('Page', 'Live', "\"ParentID\" = $sourceParentID", '');
|
$children = Versioned::get_by_stage('Page', 'Live', "\"ParentID\" = $sourceParentID", '');
|
||||||
|
|
||||||
|
@ -190,14 +190,14 @@ class SubsiteDomain extends DataObject
|
|||||||
|
|
||||||
// If there are wildcards in the primary domain (not recommended), make some
|
// If there are wildcards in the primary domain (not recommended), make some
|
||||||
// educated guesses about what to replace them with:
|
// educated guesses about what to replace them with:
|
||||||
$domain = preg_replace('/\.\*$/', ".{$currentHost}", $this->Domain);
|
$domain = preg_replace('/\.\*$/', ".{$currentHost}", $this->Domain ?? '');
|
||||||
|
|
||||||
// Default to "subsite." prefix for first wildcard
|
// Default to "subsite." prefix for first wildcard
|
||||||
// TODO Whats the significance of "subsite" in this context?!
|
// TODO Whats the significance of "subsite" in this context?!
|
||||||
$domain = preg_replace('/^\*\./', "subsite.", $domain);
|
$domain = preg_replace('/^\*\./', "subsite.", $domain ?? '');
|
||||||
|
|
||||||
// *Only* removes "intermediate" subdomains, so 'subdomain.www.domain.com' becomes 'subdomain.domain.com'
|
// *Only* removes "intermediate" subdomains, so 'subdomain.www.domain.com' becomes 'subdomain.domain.com'
|
||||||
$domain = str_replace('.www.', '.', $domain);
|
$domain = str_replace('.www.', '.', $domain ?? '');
|
||||||
|
|
||||||
return $domain;
|
return $domain;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ class SubsitesVirtualPage extends VirtualPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (self::$db as $field => $type) {
|
foreach (self::$db as $field => $type) {
|
||||||
if (in_array($field, $fields)) {
|
if (in_array($field, $fields ?? [])) {
|
||||||
unset($fields[array_search($field, $fields)]);
|
unset($fields[array_search($field, $fields)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ class SubsiteReportWrapper extends ReportWrapper
|
|||||||
_t(__CLASS__ . '.ReportDropdown', 'Sites'),
|
_t(__CLASS__ . '.ReportDropdown', 'Sites'),
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
$subsiteField->setValue(array_keys($options));
|
$subsiteField->setValue(array_keys($options ?? []));
|
||||||
|
|
||||||
// We don't need to make the field editable if only one subsite is available
|
// We don't need to make the field editable if only one subsite is available
|
||||||
if (sizeof($options) <= 1) {
|
if (sizeof($options ?? []) <= 1) {
|
||||||
$subsiteField = $subsiteField->performReadonlyTransformation();
|
$subsiteField = $subsiteField->performReadonlyTransformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class SubsiteReportWrapper extends ReportWrapper
|
|||||||
} else {
|
} else {
|
||||||
$subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain');
|
$subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain');
|
||||||
$options = $subsites->toDropdownMap('ID', 'Title');
|
$options = $subsites->toDropdownMap('ID', 'Title');
|
||||||
Subsite::$force_subsite = join(',', array_keys($options));
|
Subsite::$force_subsite = join(',', array_keys($options ?? []));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class ThemeResolver
|
|||||||
*/
|
*/
|
||||||
public function getThemeList(Subsite $site)
|
public function getThemeList(Subsite $site)
|
||||||
{
|
{
|
||||||
$themes = array_values(SSViewer::get_themes());
|
$themes = array_values(SSViewer::get_themes() ?? []);
|
||||||
$siteTheme = $site->Theme;
|
$siteTheme = $site->Theme;
|
||||||
|
|
||||||
if (!$siteTheme) {
|
if (!$siteTheme) {
|
||||||
@ -56,18 +56,18 @@ class ThemeResolver
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure themes don't cascade "up" the list
|
// Ensure themes don't cascade "up" the list
|
||||||
$index = array_search($siteTheme, $themes);
|
$index = array_search($siteTheme, $themes ?? []);
|
||||||
|
|
||||||
if ($index > 0) {
|
if ($index > 0) {
|
||||||
// 4.0 didn't have support for themes in the public webroot
|
// 4.0 didn't have support for themes in the public webroot
|
||||||
$constant = SSViewer::class . '::PUBLIC_THEME';
|
$constant = SSViewer::class . '::PUBLIC_THEME';
|
||||||
$publicConstantDefined = defined($constant);
|
$publicConstantDefined = defined($constant ?? '');
|
||||||
|
|
||||||
// Check if the default is public themes
|
// Check if the default is public themes
|
||||||
$publicDefault = $publicConstantDefined && $themes[0] === SSViewer::PUBLIC_THEME;
|
$publicDefault = $publicConstantDefined && $themes[0] === SSViewer::PUBLIC_THEME;
|
||||||
|
|
||||||
// Take only those that appear after theme chosen (non-inclusive)
|
// Take only those that appear after theme chosen (non-inclusive)
|
||||||
$themes = array_slice($themes, $index + 1);
|
$themes = array_slice($themes ?? [], $index + 1);
|
||||||
|
|
||||||
// Add back in public
|
// Add back in public
|
||||||
if ($publicDefault) {
|
if ($publicDefault) {
|
||||||
@ -94,6 +94,6 @@ class ThemeResolver
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_keys($config);
|
return array_keys($config ?? []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class SubsiteCopyPagesTask extends BuildTask
|
|||||||
// issues with having to check whether or not the new parents have been added to the site tree
|
// issues with having to check whether or not the new parents have been added to the site tree
|
||||||
// when a page, etc, is duplicated
|
// when a page, etc, is duplicated
|
||||||
$stack = [[0, 0]];
|
$stack = [[0, 0]];
|
||||||
while (count($stack) > 0) {
|
while (count($stack ?? []) > 0) {
|
||||||
list($sourceParentID, $destParentID) = array_pop($stack);
|
list($sourceParentID, $destParentID) = array_pop($stack);
|
||||||
|
|
||||||
$children = Versioned::get_by_stage(SiteTree::class, 'Live', "\"ParentID\" = $sourceParentID", '');
|
$children = Versioned::get_by_stage(SiteTree::class, 'Live', "\"ParentID\" = $sourceParentID", '');
|
||||||
|
@ -24,8 +24,8 @@ class FolderFormFactoryExtensionTest extends SapphireTest
|
|||||||
'Record' => $folder
|
'Record' => $folder
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$source = array_values($folderForm->Fields()->fieldByName('SubsiteID')->getSource());
|
$source = array_values($folderForm->Fields()->fieldByName('SubsiteID')->getSource() ?? []);
|
||||||
$result = array_values($source);
|
$result = array_values($source ?? []);
|
||||||
|
|
||||||
$this->assertContains('Main site', $result);
|
$this->assertContains('Main site', $result);
|
||||||
$this->assertContains('Subsite A', $result);
|
$this->assertContains('Subsite A', $result);
|
||||||
|
@ -274,7 +274,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
|||||||
|
|
||||||
Subsite::changeSubsite($s1);
|
Subsite::changeSubsite($s1);
|
||||||
$cmsmain = CMSMain::create();
|
$cmsmain = CMSMain::create();
|
||||||
$hints = json_decode($cmsmain->SiteTreeHints(), true);
|
$hints = json_decode($cmsmain->SiteTreeHints() ?? '', true);
|
||||||
$classes = $hints['Root']['disallowedChildren'];
|
$classes = $hints['Root']['disallowedChildren'];
|
||||||
$this->assertContains(ErrorPage::class, $classes);
|
$this->assertContains(ErrorPage::class, $classes);
|
||||||
$this->assertContains(TestClassA::class, $classes);
|
$this->assertContains(TestClassA::class, $classes);
|
||||||
@ -285,7 +285,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
|||||||
if ($cmsmain->hasMethod('getHintsCache')) {
|
if ($cmsmain->hasMethod('getHintsCache')) {
|
||||||
$cmsmain->getHintsCache()->clear();
|
$cmsmain->getHintsCache()->clear();
|
||||||
}
|
}
|
||||||
$hints = json_decode($cmsmain->SiteTreeHints(), true);
|
$hints = json_decode($cmsmain->SiteTreeHints() ?? '', true);
|
||||||
|
|
||||||
$classes = $hints['Root']['disallowedChildren'];
|
$classes = $hints['Root']['disallowedChildren'];
|
||||||
$this->assertNotContains(ErrorPage::class, $classes);
|
$this->assertNotContains(ErrorPage::class, $classes);
|
||||||
|
@ -33,10 +33,10 @@ class SubsiteAdminTest extends FunctionalTest
|
|||||||
."SilverStripe-Subsites-Model-Subsite/item/$subsite1ID/edit"
|
."SilverStripe-Subsites-Model-Subsite/item/$subsite1ID/edit"
|
||||||
);
|
);
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
strpos($response->getBody(), 'id="Form_ItemEditForm_ID"') !== false,
|
strpos($response->getBody() ?? '', 'id="Form_ItemEditForm_ID"') !== false,
|
||||||
'Testing Form_ItemEditForm_ID exists'
|
'Testing Form_ItemEditForm_ID exists'
|
||||||
);
|
);
|
||||||
$this->assertTrue(strpos($response->getBody(), '<head') !== false, 'Testing <head> exists');
|
$this->assertTrue(strpos($response->getBody() ?? '', '<head') !== false, 'Testing <head> exists');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -407,7 +407,7 @@ class SubsiteTest extends BaseSubsiteTest
|
|||||||
'Test Non-SSL',
|
'Test Non-SSL',
|
||||||
'Test SSL',
|
'Test SSL',
|
||||||
'Test Vagrant VM on port 8080'
|
'Test Vagrant VM on port 8080'
|
||||||
], array_values($adminSiteTitles));
|
], array_values($adminSiteTitles ?? []));
|
||||||
|
|
||||||
$member2Sites = Subsite::accessible_sites(
|
$member2Sites = Subsite::accessible_sites(
|
||||||
'CMS_ACCESS_CMSMain',
|
'CMS_ACCESS_CMSMain',
|
||||||
|
@ -35,8 +35,8 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest
|
|||||||
$page = $this->objFromFixture(SiteTree::class, 'page1');
|
$page = $this->objFromFixture(SiteTree::class, 'page1');
|
||||||
$fromPath = __DIR__ . '/testscript-test-file.pdf';
|
$fromPath = __DIR__ . '/testscript-test-file.pdf';
|
||||||
$destPath = TestAssetStore::getLocalPath($file);
|
$destPath = TestAssetStore::getLocalPath($file);
|
||||||
Filesystem::makeFolder(dirname($destPath));
|
Filesystem::makeFolder(dirname($destPath ?? ''));
|
||||||
copy($fromPath, $destPath);
|
copy($fromPath ?? '', $destPath ?? '');
|
||||||
|
|
||||||
// Hack in site link tracking after the fact
|
// Hack in site link tracking after the fact
|
||||||
$page->Content = '<p><img src="' . $file->getURL() . '" data-fileid="' . $file->ID . '" /></p>';
|
$page->Content = '<p><img src="' . $file->getURL() . '" data-fileid="' . $file->ID . '" /></p>';
|
||||||
|
Loading…
Reference in New Issue
Block a user