]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'master' into 0.9.x
authorEvan Prodromou <evan@status.net>
Fri, 1 Jan 2010 21:20:25 +0000 (11:20 -1000)
committerEvan Prodromou <evan@status.net>
Fri, 1 Jan 2010 21:20:25 +0000 (11:20 -1000)
Conflicts:
classes/Memcached_DataObject.php

1  2 
classes/Memcached_DataObject.php

index be8137573d31530862a1e63f05bd63d605c89902,cf7fb4340ab9f301e2f516b3440bd5f69ac1d7e5..4f81bef75c4fb4da016919fd3baf30c8c7262371
@@@ -37,15 -37,6 +37,15 @@@ class Memcached_DataObject extends DB_D
          }
      }
  
 +    /**
 +     * Wrapper for DB_DataObject's static lookup using memcached
 +     * as backing instead of an in-process cache array.
 +     *
 +     * @param string $cls classname of object type to load
 +     * @param mixed $k key field name, or value for primary key
 +     * @param mixed $v key field value, or leave out for primary key lookup
 +     * @return mixed Memcached_DataObject subtype or false
 +     */
      function &staticGet($cls, $k, $v=null)
      {
          if (is_null($v)) {
          if ($i) {
              return $i;
          } else {
-             $i = DB_DataObject::staticGet($cls, $k, $v);
-             if ($i) {
-                 // DB_DataObject's in-process lookup cache interferes with GC
-                 // to cause massive memory leaks in long-running processes.
-                 if (php_sapi_name() == 'cli') {
-                     $i->_clear_cache();
-                 }
-                 
-                 // Now store it into the shared memcached, if present...
+             $i = DB_DataObject::factory($cls);
+             if (empty($i)) {
+                 return null;
+             }
+             $result = $i->get($k, $v);
+             if ($result) {
                  $i->encache();
+                 return $i;
+             } else {
+                 return null;
              }
-             return $i;
          }
      }
  
          return new ArrayWrapper($cached);
      }
  
+     function cleanup()
+     {
+         global $_DB_DATAOBJECT;
+         if (isset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid])) {
+             unset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]);
+         }
+         if (isset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid])) {
+             unset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid]);
+         }
+     }
      // We overload so that 'SET NAMES "utf8"' is called for
      // each connection