$_PEAR now defined globally as new PEAR, so no static calls are made

This commit is contained in:
Mikael Nordfeldth 2013-09-23 22:27:17 +02:00
parent 8205c56e25
commit 9d3abc3600
4 changed files with 30 additions and 13 deletions

View File

@ -751,12 +751,12 @@ class Memcached_DataObject extends Safe_DataObject
function _connect() function _connect()
{ {
global $_DB_DATAOBJECT; global $_DB_DATAOBJECT, $_PEAR;
$sum = $this->_getDbDsnMD5(); $sum = $this->_getDbDsnMD5();
if (!empty($_DB_DATAOBJECT['CONNECTIONS'][$sum]) && if (!empty($_DB_DATAOBJECT['CONNECTIONS'][$sum]) &&
!PEAR::isError($_DB_DATAOBJECT['CONNECTIONS'][$sum])) { !$_PEAR->isError($_DB_DATAOBJECT['CONNECTIONS'][$sum])) {
$exists = true; $exists = true;
} else { } else {
$exists = false; $exists = false;

View File

@ -174,4 +174,5 @@ function PEAR_ErrorToPEAR_Exception($err)
throw new PEAR_Exception($err->getMessage()); 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');

View File

@ -345,9 +345,11 @@ class Schema
public function dropTable($name) public function dropTable($name)
{ {
global $_PEAR;
$res = $this->conn->query("DROP TABLE $name"); $res = $this->conn->query("DROP TABLE $name");
if (PEAR::isError($res)) { if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage()); throw new Exception($res->getMessage());
} }
@ -372,6 +374,8 @@ class Schema
public function createIndex($table, $columnNames, $name=null) public function createIndex($table, $columnNames, $name=null)
{ {
global $_PEAR;
if (!is_array($columnNames)) { if (!is_array($columnNames)) {
$columnNames = array($columnNames); $columnNames = array($columnNames);
} }
@ -384,7 +388,7 @@ class Schema
"ADD INDEX $name (". "ADD INDEX $name (".
implode(",", $columnNames).")"); implode(",", $columnNames).")");
if (PEAR::isError($res)) { if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage()); throw new Exception($res->getMessage());
} }
@ -402,9 +406,11 @@ class Schema
public function dropIndex($table, $name) public function dropIndex($table, $name)
{ {
global $_PEAR;
$res = $this->conn->query("ALTER TABLE $table DROP INDEX $name"); $res = $this->conn->query("ALTER TABLE $table DROP INDEX $name");
if (PEAR::isError($res)) { if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage()); throw new Exception($res->getMessage());
} }
@ -423,11 +429,13 @@ class Schema
public function addColumn($table, $columndef) public function addColumn($table, $columndef)
{ {
global $_PEAR;
$sql = "ALTER TABLE $table ADD COLUMN " . $this->_columnSql($columndef); $sql = "ALTER TABLE $table ADD COLUMN " . $this->_columnSql($columndef);
$res = $this->conn->query($sql); $res = $this->conn->query($sql);
if (PEAR::isError($res)) { if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage()); throw new Exception($res->getMessage());
} }
@ -447,12 +455,14 @@ class Schema
public function modifyColumn($table, $columndef) public function modifyColumn($table, $columndef)
{ {
global $_PEAR;
$sql = "ALTER TABLE $table MODIFY COLUMN " . $sql = "ALTER TABLE $table MODIFY COLUMN " .
$this->_columnSql($columndef); $this->_columnSql($columndef);
$res = $this->conn->query($sql); $res = $this->conn->query($sql);
if (PEAR::isError($res)) { if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage()); throw new Exception($res->getMessage());
} }
@ -472,11 +482,13 @@ class Schema
public function dropColumn($table, $columnName) public function dropColumn($table, $columnName)
{ {
global $_PEAR;
$sql = "ALTER TABLE $table DROP COLUMN $columnName"; $sql = "ALTER TABLE $table DROP COLUMN $columnName";
$res = $this->conn->query($sql); $res = $this->conn->query($sql);
if (PEAR::isError($res)) { if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage()); throw new Exception($res->getMessage());
} }
@ -513,6 +525,8 @@ class Schema
*/ */
function runSqlSet(array $statements) function runSqlSet(array $statements)
{ {
global $_PEAR;
$ok = true; $ok = true;
foreach ($statements as $sql) { foreach ($statements as $sql) {
if (defined('DEBUG_INSTALLER')) { if (defined('DEBUG_INSTALLER')) {
@ -520,7 +534,7 @@ class Schema
} }
$res = $this->conn->query($sql); $res = $this->conn->query($sql);
if (PEAR::isError($res)) { if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage()); throw new Exception($res->getMessage());
} }
} }
@ -1027,8 +1041,10 @@ class Schema
*/ */
protected function fetchQueryData($sql) protected function fetchQueryData($sql)
{ {
global $_PEAR;
$res = $this->conn->query($sql); $res = $this->conn->query($sql);
if (PEAR::isError($res)) { if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage()); throw new Exception($res->getMessage());
} }

View File

@ -264,7 +264,7 @@ class StatusNet
*/ */
public static function initDefaults($server, $path) public static function initDefaults($server, $path)
{ {
global $_server, $_path, $config; global $_server, $_path, $config, $_PEAR;
Event::clearHandlers(); Event::clearHandlers();
self::$plugins = array(); self::$plugins = array();
@ -296,7 +296,7 @@ class StatusNet
// default configuration, overwritten in config.php // default configuration, overwritten in config.php
// Keep DB_DataObject's db config synced to ours... // 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']; $config['db'] = $default['db'];