Skip to content

Commit 5fbec5a

Browse files
Prevent dashboard cache collisions (#15018)
* Prevent dashboard cache collisions * Remove server cache
1 parent 396317a commit 5fbec5a

File tree

2 files changed

+0
-36
lines changed

2 files changed

+0
-36
lines changed

src/Dashboard/Dashboard.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ public function save(bool $skip_child = false)
215215
if (!$skip_child && count($this->rights) > 0) {
216216
$this->saveRights($this->rights);
217217
}
218-
219-
// invalidate dashboard cache
220-
$cache_key = "dashboard_card_" . $this->key;
221-
$GLPI_CACHE->delete($cache_key);
222218
}
223219

224220

src/Dashboard/Grid.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,6 @@ public function getCards()
150150
<i class="fas fa-spinner fa-spin fa-3x"></i>
151151
</div>
152152
HTML;
153-
// manage cache
154-
$dashboard_key = $this->current;
155-
$footprint = sha1(serialize($card_options) .
156-
($_SESSION['glpiactiveentities_string'] ?? "") .
157-
($_SESSION['glpilanguage']));
158-
$cache_key = "dashboard_card_{$dashboard_key}_{$footprint}";
159-
$card_options['cache_key'] = $cache_key;
160-
161153
$this->addGridItem(
162154
$card_html,
163155
$gridstack_id,
@@ -916,20 +908,9 @@ public function getCardHtml(string $card_id = "", array $card_options = []): str
916908
}
917909
$card = $cards[$card_id];
918910

919-
// allows plugins to control uniqueness of its cards in cache system
920-
if (isset($card['custom_hash'])) {
921-
$card_options['custom_hash'] = $card['custom_hash'];
922-
}
923-
924-
// manage cache
925-
$options_footprint = sha1(serialize($card_options) .
926-
($_SESSION['glpiactiveentities_string'] ?? "") .
927-
($_SESSION['glpilanguage']));
928-
929911
$use_cache = !$force
930912
&& $_SESSION['glpi_use_mode'] != Session::DEBUG_MODE
931913
&& (!isset($card['cache']) || $card['cache'] == true);
932-
$cache_key = "dashboard_card_{$dashboard}_{$options_footprint}";
933914
$cache_age = 40;
934915

935916
if ($use_cache) {
@@ -938,12 +919,6 @@ public function getCardHtml(string $card_id = "", array $card_options = []): str
938919
header('Cache-Control: public');
939920
header('Cache-Control: max-age=' . $cache_age);
940921
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + $cache_age));
941-
942-
// server cache
943-
$dashboard_cards = $GLPI_CACHE->get($cache_key, []);
944-
if (isset($dashboard_cards[$gridstack_id])) {
945-
return (string)$dashboard_cards[$gridstack_id];
946-
}
947922
}
948923

949924
$html = "";
@@ -998,13 +973,6 @@ public function getCardHtml(string $card_id = "", array $card_options = []): str
998973
}
999974

1000975
$execution_time = round(microtime(true) - $start, 3);
1001-
1002-
// store server cache
1003-
if (strlen($dashboard)) {
1004-
$dashboard_cards = $GLPI_CACHE->get($cache_key, []);
1005-
$dashboard_cards[$gridstack_id] = $html;
1006-
$GLPI_CACHE->set($cache_key, $dashboard_cards, new \DateInterval("PT" . $cache_age . "S"));
1007-
}
1008976
} catch (\Throwable $e) {
1009977
$html = $render_error_html;
1010978
$execution_time = round(microtime(true) - $start, 3);

0 commit comments

Comments
 (0)