]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Config/JITConfigAdapter.php
fixing reset()
[friendica.git] / src / Core / Config / JITConfigAdapter.php
index e7aecb933b673af56a7a65e9f3cdccf28f596d37..ecd88bb3d3d5d9f609dbb706d64a5f7eccfd1db3 100644 (file)
@@ -10,7 +10,7 @@ use Friendica\Database\DBA;
  *
  * @author Hypolite Petovan <hypolite@mrpetovan.com>
  */
-class JITConfigAdapter implements IConfigAdapter
+class JITConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAdapter
 {
        private $cache;
        private $in_db;
@@ -26,6 +26,7 @@ class JITConfigAdapter implements IConfigAdapter
        public function __construct(IConfigCache $configCache)
        {
                $this->configCache = $configCache;
+               $this->connected = DBA::connected();
        }
 
        /**
@@ -33,6 +34,10 @@ class JITConfigAdapter implements IConfigAdapter
         */
        public function load($cat = "config")
        {
+               if (!$this->isConnected()) {
+                       return;
+               }
+
                // We don't preload "system" anymore.
                // This reduces the number of database reads a lot.
                if ($cat === 'system') {
@@ -58,6 +63,10 @@ class JITConfigAdapter implements IConfigAdapter
         */
        public function get($cat, $k, $default_value = null, $refresh = false)
        {
+               if (!$this->isConnected()) {
+                       return $default_value;
+               }
+
                if (!$refresh) {
                        // Do we have the cached value? Then return it
                        if (isset($this->cache[$cat][$k])) {
@@ -103,6 +112,10 @@ class JITConfigAdapter implements IConfigAdapter
         */
        public function set($cat, $k, $value)
        {
+               if (!$this->isConnected()) {
+                       return false;
+               }
+
                // We store our setting values in a string variable.
                // So we have to do the conversion here so that the compare below works.
                // The exception are array values.
@@ -143,6 +156,10 @@ class JITConfigAdapter implements IConfigAdapter
         */
        public function delete($cat, $k)
        {
+               if (!$this->isConnected()) {
+                       return false;
+               }
+
                if (isset($this->cache[$cat][$k])) {
                        unset($this->cache[$cat][$k]);
                        unset($this->in_db[$cat][$k]);