Lemon-Framework / Lemon

🍋 A php microframework
https://lemon-framework.github.io/docs/
GNU General Public License v3.0
24 stars 8 forks source link

Cache $data property type is unfit #162

Closed harabisj closed 11 months ago

harabisj commented 11 months ago

src/Lemon/Cache/Cache.php line 59 assignes result of json_decode() to $data property of type array, however the return value of the function does not have to be an array (for example "null" is a valid JSON content being decoded into null).

tenmajkl commented 11 months ago

is there any actual situation where can the file contain literal null?

tenmajkl commented 11 months ago

Because I think that unless you directly write it to the file, its impossible for null to apear there.

harabisj commented 11 months ago

I'm not 100 % sure, however this code should raise the exception:

Cache::set('key', null);
Cache::get('key');
tenmajkl commented 11 months ago

I think it sould be ok

harabisj commented 11 months ago

Right, mentioned code does not produce the error.

harabisj commented 11 months ago

The problem is in syntactically malformed data.json file. Currently I am unsure, how the error occurred. If the issue reappears, I'll reopen it.