Skip to content
Snippets Groups Projects
Commit 519a84e0 authored by Robin Appelman's avatar Robin Appelman
Browse files

more strict fixes for mdb2

parent a0844522
Branches
No related tags found
No related merge requests found
...@@ -340,7 +340,7 @@ class MDB2 ...@@ -340,7 +340,7 @@ class MDB2
} else { } else {
$msg = "unable to load class '$class_name' from file '$file_name'"; $msg = "unable to load class '$class_name' from file '$file_name'";
} }
$err =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, $msg); $err =MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, $msg);
return $err; return $err;
} }
} }
...@@ -378,7 +378,7 @@ class MDB2 ...@@ -378,7 +378,7 @@ class MDB2
{ {
$dsninfo = MDB2::parseDSN($dsn); $dsninfo = MDB2::parseDSN($dsn);
if (empty($dsninfo['phptype'])) { if (empty($dsninfo['phptype'])) {
$err =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND, $err =MDB2::raiseError(MDB2_ERROR_NOT_FOUND,
null, null, 'no RDBMS driver specified'); null, null, 'no RDBMS driver specified');
return $err; return $err;
} }
...@@ -433,7 +433,7 @@ class MDB2 ...@@ -433,7 +433,7 @@ class MDB2
*/ */
function &connect($dsn, $options = false) function &connect($dsn, $options = false)
{ {
$db =& MDB2::factory($dsn, $options); $db =MDB2::factory($dsn, $options);
if (PEAR::isError($db)) { if (PEAR::isError($db)) {
return $db; return $db;
} }
...@@ -497,10 +497,10 @@ class MDB2 ...@@ -497,10 +497,10 @@ class MDB2
} }
} }
} elseif (is_array($GLOBALS['_MDB2_databases']) && reset($GLOBALS['_MDB2_databases'])) { } elseif (is_array($GLOBALS['_MDB2_databases']) && reset($GLOBALS['_MDB2_databases'])) {
$db =& $GLOBALS['_MDB2_databases'][key($GLOBALS['_MDB2_databases'])]; $db =$GLOBALS['_MDB2_databases'][key($GLOBALS['_MDB2_databases'])];
return $db; return $db;
} }
$db =& MDB2::factory($dsn, $options); $db =MDB2::factory($dsn, $options);
return $db; return $db;
} }
...@@ -597,7 +597,7 @@ class MDB2 ...@@ -597,7 +597,7 @@ class MDB2
* @access private * @access private
* @see PEAR_Error * @see PEAR_Error
*/ */
function &raiseError($code = null, static function raiseError($code = null,
$mode = null, $mode = null,
$options = null, $options = null,
$userinfo = null, $userinfo = null,
...@@ -605,7 +605,7 @@ class MDB2 ...@@ -605,7 +605,7 @@ class MDB2
$dummy2 = null, $dummy2 = null,
$dummy3 = false) $dummy3 = false)
{ {
$err =& PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true); $err =PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
return $err; return $err;
} }
...@@ -1000,7 +1000,7 @@ class MDB2_Error extends PEAR_Error ...@@ -1000,7 +1000,7 @@ class MDB2_Error extends PEAR_Error
* *
* @param mixed MDB2 error code, or string with error message. * @param mixed MDB2 error code, or string with error message.
* @param int what 'error mode' to operate in * @param int what 'error mode' to operate in
* @param int what error level to use for $mode & PEAR_ERROR_TRIGGER * @param int what error level to use for $mode raPEAR_ERROR_TRIGGER
* @param mixed additional debug info, such as the last query * @param mixed additional debug info, such as the last query
*/ */
function MDB2_Error($code = MDB2_ERROR, $mode = PEAR_ERROR_RETURN, function MDB2_Error($code = MDB2_ERROR, $mode = PEAR_ERROR_RETURN,
...@@ -1457,7 +1457,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -1457,7 +1457,7 @@ class MDB2_Driver_Common extends PEAR
* @access public * @access public
* @see PEAR_Error * @see PEAR_Error
*/ */
function &raiseError($code = null, static function &raiseError($code = null,
$mode = null, $mode = null,
$options = null, $options = null,
$userinfo = null, $userinfo = null,
...@@ -1501,7 +1501,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -1501,7 +1501,7 @@ class MDB2_Driver_Common extends PEAR
$err = PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true); $err = PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
if ($err->getMode() !== PEAR_ERROR_RETURN if ($err->getMode() !== PEAR_ERROR_RETURN
&& isset($this->nested_transaction_counter) && !$this->has_transaction_error) { && isset($this->nested_transaction_counter) && !$this->has_transaction_error) {
$this->has_transaction_error =& $err; $this->has_transaction_error =$err;
} }
return $err; return $err;
} }
...@@ -1938,12 +1938,12 @@ class MDB2_Driver_Common extends PEAR ...@@ -1938,12 +1938,12 @@ class MDB2_Driver_Common extends PEAR
} }
if (!MDB2::classExists($class_name)) { if (!MDB2::classExists($class_name)) {
$err =& $this->raiseError(MDB2_ERROR_LOADMODULE, null, null, $err =$this->raiseError(MDB2_ERROR_LOADMODULE, null, null,
"unable to load module '$module' into property '$property'", __FUNCTION__); "unable to load module '$module' into property '$property'", __FUNCTION__);
return $err; return $err;
} }
$this->{$property} = new $class_name($this->db_index); $this->{$property} = new $class_name($this->db_index);
$this->modules[$module] =& $this->{$property}; $this->modules[$module] =$this->{$property};
if ($version) { if ($version) {
// this will be used in the connect method to determine if the module // this will be used in the connect method to determine if the module
// needs to be loaded with a different version if the server // needs to be loaded with a different version if the server
...@@ -2447,7 +2447,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -2447,7 +2447,7 @@ class MDB2_Driver_Common extends PEAR
return $connection; return $connection;
} }
$result =& $this->_doQuery($query, $is_manip, $connection, false); $result =$this->_doQuery($query, $is_manip, $connection, false);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
return $result; return $result;
} }
...@@ -2456,7 +2456,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -2456,7 +2456,7 @@ class MDB2_Driver_Common extends PEAR
$affected_rows = $this->_affectedRows($connection, $result); $affected_rows = $this->_affectedRows($connection, $result);
return $affected_rows; return $affected_rows;
} }
$result =& $this->_wrapResult($result, $types, true, false, $limit, $offset); $result =$this->_wrapResult($result, $types, true, false, $limit, $offset);
return $result; return $result;
} }
...@@ -2504,7 +2504,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -2504,7 +2504,7 @@ class MDB2_Driver_Common extends PEAR
} }
$query = $result; $query = $result;
} }
$err =& $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, $err =$this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'method not implemented', __FUNCTION__); 'method not implemented', __FUNCTION__);
return $err; return $err;
} }
...@@ -2552,7 +2552,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -2552,7 +2552,7 @@ class MDB2_Driver_Common extends PEAR
return $connection; return $connection;
} }
$result =& $this->_doQuery($query, true, $connection, $this->database_name); $result =$this->_doQuery($query, true, $connection, $this->database_name);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
return $result; return $result;
} }
...@@ -2589,12 +2589,12 @@ class MDB2_Driver_Common extends PEAR ...@@ -2589,12 +2589,12 @@ class MDB2_Driver_Common extends PEAR
return $connection; return $connection;
} }
$result =& $this->_doQuery($query, false, $connection, $this->database_name); $result =$this->_doQuery($query, false, $connection, $this->database_name);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
return $result; return $result;
} }
$result =& $this->_wrapResult($result, $types, $result_class, $result_wrap_class, $limit, $offset); $result =$this->_wrapResult($result, $types, $result_class, $result_wrap_class, $limit, $offset);
return $result; return $result;
} }
...@@ -2643,13 +2643,13 @@ class MDB2_Driver_Common extends PEAR ...@@ -2643,13 +2643,13 @@ class MDB2_Driver_Common extends PEAR
if ($result_class) { if ($result_class) {
$class_name = sprintf($result_class, $this->phptype); $class_name = sprintf($result_class, $this->phptype);
if (!MDB2::classExists($class_name)) { if (!MDB2::classExists($class_name)) {
$err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, $err =$this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'result class does not exist '.$class_name, __FUNCTION__); 'result class does not exist '.$class_name, __FUNCTION__);
return $err; return $err;
} }
$result =new $class_name($this, $result, $limit, $offset); $result =new $class_name($this, $result, $limit, $offset);
if (!MDB2::isResultCommon($result)) { if (!MDB2::isResultCommon($result)) {
$err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, $err =$this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'result class is not extended from MDB2_Result_Common', __FUNCTION__); 'result class is not extended from MDB2_Result_Common', __FUNCTION__);
return $err; return $err;
} }
...@@ -2666,7 +2666,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -2666,7 +2666,7 @@ class MDB2_Driver_Common extends PEAR
} }
if ($result_wrap_class) { if ($result_wrap_class) {
if (!MDB2::classExists($result_wrap_class)) { if (!MDB2::classExists($result_wrap_class)) {
$err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, $err =$this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'result wrap class does not exist '.$result_wrap_class, __FUNCTION__); 'result wrap class does not exist '.$result_wrap_class, __FUNCTION__);
return $err; return $err;
} }
...@@ -2877,7 +2877,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -2877,7 +2877,7 @@ class MDB2_Driver_Common extends PEAR
$condition = ' WHERE '.implode(' AND ', $condition); $condition = ' WHERE '.implode(' AND ', $condition);
$query = 'DELETE FROM ' . $this->quoteIdentifier($table, true) . $condition; $query = 'DELETE FROM ' . $this->quoteIdentifier($table, true) . $condition;
$result =& $this->_doQuery($query, true, $connection); $result =$this->_doQuery($query, true, $connection);
if (!PEAR::isError($result)) { if (!PEAR::isError($result)) {
$affected_rows = $this->_affectedRows($connection, $result); $affected_rows = $this->_affectedRows($connection, $result);
$insert = ''; $insert = '';
...@@ -2886,7 +2886,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -2886,7 +2886,7 @@ class MDB2_Driver_Common extends PEAR
} }
$values = implode(', ', $values); $values = implode(', ', $values);
$query = 'INSERT INTO '. $this->quoteIdentifier($table, true) . "($insert) VALUES ($values)"; $query = 'INSERT INTO '. $this->quoteIdentifier($table, true) . "($insert) VALUES ($values)";
$result =& $this->_doQuery($query, true, $connection); $result =$this->_doQuery($query, true, $connection);
if (!PEAR::isError($result)) { if (!PEAR::isError($result)) {
$affected_rows += $this->_affectedRows($connection, $result);; $affected_rows += $this->_affectedRows($connection, $result);;
} }
...@@ -2996,7 +2996,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -2996,7 +2996,7 @@ class MDB2_Driver_Common extends PEAR
$regexp = '/^.{'.($position+1).'}('.$this->options['bindname_format'].').*$/s'; $regexp = '/^.{'.($position+1).'}('.$this->options['bindname_format'].').*$/s';
$parameter = preg_replace($regexp, '\\1', $query); $parameter = preg_replace($regexp, '\\1', $query);
if ($parameter === '') { if ($parameter === '') {
$err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, $err =$this->raiseError(MDB2_ERROR_SYNTAX, null, null,
'named parameter name must match "bindname_format" option', __FUNCTION__); 'named parameter name must match "bindname_format" option', __FUNCTION__);
return $err; return $err;
} }
...@@ -3054,7 +3054,7 @@ class MDB2_Driver_Common extends PEAR ...@@ -3054,7 +3054,7 @@ class MDB2_Driver_Common extends PEAR
if ($ignore['end'] === "\n") { if ($ignore['end'] === "\n") {
$end_quote = strlen($query) - 1; $end_quote = strlen($query) - 1;
} else { } else {
$err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, $err =$this->raiseError(MDB2_ERROR_SYNTAX, null, null,
'query with an unterminated text string specified', __FUNCTION__); 'query with an unterminated text string specified', __FUNCTION__);
return $err; return $err;
} }
...@@ -3446,8 +3446,8 @@ class MDB2_Result_Common extends MDB2_Result ...@@ -3446,8 +3446,8 @@ class MDB2_Result_Common extends MDB2_Result
*/ */
function __construct(&$db, &$result, $limit = 0, $offset = 0) function __construct(&$db, &$result, $limit = 0, $offset = 0)
{ {
$this->db =& $db; $this->db =$db;
$this->result =& $result; $this->result =$result;
$this->offset = $offset; $this->offset = $offset;
$this->limit = max(0, $limit - 1); $this->limit = max(0, $limit - 1);
} }
...@@ -3541,7 +3541,7 @@ class MDB2_Result_Common extends MDB2_Result ...@@ -3541,7 +3541,7 @@ class MDB2_Result_Common extends MDB2_Result
*/ */
function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null)
{ {
$err =& $this->db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, $err =$this->db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'method not implemented', __FUNCTION__); 'method not implemented', __FUNCTION__);
return $err; return $err;
} }
...@@ -3846,7 +3846,7 @@ class MDB2_Result_Common extends MDB2_Result ...@@ -3846,7 +3846,7 @@ class MDB2_Result_Common extends MDB2_Result
} }
$column = $column_names[$column]; $column = $column_names[$column];
} }
$this->values[$column] =& $value; $this->values[$column] =$value;
if (!is_null($type)) { if (!is_null($type)) {
$this->types[$column] = $type; $this->types[$column] = $type;
} }
...@@ -3969,8 +3969,8 @@ class MDB2_Statement_Common ...@@ -3969,8 +3969,8 @@ class MDB2_Statement_Common
*/ */
function __construct(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip = false, $limit = null, $offset = null) function __construct(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip = false, $limit = null, $offset = null)
{ {
$this->db =& $db; $this->db =$db;
$this->statement =& $statement; $this->statement =$statement;
$this->positions = $positions; $this->positions = $positions;
$this->query = $query; $this->query = $query;
$this->types = (array)$types; $this->types = (array)$types;
...@@ -4085,7 +4085,7 @@ class MDB2_Statement_Common ...@@ -4085,7 +4085,7 @@ class MDB2_Statement_Common
return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__); 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
} }
$this->values[$parameter] =& $value; $this->values[$parameter] =$value;
if (!is_null($type)) { if (!is_null($type)) {
$this->types[$parameter] = $type; $this->types[$parameter] = $type;
} }
...@@ -4152,7 +4152,7 @@ class MDB2_Statement_Common ...@@ -4152,7 +4152,7 @@ class MDB2_Statement_Common
'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__); 'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__);
} }
} }
$result =& $this->_execute($result_class, $result_wrap_class); $result =$this->_execute($result_class, $result_wrap_class);
return $result; return $result;
} }
...@@ -4200,7 +4200,7 @@ class MDB2_Statement_Common ...@@ -4200,7 +4200,7 @@ class MDB2_Statement_Common
if ($this->is_manip) { if ($this->is_manip) {
$result = $this->db->exec($query); $result = $this->db->exec($query);
} else { } else {
$result =& $this->db->query($query, $this->result_types, $result_class, $result_wrap_class); $result =$this->db->query($query, $this->result_types, $result_class, $result_wrap_class);
} }
return $result; return $result;
} }
...@@ -4296,9 +4296,9 @@ class MDB2_Module_Common ...@@ -4296,9 +4296,9 @@ class MDB2_Module_Common
function &getDBInstance() function &getDBInstance()
{ {
if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) { if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) {
$result =& $GLOBALS['_MDB2_databases'][$this->db_index]; $result =$GLOBALS['_MDB2_databases'][$this->db_index];
} else { } else {
$result =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, $result =MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'could not find MDB2 instance'); 'could not find MDB2 instance');
} }
return $result; return $result;
......
...@@ -492,7 +492,7 @@ class PEAR ...@@ -492,7 +492,7 @@ class PEAR
* @see PEAR::setErrorHandling * @see PEAR::setErrorHandling
* @since PHP 4.0.5 * @since PHP 4.0.5
*/ */
function raiseError($message = null, static function raiseError($message = null,
$code = null, $code = null,
$mode = null, $mode = null,
$options = null, $options = null,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment