mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing issue where errors containing code = 500, were not actually converted to error500 when debug = 0. Making missingConnection, and missingTable into error500 errors.
This commit is contained in:
parent
b491414a51
commit
c60edfae6d
4 changed files with 24 additions and 4 deletions
|
@ -106,6 +106,7 @@ class ErrorHandler extends Object {
|
||||||
if (!in_array(strtolower($method), array_map('strtolower', get_class_methods($this)))) {
|
if (!in_array(strtolower($method), array_map('strtolower', get_class_methods($this)))) {
|
||||||
$method = 'error';
|
$method = 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($method !== 'error') {
|
if ($method !== 'error') {
|
||||||
if (Configure::read('debug') == 0) {
|
if (Configure::read('debug') == 0) {
|
||||||
$parentClass = get_parent_class($this);
|
$parentClass = get_parent_class($this);
|
||||||
|
@ -116,7 +117,7 @@ class ErrorHandler extends Object {
|
||||||
if (in_array(strtolower($method), $parentMethods)) {
|
if (in_array(strtolower($method), $parentMethods)) {
|
||||||
$method = 'error404';
|
$method = 'error404';
|
||||||
}
|
}
|
||||||
if (isset($code) && $code == 500) {
|
if (isset($messages[0]['code']) && $messages[0]['code'] == 500) {
|
||||||
$method = 'error500';
|
$method = 'error500';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ class ConnectionManager extends Object {
|
||||||
$this->_connectionsEnum[$name] = $this->__connectionData($config);
|
$this->_connectionsEnum[$name] = $this->__connectionData($config);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->cakeError('missingConnection', array(array('className' => 'ConnectionManager')));
|
$this->cakeError('missingConnection', array(array('code' => 500, 'className' => 'ConnectionManager')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -769,7 +769,8 @@ class Model extends Overloadable {
|
||||||
if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) {
|
if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) {
|
||||||
return $this->cakeError('missingTable', array(array(
|
return $this->cakeError('missingTable', array(array(
|
||||||
'className' => $this->alias,
|
'className' => $this->alias,
|
||||||
'table' => $this->tablePrefix . $tableName
|
'table' => $this->tablePrefix . $tableName,
|
||||||
|
'code' => 500
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
$this->_schema = null;
|
$this->_schema = null;
|
||||||
|
@ -2826,7 +2827,7 @@ class Model extends Overloadable {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($db) || !is_object($db)) {
|
if (empty($db) || !is_object($db)) {
|
||||||
return $this->cakeError('missingConnection', array(array('className' => $this->alias)));
|
return $this->cakeError('missingConnection', array(array('code' => 500, 'className' => $this->alias)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -609,4 +609,22 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
$this->assertPattern('/<em>Article<\/em> could not be found./', $result);
|
$this->assertPattern('/<em>Article<\/em> could not be found./', $result);
|
||||||
$this->assertPattern('/(\/|\\\)article.php/', $result);
|
$this->assertPattern('/(\/|\\\)article.php/', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testing that having a code => 500 in the cakeError call makes an
|
||||||
|
* internal server error.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testThatCode500Works() {
|
||||||
|
Configure::write('debug', 0);
|
||||||
|
ob_start();
|
||||||
|
$TestErrorHandler = new TestErrorHandler('missingTable', array(
|
||||||
|
'className' => 'Article',
|
||||||
|
'table' => 'articles',
|
||||||
|
'code' => 500
|
||||||
|
));
|
||||||
|
$result = ob_get_clean();
|
||||||
|
$this->assertPattern('/<h2>An Internal Error Has Occurred<\/h2>/', $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue