Commit 8b988540 authored by alexpott's avatar alexpott

Issue #2451085 by dawehner, Arla: _drupal_log_error() passes NULL to...

Issue #2451085 by dawehner, Arla: _drupal_log_error() passes NULL to ThemeManager::setActiveTheme(), violating its typehint
parent 86977a15
......@@ -125,7 +125,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
// The installer initializes a maintenance theme at the earliest possible
// point in time already. Do not unset that.
if (!$is_installer) {
\Drupal::theme()->setActiveTheme(NULL);
\Drupal::theme()->resetActiveTheme();
}
if (!defined('MAINTENANCE_MODE')) {
define('MAINTENANCE_MODE', 'error');
......
......@@ -352,10 +352,13 @@ protected function checkRequirements() {
* Keyed array representing an assertion, as generated by assert().
*
* @see self::assert()
*
* @return \Drupal\Core\Database\StatementInterface|int|null
* The message ID.
*/
protected function storeAssertion(array $assertion) {
return self::getDatabaseConnection()
->insert('simpletest')
->insert('simpletest', ['return' => Database::RETURN_INSERT_ID])
->fields($assertion)
->execute();
}
......@@ -398,7 +401,7 @@ protected function assert($status, $message = '', $group = 'Other', array $calle
}
// Creation assertion array that can be displayed while tests are running.
$this->assertions[] = $assertion = array(
$assertion = array(
'test_id' => $this->testId,
'test_class' => get_class($this),
'status' => $status,
......@@ -410,7 +413,9 @@ protected function assert($status, $message = '', $group = 'Other', array $calle
);
// Store assertion for display after the test has completed.
$this->storeAssertion($assertion);
$message_id = $this->storeAssertion($assertion);
$assertion['message_id'] = $message_id;
$this->assertions[] = $assertion;
// We do not use a ternary operator here to allow a breakpoint on
// test failure.
......
......@@ -46,6 +46,11 @@ function testErrorHandler() {
'%function' => 'Drupal\error_test\Controller\ErrorTestController->generateWarnings()',
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
);
$fatal_error = array(
'%type' => 'Recoverable fatal error',
'%function' => 'Drupal\error_test\Controller\ErrorTestController->Drupal\error_test\Controller\{closure}()',
'!message' => 'Argument 1 passed to Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}() must be of the type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 66 and defined',
);
// Set error reporting to display verbose notices.
$this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
......@@ -56,6 +61,24 @@ function testErrorHandler() {
$this->assertErrorMessage($error_user_notice);
$this->assertRaw('<pre class="backtrace">', 'Found pre element with backtrace class.');
// Set error reporting to display verbose notices.
$this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
$this->drupalGet('error-test/generate-fatals');
$this->assertResponse(500, 'Received expected HTTP status code.');
$this->assertErrorMessage($fatal_error);
$this->assertRaw('<pre class="backtrace">', 'Found pre element with backtrace class.');
// Remove the fatal error from the assertions, its wanted here. Ensure
// that we just remove the one recoverable fatal error.
foreach ($this->assertions as $key => $assertion) {
if ($assertion['message_group'] == 'Recoverable fatal error' && strpos($assertion['message'], 'Argument 1 passed to Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}() must be of the type array, string given, called in') !== FALSE) {
unset($this->assertions[$key]);
$this->deleteAssert($assertion['message_id']);
}
}
// Drop the single exception.
$this->results['#exception']--;
// Set error reporting to collect notices.
$config->set('error_level', ERROR_REPORTING_DISPLAY_ALL)->save();
$this->drupalGet('error-test/generate-warnings');
......
......@@ -5,6 +5,13 @@ error_test.generate_warnings:
requirements:
_access: 'TRUE'
error_test.generate_fatals:
path: '/error-test/generate-fatals'
defaults:
_controller: '\Drupal\error_test\Controller\ErrorTestController::generateFatals'
requirements:
_access: 'TRUE'
error_test.generate_warnings_with_report:
path: '/error-test/generate-warnings-with-report'
defaults:
......
......@@ -56,6 +56,17 @@ public function generateWarnings($collect_errors = FALSE) {
return [];
}
/**
* Generate fatals to test the error handler.
*/
public function generateFatals() {
$function = function(array $test) {
};
$function("test-string");
return [];
}
/**
* Trigger an exception to test the exception handler.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment