@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | self::$_can_cache_content_string = ''; |
29 | 29 | if ($this->owner->hasMethod('canCachePage')) { |
30 | 30 | self::$_can_cache_content_string = $this->owner->canCachePage() ? '' : 'can-no-cache-' . $this->owner->ID; |
31 | - if (! $this->canCacheCheck()) { |
|
31 | + if (!$this->canCacheCheck()) { |
|
32 | 32 | return false; |
33 | 33 | } |
34 | 34 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $action = $this->owner->request->param('Action'); |
38 | 38 | if ($action) { |
39 | 39 | self::$_can_cache_content_string .= $action; |
40 | - if (! $this->canCacheCheck()) { |
|
40 | + if (!$this->canCacheCheck()) { |
|
41 | 41 | return false; |
42 | 42 | } |
43 | 43 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | // id |
47 | 47 | if ($id) { |
48 | 48 | self::$_can_cache_content_string .= $id; |
49 | - if (! $this->canCacheCheck()) { |
|
49 | + if (!$this->canCacheCheck()) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | self::$_can_cache_content_string .= $item; |
62 | 62 | } |
63 | 63 | |
64 | - if (! $this->canCacheCheck()) { |
|
64 | + if (!$this->canCacheCheck()) { |
|
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $member = Security::getCurrentUser(); |
72 | 72 | if ($member && $member->exists()) { |
73 | 73 | self::$_can_cache_content_string .= $member->ID; |
74 | - if (! $this->canCacheCheck()) { |
|
74 | + if (!$this->canCacheCheck()) { |
|
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | public function CacheKeyGenerator($letter, $includePageId = true): string |
132 | 132 | { |
133 | 133 | if ($this->HasCacheKeys()) { |
134 | - $string = $letter . '_' .$this->cacheKeyAnyDataObjectChanges(); |
|
134 | + $string = $letter . '_' . $this->cacheKeyAnyDataObjectChanges(); |
|
135 | 135 | |
136 | 136 | if ($includePageId) { |
137 | 137 | $string .= '_ID_' . $this->owner->ID; |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | public function getClassNameTitle() : string |
64 | 64 | { |
65 | - if(class_exists($this->getOwner()->ClassNameLastEdited)) { |
|
65 | + if (class_exists($this->getOwner()->ClassNameLastEdited)) { |
|
66 | 66 | return Injector::inst()->get($this->getOwner()->ClassNameLastEdited)->i18n_singular_name(); |
67 | 67 | } |
68 | 68 | return 'class not found'; |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | // NB. |
21 | 21 | // if the dataobject has the versioned extension then the cache should be invalidated onAfterPublish |
22 | 22 | // hasStages function is part of the Versioned class so safe to check here |
23 | - if (! $owner->hasExtension(Versioned::class)) { |
|
23 | + if (!$owner->hasExtension(Versioned::class)) { |
|
24 | 24 | $this->doUpdateCache($className); |
25 | - } elseif (! $owner->hasStages()) { |
|
25 | + } elseif (!$owner->hasStages()) { |
|
26 | 26 | $this->doUpdateCache($className); |
27 | 27 | } |
28 | 28 | } |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | private function canUpdateCache($className): bool |
90 | 90 | { |
91 | 91 | // we want to always avoid this to avoid a loop. |
92 | - if($className === ObjectsUpdated::class) { |
|
92 | + if ($className === ObjectsUpdated::class) { |
|
93 | 93 | return false; |
94 | 94 | } |
95 | 95 | $excludedClasses = (array) Config::inst()->get(self::class, 'excluded_classes_for_caching'); |
96 | 96 | |
97 | - return ! in_array($className, $excludedClasses, true); |
|
97 | + return !in_array($className, $excludedClasses, true); |
|
98 | 98 | } |
99 | 99 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function updateCMSFields(FieldList $fields) |
33 | 33 | { |
34 | 34 | $name = ''; |
35 | - if(class_exists($this->getOwner()->ClassNameLastEdited)) { |
|
35 | + if (class_exists($this->getOwner()->ClassNameLastEdited)) { |
|
36 | 36 | $name = Injector::inst()->get($this->getOwner()->ClassNameLastEdited)->i18n_singular_name(); |
37 | 37 | } |
38 | 38 | $fields->addFieldsToTab( |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | ReadonlyField::create('CacheKeyLastEdited', 'Content Last Edited') |
45 | 45 | ->setRightTitle('The frontend template cache will be invalidated every time this value changes. It changes every time anything is changed in the database.'), |
46 | 46 | ReadonlyField::create('ClassNameLastEdited', 'Last class updated') |
47 | - ->setRightTitle('Last object updated. The name of this object is: '.$name), |
|
47 | + ->setRightTitle('Last object updated. The name of this object is: ' . $name), |
|
48 | 48 | ] |
49 | 49 | ); |
50 | - if($this->getOwner()->RecordCacheUpdates) { |
|
50 | + if ($this->getOwner()->RecordCacheUpdates) { |
|
51 | 51 | $fields->addFieldsToTab( |
52 | 52 | 'Root.Caching', |
53 | 53 | [ |
54 | 54 | GridField::create( |
55 | 55 | 'ObjectsUpdated', |
56 | - 'Last '.self::MAX_OBJECTS_UPDATED.' objects updated', |
|
56 | + 'Last ' . self::MAX_OBJECTS_UPDATED . ' objects updated', |
|
57 | 57 | ObjectsUpdated::get()->limit(self::MAX_OBJECTS_UPDATED), |
58 | 58 | GridFieldConfig_RecordViewer::create() |
59 | 59 | ) |
@@ -65,31 +65,31 @@ discard block |
||
65 | 65 | public static function site_cache_key(): string |
66 | 66 | { |
67 | 67 | $obj = SiteConfig::current_site_config(); |
68 | - if($obj->HasCaching) { |
|
69 | - return (string) 'ts_'.strtotime($obj->CacheKeyLastEdited); |
|
68 | + if ($obj->HasCaching) { |
|
69 | + return (string) 'ts_' . strtotime($obj->CacheKeyLastEdited); |
|
70 | 70 | } else { |
71 | - return (string) 'ts_'.time(); |
|
71 | + return (string) 'ts_' . time(); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | 75 | public static function update_cache_key(?string $className = '') |
76 | 76 | { |
77 | 77 | $obj = SiteConfig::current_site_config(); |
78 | - if($obj->HasCaching) { |
|
78 | + if ($obj->HasCaching) { |
|
79 | 79 | DB::query(' |
80 | 80 | UPDATE "SiteConfig" |
81 | 81 | SET |
82 | 82 | "CacheKeyLastEdited" = \'' . DBDatetime::now()->Rfc2822() . '\', |
83 | - "ClassNameLastEdited" = \'' . addslashes((string) $className). '\' |
|
84 | - WHERE ID = '.$obj->ID.' |
|
83 | + "ClassNameLastEdited" = \'' . addslashes((string) $className) . '\' |
|
84 | + WHERE ID = '.$obj->ID . ' |
|
85 | 85 | LIMIT 1 |
86 | 86 | ;'); |
87 | 87 | } |
88 | - if($obj->RecordCacheUpdates) { |
|
88 | + if ($obj->RecordCacheUpdates) { |
|
89 | 89 | $recordId = Injector::inst() |
90 | - ->create(ObjectsUpdated::class, ['ClassNameLastEdited' => $className]) |
|
90 | + ->create(ObjectsUpdated::class, [ 'ClassNameLastEdited' => $className ]) |
|
91 | 91 | ->write(); |
92 | - DB::query('DELETE FROM ObjectsUpdated WHERE ID < '.(Int) ($recordId - self::MAX_OBJECTS_UPDATED)); |
|
92 | + DB::query('DELETE FROM ObjectsUpdated WHERE ID < ' . (Int) ($recordId - self::MAX_OBJECTS_UPDATED)); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | } |