diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index 7689ea979b..888b19a024 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -751,12 +751,12 @@ class Memcached_DataObject extends Safe_DataObject function _connect() { - global $_DB_DATAOBJECT; + global $_DB_DATAOBJECT, $_PEAR; $sum = $this->_getDbDsnMD5(); if (!empty($_DB_DATAOBJECT['CONNECTIONS'][$sum]) && - !PEAR::isError($_DB_DATAOBJECT['CONNECTIONS'][$sum])) { + !$_PEAR->isError($_DB_DATAOBJECT['CONNECTIONS'][$sum])) { $exists = true; } else { $exists = false; diff --git a/lib/framework.php b/lib/framework.php index 50a04d4fd3..4e9078845f 100644 --- a/lib/framework.php +++ b/lib/framework.php @@ -174,4 +174,5 @@ function PEAR_ErrorToPEAR_Exception($err) throw new PEAR_Exception($err->getMessage()); } -PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'PEAR_ErrorToPEAR_Exception'); +/* global */ $_PEAR = new PEAR; +$_PEAR->setErrorHandling(PEAR_ERROR_CALLBACK, 'PEAR_ErrorToPEAR_Exception'); diff --git a/lib/schema.php b/lib/schema.php index 92555499ba..94cde28f9d 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -345,9 +345,11 @@ class Schema public function dropTable($name) { + global $_PEAR; + $res = $this->conn->query("DROP TABLE $name"); - if (PEAR::isError($res)) { + if ($_PEAR->isError($res)) { throw new Exception($res->getMessage()); } @@ -372,6 +374,8 @@ class Schema public function createIndex($table, $columnNames, $name=null) { + global $_PEAR; + if (!is_array($columnNames)) { $columnNames = array($columnNames); } @@ -384,7 +388,7 @@ class Schema "ADD INDEX $name (". implode(",", $columnNames).")"); - if (PEAR::isError($res)) { + if ($_PEAR->isError($res)) { throw new Exception($res->getMessage()); } @@ -402,9 +406,11 @@ class Schema public function dropIndex($table, $name) { + global $_PEAR; + $res = $this->conn->query("ALTER TABLE $table DROP INDEX $name"); - if (PEAR::isError($res)) { + if ($_PEAR->isError($res)) { throw new Exception($res->getMessage()); } @@ -423,11 +429,13 @@ class Schema public function addColumn($table, $columndef) { + global $_PEAR; + $sql = "ALTER TABLE $table ADD COLUMN " . $this->_columnSql($columndef); $res = $this->conn->query($sql); - if (PEAR::isError($res)) { + if ($_PEAR->isError($res)) { throw new Exception($res->getMessage()); } @@ -447,12 +455,14 @@ class Schema public function modifyColumn($table, $columndef) { + global $_PEAR; + $sql = "ALTER TABLE $table MODIFY COLUMN " . $this->_columnSql($columndef); $res = $this->conn->query($sql); - if (PEAR::isError($res)) { + if ($_PEAR->isError($res)) { throw new Exception($res->getMessage()); } @@ -472,11 +482,13 @@ class Schema public function dropColumn($table, $columnName) { + global $_PEAR; + $sql = "ALTER TABLE $table DROP COLUMN $columnName"; $res = $this->conn->query($sql); - if (PEAR::isError($res)) { + if ($_PEAR->isError($res)) { throw new Exception($res->getMessage()); } @@ -513,6 +525,8 @@ class Schema */ function runSqlSet(array $statements) { + global $_PEAR; + $ok = true; foreach ($statements as $sql) { if (defined('DEBUG_INSTALLER')) { @@ -520,7 +534,7 @@ class Schema } $res = $this->conn->query($sql); - if (PEAR::isError($res)) { + if ($_PEAR->isError($res)) { throw new Exception($res->getMessage()); } } @@ -1027,8 +1041,10 @@ class Schema */ protected function fetchQueryData($sql) { + global $_PEAR; + $res = $this->conn->query($sql); - if (PEAR::isError($res)) { + if ($_PEAR->isError($res)) { throw new Exception($res->getMessage()); } diff --git a/lib/statusnet.php b/lib/statusnet.php index ac7784eed1..14b57ea052 100644 --- a/lib/statusnet.php +++ b/lib/statusnet.php @@ -264,7 +264,7 @@ class StatusNet */ public static function initDefaults($server, $path) { - global $_server, $_path, $config; + global $_server, $_path, $config, $_PEAR; Event::clearHandlers(); self::$plugins = array(); @@ -296,7 +296,7 @@ class StatusNet // default configuration, overwritten in config.php // Keep DB_DataObject's db config synced to ours... - $config['db'] = &PEAR::getStaticProperty('DB_DataObject','options'); + $config['db'] = &$_PEAR->getStaticProperty('DB_DataObject','options'); $config['db'] = $default['db'];