]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/PConfig.php
Avoid memory issue in exception
[friendica.git] / src / Core / PConfig.php
index 1f9f36638d8535f8501249d658bce46844aa23b4..df024f0f3426dfa84abc665789066a1c6427316a 100644 (file)
@@ -8,8 +8,6 @@
  */
 namespace Friendica\Core;
 
-use Friendica\Core\Config\IPConfigCache;
-
 /**
  * @brief Management of user configuration storage
  * Note:
@@ -20,31 +18,31 @@ use Friendica\Core\Config\IPConfigCache;
 class PConfig
 {
        /**
-        * @var \Friendica\Core\Config\IPConfigAdapter
+        * @var Config\IPConfigAdapter
         */
        private static $adapter;
 
        /**
-        * @var IPConfigCache
+        * @var Config\IPConfigCache
         */
-       private static $config;
+       private static $cache;
 
        /**
         * Initialize the config with only the cache
         *
-        * @param IPConfigCache $config  The configuration cache
+        * @param Config\IPConfigCache $cache  The configuration cache
         */
-       public static function init($config)
+       public static function init(Config\IPConfigCache $cache)
        {
-               self::$config  = $config;
+               self::$cache  = $cache;
        }
 
        /**
         * Add the adapter for DB-backend
         *
-        * @param $adapter
+        * @param Config\IPConfigAdapter $adapter
         */
-       public static function setAdapter($adapter)
+       public static function setAdapter(Config\IPConfigAdapter $adapter)
        {
                self::$adapter = $adapter;
        }
@@ -52,14 +50,13 @@ class PConfig
        /**
         * @brief Loads all configuration values of a user's config family into a cached storage.
         *
-        * All configuration values of the given user are stored in global cache
-        * which is available under the global variable self::$config[$uid].
+        * All configuration values of the given user are stored with the $uid in
+        * the cache ( @see IPConfigCache )
         *
         * @param string $uid    The user_id
         * @param string $family The category of the configuration value
         *
         * @return void
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function load($uid, $family)
        {
@@ -75,7 +72,8 @@ class PConfig
         * ($family) and a key.
         *
         * Get a particular user's config value from the given category ($family)
-        * and the $key from a cached storage in self::$config[$uid].
+        * and the $key with the $uid from a cached storage either from the self::$adapter
+        * (@see IConfigAdapter ) or from the static::$cache (@see IConfigCache ).
         *
         * @param string  $uid           The user_id
         * @param string  $family        The category of the configuration value
@@ -88,7 +86,7 @@ class PConfig
        public static function get($uid, $family, $key, $default_value = null, $refresh = false)
        {
                if (!isset(self::$adapter)) {
-                       return self::$config->getP($uid, $family, $key, $default_value);
+                       return self::$cache->getP($uid, $family, $key, $default_value);
                }
 
                return self::$adapter->get($uid, $family, $key, $default_value, $refresh);
@@ -112,7 +110,7 @@ class PConfig
        public static function set($uid, $family, $key, $value)
        {
                if (!isset(self::$adapter)) {
-                       return self::$config->setP($uid, $family, $key, $value);
+                       return self::$cache->setP($uid, $family, $key, $value);
                }
 
                return self::$adapter->set($uid, $family, $key, $value);
@@ -121,20 +119,20 @@ class PConfig
        /**
         * @brief Deletes the given key from the users's configuration.
         *
-        * Removes the configured value from the stored cache in self::$config[$uid]
-        * and removes it from the database.
+        * Removes the configured value from the stored cache in self::$config
+        * (@see ConfigCache ) and removes it from the database (@see IConfigAdapter )
+        * with the given $uid.
         *
         * @param string $uid    The user_id
         * @param string $family The category of the configuration value
         * @param string $key    The configuration key to delete
         *
         * @return mixed
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function delete($uid, $family, $key)
        {
                if (!isset(self::$adapter)) {
-                       return self::$config->deleteP($uid, $family, $key);
+                       return self::$cache->deleteP($uid, $family, $key);
                }
 
                return self::$adapter->delete($uid, $family, $key);