Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/private/Files/Cache/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static function getStorageById($storageId) {
self::$localCache = new CappedMemoryCache();
}
$result = self::$localCache->get($storageId);
if ($result === null) {
if ($result === null || empty($result) || !isset($result['numeric_id'])) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any case where the empty($result) check is relevant? The isset check should be more restrictive anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty($result) is in case an empty array is returned

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

php > $a = [];
php > $b = isset($a['key']);
php > var_dump($b);
bool(false)

It should be covered with the isset check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll make a master only PR for perfection

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh PHP... if this was JS that isset would fail

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$result = self::getStorageByIdFromCache($storageId);
self::$localCache->set($storageId, $result);
}
Expand All @@ -134,7 +134,7 @@ private static function getDistributedCache() {
*/
private static function getStorageByIdFromCache($storageId) {
$result = self::getDistributedCache()->get($storageId);
if ($result === null) {
if ($result === null || empty($result) || !isset($result['numeric_id'])) {
$result = self::getStorageByIdFromDb($storageId);
self::getDistributedCache()->set(
$storageId, $result, self::$distributedCacheTTL
Expand Down