Add missing add() method to NullEngine to prevent undefined prefix key error - #19568
Conversation
|
CI failure here is unrelated to your change. It's the rector step in the "Coding Standard & Static Analysis" job blowing up on a dependency mismatch:
On the change itself: the diagnosis is correct. Two things worth considering:
|
7004542 to
19c6231
Compare
|
You are right, better to ensure parent init is called..Added the test as well to ensure it behaves as expected. This one failed: CI / testsuite (8.2, mysql, highest) (pull_request) because of "Mysql Server has gone away"..not sure if you can re-run the job |
|
Lets see if 5.x becomes green, it should. |
When Cache::add() is called with NullEngine, it falls through to the parent CacheEngine::add() which calls $this->_key(). That method accesses $this->_config['prefix'], but NullEngine does not populate _config with defaults since it skips the standard init() setup.
This results in: "Undefined array key prefix" in CacheEngine.php
The fix adds an add() method to NullEngine that simply returns true, consistent with how set(), get(), delete(), and other methods already work in NullEngine (they all no-op and return the expected default).
Reproducible when any code calls Cache::add() on a cache config using NullEngine, for example queue workers using unique job deduplication via Cache::add().