function Log::removeDatabaseEntries

Same name in other branches
  1. 10 core/lib/Drupal/Core/Database/Log.php \Drupal\Core\Database\Log::removeDatabaseEntries()

Removes database related calls from a backtrace array.

Parameters

array $backtrace: A standard PHP backtrace. Passed by reference.

string $driver_namespace: The PHP namespace of the database driver.

Return value

array The cleaned backtrace array.

2 calls to Log::removeDatabaseEntries()
Error::decodeException in core/lib/Drupal/Core/Utility/Error.php
Decodes an exception and retrieves the correct caller.
Log::findCaller in core/lib/Drupal/Core/Database/Log.php
Determine the routine that called this query.

File

core/lib/Drupal/Core/Database/Log.php, line 185

Class

Log
Database query logger.

Namespace

Drupal\Core\Database

Code

public static function removeDatabaseEntries(array $backtrace, string $driver_namespace) : array {
    // Starting from the very first entry processed during the request, find
    // the first function call that can be identified as a call to a
    // method/function in the database layer.
    for ($n = count($backtrace) - 1; $n >= 0; $n--) {
        // If the call was made from a function, 'class' will be empty. We give
        // it a default empty string value in that case.
        $class = $backtrace[$n]['class'] ?? '';
        if (strpos($class, __NAMESPACE__, 0) === 0 || strpos($class, $driver_namespace, 0) === 0) {
            break;
        }
    }
    return array_values(array_slice($backtrace, $n));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.