<?php
namespace Friendica\Core\Config;
-use dba;
use Friendica\BaseObject;
-use Friendica\Database\DBM;
+use Friendica\Database\DBA;
require_once 'include/dba.php';
*
* Default Config Adapter. Provides the best performance for pages loading few configuration variables.
*
- * @author Hypolite Petovan <mrpetovan@gmail.com>
+ * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class JITConfigAdapter extends BaseObject implements IConfigAdapter
{
return;
}
- $configs = dba::select('config', ['v', 'k'], ['cat' => $cat]);
- while ($config = dba::fetch($configs)) {
+ $configs = DBA::select('config', ['v', 'k'], ['cat' => $cat]);
+ while ($config = DBA::fetch($configs)) {
$k = $config['k'];
self::getApp()->setConfigValue($cat, $k, $config['v']);
$this->in_db[$cat][$k] = true;
}
}
- dba::close($configs);
+ DBA::close($configs);
}
public function get($cat, $k, $default_value = null, $refresh = false)
}
}
- $config = dba::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
- if (DBM::is_result($config)) {
+ $config = DBA::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
+ if (DBA::isResult($config)) {
// manage array value
$value = (preg_match("|^a:[0-9]+:{.*}$|s", $config['v']) ? unserialize($config['v']) : $config['v']);
$this->in_db[$cat][$k] = true;
return $value;
} elseif (isset($a->config[$cat][$k])) {
- // Assign the value (mostly) from the .htconfig.php to the cache
+ // Assign the value (mostly) from config/local.ini.php file to the cache
$this->cache[$cat][$k] = $a->config[$cat][$k];
$this->in_db[$cat][$k] = false;
return $a->config[$cat][$k];
+ } elseif (isset($a->config[$k])) {
+ // Assign the value (mostly) from config/local.ini.php file to the cache
+ $this->cache[$k] = $a->config[$k];
+ $this->in_db[$k] = false;
+
+ return $a->config[$k];
}
$this->cache[$cat][$k] = '!<unset>!';
$stored = $this->get($cat, $k, null, true);
+ if (!isset($this->in_db[$cat])) {
+ $this->in_db[$cat] = [];
+ }
+ if (!isset($this->in_db[$cat][$k])) {
+ $this->in_db[$cat] = false;
+ }
+
if (($stored === $dbvalue) && $this->in_db[$cat][$k]) {
return true;
}
// manage array value
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
- $result = dba::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true);
+ $result = DBA::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true);
if ($result) {
$this->in_db[$cat][$k] = true;
unset($this->in_db[$cat][$k]);
}
- $result = dba::delete('config', ['cat' => $cat, 'k' => $k]);
+ $result = DBA::delete('config', ['cat' => $cat, 'k' => $k]);
return $result;
}