]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/cache.php
fix local file include vulnerability in doc.php
[quix0rs-gnu-social.git] / lib / cache.php
index bac3499e5eed563b116c8b86a686b434cbaa72cb..635c96ad4c7899640ac0f8c3ed7e149daad9ce5a 100644 (file)
@@ -120,7 +120,7 @@ class Cache
 
         if (Event::handle('StartCacheGet', array(&$key, &$value))) {
             if (array_key_exists($key, $this->_items)) {
-                $value = $this->_items[$key];
+                $value = unserialize($this->_items[$key]);
             }
             Event::handle('EndCacheGet', array($key, &$value));
         }
@@ -146,7 +146,7 @@ class Cache
         if (Event::handle('StartCacheSet', array(&$key, &$value, &$flag,
                                                  &$expiry, &$success))) {
 
-            $this->_items[$key] = $value;
+            $this->_items[$key] = serialize($value);
 
             $success = true;
 
@@ -170,7 +170,7 @@ class Cache
         $success = false;
 
         if (Event::handle('StartCacheDelete', array(&$key, &$success))) {
-            if (array_key_exists($key, $this->_items[$key])) {
+            if (array_key_exists($key, $this->_items)) {
                 unset($this->_items[$key]);
             }
             $success = true;
@@ -179,4 +179,23 @@ class Cache
 
         return $success;
     }
+
+    /**
+     * Close or reconnect any remote connections, such as to give
+     * daemon processes a chance to reconnect on a fresh socket.
+     *
+     * @return boolean success flag
+     */
+
+    function reconnect()
+    {
+        $success = false;
+
+        if (Event::handle('StartCacheReconnect', array(&$success))) {
+            $success = true;
+            Event::handle('EndCacheReconnect', array());
+        }
+
+        return $success;
+    }
 }