1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

Initialize $cache_key variable in CelerityResourceController.php

Summary:
`$cache_key` is unconditionally called in `$cache->setKey($cache_key, $data)` but is only defined if the previous condition `if ($is_cacheable && $is_locally_cacheable && !$dev_mode)` was true.
Thus initialize the variable to avoid a theoretical exception. (No additional null check is needed as `$cache` gets defined in the same condition.)

Test Plan: Carefully read the code.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25642
This commit is contained in:
Andre Klapper 2024-05-16 11:45:12 +02:00
parent 10cb252163
commit c1d86da5b2

View file

@ -59,6 +59,7 @@ abstract class CelerityResourceController extends PhabricatorController {
}
$cache = null;
$cache_key = null;
$data = null;
if ($is_cacheable && $is_locally_cacheable && !$dev_mode) {
$cache = PhabricatorCaches::getImmutableCache();
@ -98,7 +99,7 @@ abstract class CelerityResourceController extends PhabricatorController {
$data = $xformer->transformResource($path, $data);
}
if ($cache) {
if ($cache && $cache_key !== null) {
$cache->setKey($cache_key, $data);
}
}