Merge remote-tracking branch 'origin/QA_4_6' into QA_4_6

This commit is contained in:
Weblate 2016-09-02 14:41:00 +02:00
commit 2e58cf0105
4 changed files with 42 additions and 15 deletions

View File

@ -2351,21 +2351,12 @@ class DatabaseInterface
$user, $password, $is_controluser = false, $server = null,
$auxiliary_connection = false
) {
$error_count = $GLOBALS['error_handler']->countErrors();
// Do not show location and backtrace for connection errors
$GLOBALS['error_handler']->setHideLocation(true);
$result = $this->_extension->connect(
$user, $password, $is_controluser, $server, $auxiliary_connection
);
/* Any errors from connection? */
if ($GLOBALS['error_handler']->countErrors() > $error_count) {
$errors = $GLOBALS['error_handler']->sliceErrors($error_count);
foreach ($errors as $error) {
trigger_error(
$error->getMessage(),
E_USER_ERROR
);
}
}
$GLOBALS['error_handler']->setHideLocation(false);
if ($result) {
if (! $auxiliary_connection && ! $is_controluser) {

View File

@ -83,6 +83,11 @@ class Error extends Message
*/
protected $backtrace = array();
/**
* Hide location of errors
*/
protected $hide_location = false;
/**
* Constructor
*
@ -146,6 +151,18 @@ class Error extends Message
return $result;
}
/**
* Toggles location hiding
*
* @param boolean $hide Whether to hide
*
* @return void
*/
public function setHideLocation($hide)
{
$this->hide_location = $hide;
}
/**
* sets PMA\libraries\Error::$_backtrace
*
@ -441,7 +458,8 @@ class Error extends Message
*/
public function isUserError()
{
return $this->getNumber() & (E_USER_WARNING | E_USER_ERROR | E_USER_NOTICE);
return $this->hide_location ||
($this->getNumber() & (E_USER_WARNING | E_USER_ERROR | E_USER_NOTICE));
}
/**

View File

@ -23,6 +23,11 @@ class ErrorHandler
*/
protected $errors = array();
/**
* Hide location of errors
*/
protected $hide_location = false;
/**
* Constructor - set PHP error handler
*
@ -77,6 +82,18 @@ class ErrorHandler
}
}
/**
* Toggles location hiding
*
* @param boolean $hide Whether to hide
*
* @return void
*/
public function setHideLocation($hide)
{
$this->hide_location = $hide;
}
/**
* returns array with all errors
*
@ -170,6 +187,7 @@ class ErrorHandler
$errfile,
$errline
);
$error->setHideLocation($this->hide_location);
// do not repeat errors
$this->errors[$error->getHash()] = $error;

View File

@ -86,9 +86,9 @@ function PMA_sessionFailed($errors)
* will not change in future.
*/
$messages[] = preg_replace(
'/open(.*, O_RDWR)/',
'/open\(.*, O_RDWR\)/',
'open(SESSION_FILE, O_RDWR)',
$error->getMessage()
htmlspecialchars($error->getMessage())
);
}