mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
MINOR Added caching to SiteTree->getStatusFlags(), as its called twice for every node now in LeftAndMain->SiteTreeAsUL() (see #7410)
This commit is contained in:
parent
bc2fb3c900
commit
e50936fe9f
@ -201,6 +201,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
protected static $enforce_strict_hierarchy = true;
|
protected static $enforce_strict_hierarchy = true;
|
||||||
|
|
||||||
|
protected $_cache_statusFlags = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the system should avoid orphaned pages
|
* Determines if the system should avoid orphaned pages
|
||||||
* by deleting all children when the their parent is deleted (TRUE),
|
* by deleting all children when the their parent is deleted (TRUE),
|
||||||
@ -1494,6 +1496,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
parent::onAfterDelete();
|
parent::onAfterDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function flushCache($persistent = true) {
|
||||||
|
parent::flushCache($persistent);
|
||||||
|
$this->_cache_statusFlags = null;
|
||||||
|
}
|
||||||
|
|
||||||
function validate() {
|
function validate() {
|
||||||
$result = parent::validate();
|
$result = parent::validate();
|
||||||
|
|
||||||
@ -2470,9 +2477,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* Example (with optional title attribute):
|
* Example (with optional title attribute):
|
||||||
* "deletedonlive" => array('text' => "Deleted", 'title' => 'This page has been deleted')
|
* "deletedonlive" => array('text' => "Deleted", 'title' => 'This page has been deleted')
|
||||||
*
|
*
|
||||||
|
* @param Boolean $cached
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getStatusFlags() {
|
function getStatusFlags($cached = true) {
|
||||||
|
if(!$this->_cache_statusFlags || !$cached) {
|
||||||
$flags = array();
|
$flags = array();
|
||||||
if($this->IsDeletedFromStage) {
|
if($this->IsDeletedFromStage) {
|
||||||
if($this->ExistsOnLive) {
|
if($this->ExistsOnLive) {
|
||||||
@ -2500,7 +2509,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
$this->extend('updateStatusFlags', $flags);
|
$this->extend('updateStatusFlags', $flags);
|
||||||
|
|
||||||
return $flags;
|
$this->_cache_statusFlags = $flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_cache_statusFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -956,8 +956,8 @@ class SiteTreeTest_NotRoot extends Page implements TestOnly {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SiteTreeTest_StageStatusInherit extends SiteTree implements TestOnly {
|
class SiteTreeTest_StageStatusInherit extends SiteTree implements TestOnly {
|
||||||
function getStatusFlags(){
|
function getStatusFlags($cached = true){
|
||||||
$flags = parent::getStatusFlags();
|
$flags = parent::getStatusFlags($cached);
|
||||||
$flags['inherited-class'] = "InheritedTitle";
|
$flags['inherited-class'] = "InheritedTitle";
|
||||||
return $flags;
|
return $flags;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user