Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/cache/PhabricatorUserProfileImageCacheType.php
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | public function getValueFromStorage($value) { | ||||
return end($parts); | return end($parts); | ||||
} | } | ||||
public function shouldValidateRawCacheData() { | public function shouldValidateRawCacheData() { | ||||
return true; | return true; | ||||
} | } | ||||
public function isRawCacheDataValid(PhabricatorUser $user, $key, $data) { | public function isRawCacheDataValid(PhabricatorUser $user, $key, $data) { | ||||
if ($data === null) { | |||||
return false; | |||||
} | |||||
$parts = explode(',', $data, 2); | $parts = explode(',', $data, 2); | ||||
$version = reset($parts); | $version = reset($parts); | ||||
return ($version === $this->getCacheVersion($user)); | return ($version === $this->getCacheVersion($user)); | ||||
valerio.bozzolan: Before PHP 8.1 this was happening, when `$data` was null:
```
$parts = explode(',', null… | |||||
} | } | ||||
Not Done Inline ActionsThanks. Also here maybe better a minimal strict short-circuit check like if ($data === null) { return false; } To avoid type juggling with string "0" etc. valerio.bozzolan: Thanks. Also here maybe better a minimal strict short-circuit check like
```lang=php
if ($data… | |||||
private function getCacheVersion(PhabricatorUser $user) { | private function getCacheVersion(PhabricatorUser $user) { | ||||
$parts = array( | $parts = array( | ||||
PhabricatorEnv::getCDNURI('/'), | PhabricatorEnv::getCDNURI('/'), | ||||
PhabricatorEnv::getEnvConfig('cluster.instance'), | PhabricatorEnv::getEnvConfig('cluster.instance'), | ||||
$user->getProfileImagePHID(), | $user->getProfileImagePHID(), | ||||
); | ); | ||||
$parts = serialize($parts); | $parts = serialize($parts); | ||||
return PhabricatorHash::digestForIndex($parts); | return PhabricatorHash::digestForIndex($parts); | ||||
} | } | ||||
Done Inline ActionsInternal note: this method never returns an empty string or null valerio.bozzolan: Internal note: this method never returns an empty string or null | |||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
Before PHP 8.1 this was happening, when $data was null:
Also note that $this->getCacheVersion($user) seems that it never returns an empty string so this is really always false when $data is null