Unverified Commit 5f61f0fb authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3151095 by dww, alexpott, jungle: Replace use of whitelist/blacklist in...

Issue #3151095 by dww, alexpott, jungle: Replace use of whitelist/blacklist in \Drupal\Core\Utility\Error and its test
parent faca9704
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -19,11 +19,11 @@ class Error {
  const ERROR = 3;

  /**
   * An array of blacklisted functions.
   * An array of ignored functions.
   *
   * @var array
   */
  protected static $blacklistFunctions = ['debug', '_drupal_error_handler', '_drupal_exception_handler'];
  protected static $ignoredFunctions = ['debug', '_drupal_error_handler', '_drupal_exception_handler'];

  /**
   * Decodes an exception and retrieves the correct caller.
@@ -110,9 +110,9 @@ public static function renderExceptionSafe($exception) {
   */
  public static function getLastCaller(array &$backtrace) {
    // Errors that occur inside PHP internal functions do not generate
    // information about file and line. Ignore black listed functions.
    // information about file and line. Ignore the ignored functions.
    while (($backtrace && !isset($backtrace[0]['line'])) ||
      (isset($backtrace[1]['function']) && in_array($backtrace[1]['function'], static::$blacklistFunctions))) {
      (isset($backtrace[1]['function']) && in_array($backtrace[1]['function'], static::$ignoredFunctions))) {
      array_shift($backtrace);
    }

+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ public function providerTestGetLastCaller() {
    $two_items[] = $this->createBacktraceItem('test_function_two', 'TestClass');
    $data[] = [$two_items, $this->createBacktraceItem('TestClass->test_function_two()')];

    // Add blacklist functions to backtrace. They should get removed.
    // Add ignored functions to backtrace. They should get removed.
    foreach (['debug', '_drupal_error_handler', '_drupal_exception_handler'] as $function) {
      $two_items = $single_item;
      // Push to the start of the backtrace.