Skip to content
Snippets Groups Projects
Commit ea515096 authored by Wouter Wolters's avatar Wouter Wolters Committed by Anja Leichsenring
Browse files

[TASK] Use strict type checking in TreelistCacheUpdateHooks

Resolves: #78836
Releases: master
Change-Id: Ib76c95164e228ce3a8afa448cf4a9c1ba6ddec29
Reviewed-on: https://review.typo3.org/50772


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarManuel Glauser <mail@manuelglauser.ch>
Tested-by: default avatarManuel Glauser <mail@manuelglauser.ch>
Reviewed-by: default avatarJan Helke <typo3@helke.de>
Tested-by: default avatarJan Helke <typo3@helke.de>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent f9f54aec
Branches
Tags
No related merge requests found
...@@ -71,15 +71,15 @@ class TreelistCacheUpdateHooks ...@@ -71,15 +71,15 @@ class TreelistCacheUpdateHooks
*/ */
public function processDatamap_afterDatabaseOperations($status, $table, $recordId, array $updatedFields, DataHandler $dataHandler) public function processDatamap_afterDatabaseOperations($status, $table, $recordId, array $updatedFields, DataHandler $dataHandler)
{ {
if ($table == 'pages' && $this->requiresUpdate($updatedFields)) { if ($table === 'pages' && $this->requiresUpdate($updatedFields)) {
$affectedPagePid = 0; $affectedPagePid = 0;
$affectedPageUid = 0; $affectedPageUid = 0;
if ($status == 'new') { if ($status === 'new') {
// Detect new pages // Detect new pages
// Resolve the uid // Resolve the uid
$affectedPageUid = $dataHandler->substNEWwithIDs[$recordId]; $affectedPageUid = $dataHandler->substNEWwithIDs[$recordId];
$affectedPagePid = $updatedFields['pid']; $affectedPagePid = $updatedFields['pid'];
} elseif ($status == 'update') { } elseif ($status === 'update') {
// Detect updated pages // Detect updated pages
$affectedPageUid = $recordId; $affectedPageUid = $recordId;
// When updating a page the pid is not directly available so we // When updating a page the pid is not directly available so we
...@@ -142,7 +142,7 @@ class TreelistCacheUpdateHooks ...@@ -142,7 +142,7 @@ class TreelistCacheUpdateHooks
*/ */
public function moveRecord_firstElementPostProcess($table, $recordId, $destinationPid, array $movedRecord, array $updatedFields, DataHandler $dataHandler) public function moveRecord_firstElementPostProcess($table, $recordId, $destinationPid, array $movedRecord, array $updatedFields, DataHandler $dataHandler)
{ {
if ($table == 'pages' && $this->requiresUpdate($updatedFields)) { if ($table === 'pages' && $this->requiresUpdate($updatedFields)) {
$affectedPageUid = $recordId; $affectedPageUid = $recordId;
$affectedPageOldPid = $movedRecord['pid']; $affectedPageOldPid = $movedRecord['pid'];
$affectedPageNewPid = $updatedFields['pid']; $affectedPageNewPid = $updatedFields['pid'];
...@@ -169,7 +169,7 @@ class TreelistCacheUpdateHooks ...@@ -169,7 +169,7 @@ class TreelistCacheUpdateHooks
*/ */
public function moveRecord_afterAnotherElementPostProcess($table, $recordId, $destinationPid, $originalDestinationPid, array $movedRecord, array $updatedFields, DataHandler $dataHandler) public function moveRecord_afterAnotherElementPostProcess($table, $recordId, $destinationPid, $originalDestinationPid, array $movedRecord, array $updatedFields, DataHandler $dataHandler)
{ {
if ($table == 'pages' && $this->requiresUpdate($updatedFields)) { if ($table === 'pages' && $this->requiresUpdate($updatedFields)) {
$affectedPageUid = $recordId; $affectedPageUid = $recordId;
$affectedPageOldPid = $movedRecord['pid']; $affectedPageOldPid = $movedRecord['pid'];
$affectedPageNewPid = $updatedFields['pid']; $affectedPageNewPid = $updatedFields['pid'];
...@@ -192,7 +192,7 @@ class TreelistCacheUpdateHooks ...@@ -192,7 +192,7 @@ class TreelistCacheUpdateHooks
$requiresUpdate = false; $requiresUpdate = false;
$updatedFieldNames = array_keys($updatedFields); $updatedFieldNames = array_keys($updatedFields);
foreach ($updatedFieldNames as $updatedFieldName) { foreach ($updatedFieldNames as $updatedFieldName) {
if (in_array($updatedFieldName, $this->updateRequiringFields)) { if (in_array($updatedFieldName, $this->updateRequiringFields, true)) {
$requiresUpdate = true; $requiresUpdate = true;
break; break;
} }
...@@ -201,7 +201,7 @@ class TreelistCacheUpdateHooks ...@@ -201,7 +201,7 @@ class TreelistCacheUpdateHooks
} }
/** /**
* Calls the cache maintainance functions according to the determined actions * Calls the cache maintenance functions according to the determined actions
* *
* @param int $affectedPage uid of the affected page * @param int $affectedPage uid of the affected page
* @param int $affectedParentPage parent uid of the affected page * @param int $affectedParentPage parent uid of the affected page
...@@ -230,7 +230,7 @@ class TreelistCacheUpdateHooks ...@@ -230,7 +230,7 @@ class TreelistCacheUpdateHooks
// From time to time clean the cache from expired entries // From time to time clean the cache from expired entries
// (theoretically every 1000 calls) // (theoretically every 1000 calls)
$randomNumber = rand(1, 1000); $randomNumber = rand(1, 1000);
if ($randomNumber == 500) { if ($randomNumber === 500) {
$this->removeExpiredCacheEntries(); $this->removeExpiredCacheEntries();
} }
} }
...@@ -337,10 +337,10 @@ class TreelistCacheUpdateHooks ...@@ -337,10 +337,10 @@ class TreelistCacheUpdateHooks
protected function determineClearCacheActions($status, $updatedFields) protected function determineClearCacheActions($status, $updatedFields)
{ {
$actions = []; $actions = [];
if ($status == 'new') { if ($status === 'new') {
// New page // New page
$actions['allParents'] = true; $actions['allParents'] = true;
} elseif ($status == 'update') { } elseif ($status === 'update') {
$updatedFieldNames = array_keys($updatedFields); $updatedFieldNames = array_keys($updatedFields);
foreach ($updatedFieldNames as $updatedFieldName) { foreach ($updatedFieldNames as $updatedFieldName) {
switch ($updatedFieldName) { switch ($updatedFieldName) {
...@@ -375,7 +375,7 @@ class TreelistCacheUpdateHooks ...@@ -375,7 +375,7 @@ class TreelistCacheUpdateHooks
} }
break; break;
default: default:
if (in_array($updatedFieldName, $this->updateRequiringFields)) { if (in_array($updatedFieldName, $this->updateRequiringFields, true)) {
$actions['uidInTreelist'] = true; $actions['uidInTreelist'] = true;
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment