]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
MITM the DB_DataObject to avoid PEAR::DB strict standards warnings
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 6 Jun 2015 16:29:15 +0000 (18:29 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 6 Jun 2015 16:29:15 +0000 (18:29 +0200)
classes/GS_DataObject.php [new file with mode: 0644]
classes/Memcached_DataObject.php
classes/Safe_DataObject.php

diff --git a/classes/GS_DataObject.php b/classes/GS_DataObject.php
new file mode 100644 (file)
index 0000000..67f3240
--- /dev/null
@@ -0,0 +1,192 @@
+<?php
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+class GS_DataObject extends DB_DataObject
+{
+    public function _autoloadClass($class, $table=false)
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::_autoloadClass($class, $table);
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    // wraps the _connect call so we don't throw E_STRICT warnings during it
+    public function _connect()
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::_connect();
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    // wraps the _loadConfig call so we don't throw E_STRICT warnings during it
+    // doesn't actually return anything, but we'll follow the same model as the rest of the wrappers
+    public function _loadConfig()
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::_loadConfig();
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    // wraps the count call so we don't throw E_STRICT warnings during it
+    public function count($countWhat = false,$whereAddOnly = false)
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::count($countWhat, $whereAddOnly);
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    public function debugLevel($v = null)
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::debugLevel($v);
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    public function factory($table = '')
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::factory($table);
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    public function get($k = null, $v = null)
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::get($k, $v);
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    public function fetch()
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::fetch();
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    public function find($n = false)
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::find($n);
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    public function fetchRow($row = null)
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::fetchRow($row);
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    public function links()
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::links();
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    // wraps the update call so we don't throw E_STRICT warnings during it
+    public function update($dataObject = false)
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::update($dataObject);
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    public function staticGet($class, $k, $v = null)
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::staticGet($class, $k, $v);
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+
+    public function staticGetAutoloadTable($table)
+    {
+        // avoid those annoying PEAR::DB strict standards warnings it causes
+        $old = error_reporting();
+        error_reporting(error_reporting() & ~E_STRICT);
+
+        $res = parent::staticGetAutoloadTable($table);
+
+        // reset
+        error_reporting($old);
+        return $res;
+    }
+}
index 91b986891cea53aa6a74ee04f3c0512f2e047ba6..c725e1d9aa1754f5ab2488f9db2052079710450c 100644 (file)
@@ -824,7 +824,7 @@ class Memcached_DataObject extends Safe_DataObject
         global $_DB_DATAOBJECT;
 
         if (empty($_DB_DATAOBJECT['CONFIG'])) {
-            DB_DataObject::_loadConfig();
+            self::_loadConfig();
         }
 
         $options = &$_DB_DATAOBJECT['CONFIG'];
index b4c251c475f609047c737d401863fd930416e697..8e5e72c013bdc6ebe7d68cada500fb408e294efa 100644 (file)
@@ -17,7 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Extended DB_DataObject to improve a few things:
@@ -26,7 +26,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
  * - don't leak memory when loading already-used .ini files
  *   (eg when using the same schema on thousands of databases)
  */
-class Safe_DataObject extends DB_DataObject
+class Safe_DataObject extends GS_DataObject
 {
     /**
      * Destructor to free global memory resources associated with
@@ -177,7 +177,6 @@ class Safe_DataObject extends DB_DataObject
             }
 
         }
-
         if (!$this->_database) {
             $this->_connect();
         }
@@ -204,7 +203,7 @@ class Safe_DataObject extends DB_DataObject
         }
 
         if (empty($_DB_DATAOBJECT['CONFIG'])) {
-            DB_DataObject::_loadConfig();
+            self::_loadConfig();
         }
 
         // if you supply this with arguments, then it will take those