use Friendica\Model;
/**
- * This class implements the preload Time configuration, which will cache
+ * This class implements the preload configuration, which will cache
* all user config values per call in a cache.
*
* Minimizes the number of database queries to retrieve configuration values at the cost of memory.
*/
public function load(int $uid, string $cat = 'config')
{
- // Don't load the whole configuration twice
- if (!empty($this->config_loaded[$uid])) {
+ // Don't load the whole configuration twice or with invalid uid
+ if (!$uid || !empty($this->config_loaded[$uid])) {
return;
}
*/
public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false)
{
+ if (!$uid) {
+ return $default_value;
+ }
+
if (empty($this->config_loaded[$uid])) {
$this->load($uid);
} elseif ($refresh) {
*/
public function set(int $uid, string $cat, string $key, $value)
{
+ if (!$uid) {
+ return false;
+ }
+
if (empty($this->config_loaded[$uid])) {
$this->load($uid);
}
*/
public function delete(int $uid, string $cat, string $key)
{
+ if (!$uid) {
+ return false;
+ }
+
if (empty($this->config_loaded[$uid])) {
$this->load($uid);
}