Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Connection.php

function Connection::removeDatabaseEntriesFromDebugBacktrace

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 Connection::removeDatabaseEntriesFromDebugBacktrace()
Connection::findCallerFromDebugBacktrace in core/lib/Drupal/Core/Database/Connection.php
Determine the last non-database method that called the database API.
Error::decodeException in core/lib/Drupal/Core/Utility/Error.php
Decodes an exception and retrieves the correct caller.

File

core/lib/Drupal/Core/Database/Connection.php, line 1584

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public static function removeDatabaseEntriesFromDebugBacktrace(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 (str_starts_with($class, __NAMESPACE__) || str_starts_with($class, $driver_namespace)) {
            break;
        }
    }
    return array_values(array_slice($backtrace, $n));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal