fix coding style, wrap long lines
This commit is contained in:
parent
fbb076aa78
commit
dfb51338ea
@ -3,9 +3,10 @@
|
||||
/**
|
||||
* Wrappers for Drizzle extension classes
|
||||
*
|
||||
* Drizzle extension exposes libdrizzle functions and requires user to have it in mind while using them.
|
||||
* This wrapper is not complete and hides a lot of original functionality, but allows for easy usage
|
||||
* of the drizzle PHP extension.
|
||||
* Drizzle extension exposes libdrizzle functions and requires user to have it in
|
||||
* mind while using them.
|
||||
* This wrapper is not complete and hides a lot of original functionality,
|
||||
* but allows for easy usage of the drizzle PHP extension.
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage Drizzle
|
||||
@ -14,7 +15,8 @@ if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// TODO: drizzle module segfaults while freeing resources, often. This allows at least for some development
|
||||
// TODO: drizzle module segfaults while freeing resources, often.
|
||||
// This allows at least for some development
|
||||
function _drizzle_shutdown_flush()
|
||||
{
|
||||
flush();
|
||||
@ -109,7 +111,8 @@ class PMA_Drizzle extends Drizzle
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@ -126,7 +129,8 @@ class PMA_Drizzle extends Drizzle
|
||||
* @return PMA_DrizzleCon
|
||||
*/
|
||||
public function addTcp($host, $port, $user, $password, $db, $options)
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
$dcon = parent::addTcp($host, $port, $user, $password, $db, $options);
|
||||
return $dcon instanceof DrizzleCon
|
||||
? new PMA_DrizzleCon($dcon)
|
||||
@ -145,7 +149,8 @@ class PMA_Drizzle extends Drizzle
|
||||
* @return PMA_DrizzleCon
|
||||
*/
|
||||
public function addUds($uds, $user, $password, $db, $options)
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
$dcon = parent::addUds($uds, $user, $password, $db, $options);
|
||||
return $dcon instanceof DrizzleCon
|
||||
? new PMA_DrizzleCon($dcon)
|
||||
@ -180,7 +185,8 @@ class PMA_DrizzleCon
|
||||
* @param DrizzleCon $dcon
|
||||
*/
|
||||
public function __construct(DrizzleCon $dcon)
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
$this->dcon = $dcon;
|
||||
}
|
||||
|
||||
@ -188,17 +194,22 @@ class PMA_DrizzleCon
|
||||
* Executes given query. Opens database connection if not already done.
|
||||
*
|
||||
* @param string $query
|
||||
* @param int $bufferMode PMA_Drizzle::BUFFER_RESULT, PMA_Drizzle::BUFFER_ROW
|
||||
* @param int $fetchMode PMA_Drizzle::FETCH_ASSOC, PMA_Drizzle::FETCH_NUM or PMA_Drizzle::FETCH_BOTH
|
||||
* @param int $bufferMode PMA_Drizzle::BUFFER_RESULT,PMA_Drizzle::BUFFER_ROW
|
||||
* @param int $fetchMode PMA_Drizzle::FETCH_ASSOC, PMA_Drizzle::FETCH_NUM
|
||||
* or PMA_Drizzle::FETCH_BOTH
|
||||
*
|
||||
* @return PMA_DrizzleResult
|
||||
*/
|
||||
public function query($query, $bufferMode = PMA_Drizzle::BUFFER_RESULT, $fetchMode = PMA_Drizzle::FETCH_ASSOC)
|
||||
{_dlog();
|
||||
public function query($query, $bufferMode = PMA_Drizzle::BUFFER_RESULT,
|
||||
$fetchMode = PMA_Drizzle::FETCH_ASSOC
|
||||
) {
|
||||
_dlog();
|
||||
$result = $this->dcon->query($query);
|
||||
if ($result instanceof DrizzleResult) {
|
||||
_dlog(true);
|
||||
$this->lastResult = new PMA_DrizzleResult($result, $bufferMode, $fetchMode);
|
||||
_dlog(true);
|
||||
$this->lastResult = new PMA_DrizzleResult(
|
||||
$result, $bufferMode, $fetchMode
|
||||
);
|
||||
return $this->lastResult;
|
||||
}
|
||||
return $result;
|
||||
@ -225,7 +236,8 @@ class PMA_DrizzleCon
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
return call_user_func_array(array($this->dcon, $method), $args);
|
||||
}
|
||||
|
||||
@ -235,7 +247,8 @@ class PMA_DrizzleCon
|
||||
* @return DrizzleCon
|
||||
*/
|
||||
public function getConnectionObject()
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
return $this->dcon;
|
||||
}
|
||||
}
|
||||
@ -285,7 +298,8 @@ class PMA_DrizzleResult
|
||||
* @param int $fetchMode
|
||||
*/
|
||||
public function __construct(DrizzleResult $dresult, $bufferMode, $fetchMode)
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
$this->dresult = $dresult;
|
||||
$this->bufferMode = $bufferMode;
|
||||
$this->fetchMode = $fetchMode;
|
||||
@ -301,15 +315,18 @@ class PMA_DrizzleResult
|
||||
* @param int $fetchMode
|
||||
*/
|
||||
public function setFetchMode($fetchMode)
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
$this->fetchMode = $fetchMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads information about columns contained in current result set into {@see $columns} and {@see $columnNames} arrays
|
||||
* Reads information about columns contained in current result
|
||||
* set into {@see $columns} and {@see $columnNames} arrays
|
||||
*/
|
||||
private function _readColumns()
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
$this->columns = array();
|
||||
$this->columnNames = array();
|
||||
if ($this->bufferMode == PMA_Drizzle::BUFFER_RESULT) {
|
||||
@ -331,7 +348,8 @@ class PMA_DrizzleResult
|
||||
* @return DrizzleColumn[]
|
||||
*/
|
||||
public function getColumns()
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
if (!$this->columns) {
|
||||
$this->_readColumns();
|
||||
}
|
||||
@ -344,7 +362,8 @@ class PMA_DrizzleResult
|
||||
* @return int
|
||||
*/
|
||||
public function numColumns()
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
return $this->dresult->columnCount();
|
||||
}
|
||||
|
||||
@ -361,30 +380,32 @@ class PMA_DrizzleResult
|
||||
}
|
||||
|
||||
switch ($fetchMode) {
|
||||
case PMA_Drizzle::FETCH_ASSOC:
|
||||
$row = array_combine($this->columnNames, $row);
|
||||
break;
|
||||
case PMA_Drizzle::FETCH_BOTH:
|
||||
$length = count($row);
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$row[$this->columnNames[$i]] = $row[$i];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case PMA_Drizzle::FETCH_ASSOC:
|
||||
$row = array_combine($this->columnNames, $row);
|
||||
break;
|
||||
case PMA_Drizzle::FETCH_BOTH:
|
||||
$length = count($row);
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$row[$this->columnNames[$i]] = $row[$i];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches next for from this result set
|
||||
*
|
||||
* @param int $fetchMode fetch mode to use, if none given the default one is used
|
||||
* @param int $fetchMode fetch mode to use, if not given the default one is used
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function fetchRow($fetchMode = null)
|
||||
{_dlog();
|
||||
// read column names on first fetch, only buffered results allow for reading it later
|
||||
{
|
||||
_dlog();
|
||||
// read column names on first fetch, only buffered results
|
||||
// allow for reading it later
|
||||
if (!$this->columns) {
|
||||
$this->_readColumns();
|
||||
}
|
||||
@ -393,12 +414,12 @@ class PMA_DrizzleResult
|
||||
}
|
||||
$row = null;
|
||||
switch ($this->bufferMode) {
|
||||
case PMA_Drizzle::BUFFER_RESULT:
|
||||
$row = $this->dresult->rowNext();
|
||||
break;
|
||||
case PMA_Drizzle::BUFFER_ROW:
|
||||
$row = $this->dresult->rowBuffer();
|
||||
break;
|
||||
case PMA_Drizzle::BUFFER_RESULT:
|
||||
$row = $this->dresult->rowNext();
|
||||
break;
|
||||
case PMA_Drizzle::BUFFER_ROW:
|
||||
$row = $this->dresult->rowBuffer();
|
||||
break;
|
||||
}
|
||||
$this->_transformResultRow($row, $fetchMode);
|
||||
return $row;
|
||||
@ -412,9 +433,12 @@ class PMA_DrizzleResult
|
||||
* @return bool
|
||||
*/
|
||||
public function seek($row_index)
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
if ($this->bufferMode != PMA_Drizzle::BUFFER_RESULT) {
|
||||
trigger_error("Can't seek in an unbuffered result set", E_USER_WARNING);
|
||||
trigger_error(
|
||||
__("Can't seek in an unbuffered result set"), E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// rowSeek always returns NULL (drizzle extension v.0.5, API v.7)
|
||||
@ -431,9 +455,12 @@ class PMA_DrizzleResult
|
||||
* @return int|false
|
||||
*/
|
||||
public function numRows()
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
if ($this->bufferMode != PMA_Drizzle::BUFFER_RESULT) {
|
||||
trigger_error("Can't count rows in an unbuffered result set", E_USER_WARNING);
|
||||
trigger_error(
|
||||
__("Can't count rows in an unbuffered result set"), E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return $this->dresult->rowCount();
|
||||
@ -445,7 +472,8 @@ class PMA_DrizzleResult
|
||||
* @return int|false
|
||||
*/
|
||||
public function affectedRows()
|
||||
{_dlog();
|
||||
{
|
||||
_dlog();
|
||||
return $this->dresult->affectedRows();
|
||||
}
|
||||
|
||||
|
||||
@ -3,10 +3,13 @@
|
||||
/**
|
||||
* Interface to the Drizzle extension
|
||||
*
|
||||
* WARNING - EXPERIMENTAL, never use in production, drizzle module segfaults often and when you least expect it to
|
||||
* WARNING - EXPERIMENTAL, never use in production,
|
||||
* drizzle module segfaults often and when you least expect it to
|
||||
*
|
||||
* TODO: This file and drizzle-wrappers.lib.php should be devoid of any segault related hacks.
|
||||
* TODO: Crashing versions of drizzle module and/or libdrizzle should be blacklisted
|
||||
* TODO: This file and drizzle-wrappers.lib.php should be devoid
|
||||
* of any segault related hacks.
|
||||
* TODO: Crashing versions of drizzle module and/or libdrizzle
|
||||
* should be blacklisted
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage Drizzle
|
||||
@ -39,8 +42,9 @@ if (!defined('PMA_MYSQL_CLIENT_API')) {
|
||||
*
|
||||
* @return PMA_DrizzleCon
|
||||
*/
|
||||
function PMA_DBI_real_connect($drizzle, $host, $port, $uds, $user, $password, $db = null, $options = DRIZZLE_CON_NONE)
|
||||
{
|
||||
function PMA_DBI_real_connect($drizzle, $host, $port, $uds, $user, $password,
|
||||
$db = null, $options = DRIZZLE_CON_NONE
|
||||
) {
|
||||
if ($uds) {
|
||||
$con = $drizzle->addUds($uds, $user, $password, $db, $options);
|
||||
} else {
|
||||
@ -57,12 +61,14 @@ function PMA_DBI_real_connect($drizzle, $host, $port, $uds, $user, $password, $d
|
||||
* @param string $password drizzle user password
|
||||
* @param bool $is_controluser
|
||||
* @param array $server host/port/socket
|
||||
* @param bool $auxiliary_connection (when true, don't go back to login if connection fails)
|
||||
* @param bool $auxiliary_connection when true, don't go back to
|
||||
* login if connection fails
|
||||
*
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
function PMA_DBI_connect($user, $password, $is_controluser = false, $server = null, $auxiliary_connection = false)
|
||||
{
|
||||
function PMA_DBI_connect($user, $password, $is_controluser = false,
|
||||
$server = null, $auxiliary_connection = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
if ($server) {
|
||||
@ -103,18 +109,35 @@ function PMA_DBI_connect($user, $password, $is_controluser = false, $server = nu
|
||||
}
|
||||
|
||||
if (!$server) {
|
||||
$link = @PMA_DBI_real_connect($drizzle, $cfg['Server']['host'], $server_port, $server_socket, $user, $password, false, $client_flags);
|
||||
$link = @PMA_DBI_real_connect(
|
||||
$drizzle, $cfg['Server']['host'], $server_port, $server_socket, $user,
|
||||
$password, false, $client_flags
|
||||
);
|
||||
// Retry with empty password if we're allowed to
|
||||
if ($link == false && isset($cfg['Server']['nopassword']) && $cfg['Server']['nopassword'] && !$is_controluser) {
|
||||
$link = @PMA_DBI_real_connect($drizzle, $cfg['Server']['host'], $server_port, $server_socket, $user, null, false, $client_flags);
|
||||
if ($link == false && isset($cfg['Server']['nopassword'])
|
||||
&& $cfg['Server']['nopassword'] && !$is_controluser
|
||||
) {
|
||||
$link = @PMA_DBI_real_connect(
|
||||
$drizzle, $cfg['Server']['host'], $server_port, $server_socket,
|
||||
$user, null, false, $client_flags
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$link = @PMA_DBI_real_connect($drizzle, $server['host'], $server_port, $server_socket, $user, $password);
|
||||
$link = @PMA_DBI_real_connect(
|
||||
$drizzle, $server['host'], $server_port, $server_socket,
|
||||
$user, $password
|
||||
);
|
||||
}
|
||||
|
||||
if ($link == false) {
|
||||
if ($is_controluser) {
|
||||
trigger_error(__('Connection for controluser as defined in your configuration failed.'), E_USER_WARNING);
|
||||
trigger_error(
|
||||
__(
|
||||
'Connection for controluser as defined'
|
||||
. ' in your configuration failed.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// we could be calling PMA_DBI_connect() to connect to another
|
||||
@ -333,8 +356,8 @@ function PMA_DBI_getError($link = null)
|
||||
$link =& $GLOBALS['userlink'];
|
||||
// Do not stop now. We still can get the error code
|
||||
// with mysqli_connect_errno()
|
||||
// } else {
|
||||
// return false;
|
||||
// } else {
|
||||
// return false;
|
||||
}
|
||||
|
||||
if (null !== $link) {
|
||||
|
||||
@ -32,8 +32,9 @@ if (! defined('PMA_MYSQL_CLIENT_API')) {
|
||||
*
|
||||
* @return mixed false on error or a mysql connection resource on success
|
||||
*/
|
||||
function PMA_DBI_real_connect($server, $user, $password, $client_flags, $persistent = false)
|
||||
{
|
||||
function PMA_DBI_real_connect($server, $user, $password, $client_flags,
|
||||
$persistent = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
if (empty($client_flags)) {
|
||||
@ -120,22 +121,37 @@ function PMA_DBI_connect($user, $password, $is_controluser = false, $server = nu
|
||||
}
|
||||
|
||||
if (!$server) {
|
||||
$link = PMA_DBI_real_connect($cfg['Server']['host'] . $server_port . $server_socket, $user, $password, empty($client_flags) ? null : $client_flags);
|
||||
$link = PMA_DBI_real_connect(
|
||||
$cfg['Server']['host'] . $server_port . $server_socket,
|
||||
$user, $password, empty($client_flags) ? null : $client_flags
|
||||
);
|
||||
|
||||
// Retry with empty password if we're allowed to
|
||||
// Retry with empty password if we're allowed to
|
||||
if (empty($link) && $cfg['Server']['nopassword'] && !$is_controluser) {
|
||||
$link = PMA_DBI_real_connect($cfg['Server']['host'] . $server_port . $server_socket, $user, '', empty($client_flags) ? null : $client_flags);
|
||||
$link = PMA_DBI_real_connect(
|
||||
$cfg['Server']['host'] . $server_port . $server_socket,
|
||||
$user, '', empty($client_flags) ? null : $client_flags
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!isset($server['host'])) {
|
||||
$link = PMA_DBI_real_connect($server_socket, $user, $password, null);
|
||||
} else {
|
||||
$link = PMA_DBI_real_connect($server['host'] . $server_port . $server_socket, $user, $password, null);
|
||||
$link = PMA_DBI_real_connect(
|
||||
$server['host'] . $server_port . $server_socket,
|
||||
$user, $password, null
|
||||
);
|
||||
}
|
||||
}
|
||||
if (empty($link)) {
|
||||
if ($is_controluser) {
|
||||
trigger_error(__('Connection for controluser as defined in your configuration failed.'), E_USER_WARNING);
|
||||
trigger_error(
|
||||
__(
|
||||
'Connection for controluser as defined'
|
||||
. ' in your configuration failed.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// we could be calling PMA_DBI_connect() to connect to another
|
||||
@ -351,10 +367,10 @@ function PMA_DBI_getError($link = null)
|
||||
if (null === $link && isset($GLOBALS['userlink'])) {
|
||||
$link =& $GLOBALS['userlink'];
|
||||
|
||||
// Do not stop now. On the initial connection, we don't have a $link,
|
||||
// we don't have a $GLOBALS['userlink'], but we can catch the error code
|
||||
// } else {
|
||||
// return false;
|
||||
// Do not stop now. On the initial connection, we don't have a $link,
|
||||
// we don't have a $GLOBALS['userlink'], but we can catch the error code
|
||||
// } else {
|
||||
// return false;
|
||||
}
|
||||
|
||||
if (null !== $link && false !== $link) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user