Page MenuHomePhorge

Initialize $cache_key variable in CelerityResourceController.php
ClosedPublic

Authored by aklapper on May 16 2024, 09:46.

Details

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.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

src/applications/celerity/controller/CelerityResourceController.php
102

And, maybe this line

I felt it's not necessarily needed but it cannot hurt either. :)

Thanks. Moreover, looking at PhutilKeyValueCache it seems that setKey(null) has no sense. So thanks also for that extra care you already set.

This revision is now accepted and ready to land.Jun 11 2024, 10:57