From c1d86da5b2098fed53ca6517617fcacd55aadf81 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Thu, 16 May 2024 11:45:12 +0200 Subject: [PATCH] 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 --- .../celerity/controller/CelerityResourceController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/applications/celerity/controller/CelerityResourceController.php b/src/applications/celerity/controller/CelerityResourceController.php index 547c881df8..1908c4583a 100644 --- a/src/applications/celerity/controller/CelerityResourceController.php +++ b/src/applications/celerity/controller/CelerityResourceController.php @@ -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); } }