Unverified Commit 06d496f7 authored by alexpott's avatar alexpott
Browse files

Issue #3109097 by voleger, longwave: Drupal 9 does not handle db_* functions any more

parent fc46c7f3
......@@ -140,9 +140,6 @@ protected function createTableSql($name, $table) {
/**
* Create an SQL string for a field to be used in table creation or alteration.
*
* Before passing a field out of a schema definition into this function it has
* to be processed by _db_process_field().
*
* @param string $name
* Name of the field.
* @param array $spec
......
......@@ -318,9 +318,6 @@ protected function createTableSql($name, $table) {
* Create an SQL string for a field to be used in table creation or
* alteration.
*
* Before passing a field out of a schema definition into this
* function it has to be processed by _db_process_field().
*
* @param $name
* Name of the field.
* @param $spec
......
......@@ -125,11 +125,10 @@ public function log(StatementInterface $statement, $args, $time) {
* Determine the routine that called this query.
*
* We define "the routine that called this query" as the first entry in
* the call stack that is not inside the includes/Drupal/Database directory,
* does not begin with db_ and does have a file (which excludes
* call_user_func_array(), anonymous functions and similar). That makes the
* climbing logic very simple, and handles the variable stack depth caused by
* the query builders.
* the call stack that is not inside the includes/Drupal/Database directory
* and does have a file (which excludes call_user_func_array(), anonymous
* functions and similar). That makes the climbing logic very simple, and
* handles the variable stack depth caused by the query builders.
*
* See the @link http://php.net/debug_backtrace debug_backtrace() @endlink
* function.
......@@ -150,7 +149,7 @@ public function findCaller() {
if (empty($stack[$i + 1]['class'])) {
$stack[$i + 1]['class'] = '';
}
if (strpos($stack[$i + 1]['class'], __NAMESPACE__) === FALSE && strpos($stack[$i + 1]['function'], 'db_') === FALSE && !empty($stack[$i]['file'])) {
if (strpos($stack[$i + 1]['class'], __NAMESPACE__) === FALSE && !empty($stack[$i]['file'])) {
$stack[$i] += ['file' => '?', 'line' => '?', 'args' => []];
return [
'file' => $stack[$i]['file'],
......
......@@ -32,7 +32,7 @@ interface PagerManagerInterface {
* you can extend the query object with the 'PagerSelectExtender' extender
* before executing it. For example:
* @code
* $query = db_select('some_table')
* $query = $connection->select('some_table')
* ->extend('Drupal\Core\Database\Query\PagerSelectExtender');
* @endcode
*
......
......@@ -46,11 +46,10 @@ public static function decodeException($exception) {
if ($exception instanceof \PDOException || $exception instanceof DatabaseExceptionWrapper) {
// The first element in the stack is the call, the second element gives us
// the caller. We skip calls that occurred in one of the classes of the
// database layer or in one of its global functions.
$db_functions = ['db_query', 'db_query_range'];
// database layer.
while (!empty($backtrace[1]) && ($caller = $backtrace[1]) &&
((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE)) ||
in_array($caller['function'], $db_functions))) {
((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE))
)) {
// We remove that call.
array_shift($backtrace);
}
......
......@@ -205,7 +205,7 @@ public function testNodeAccessLanguageAware() {
// - Node with both translations public.
// - Node with only the Catalan translation marked as private.
// - No language node marked as public.
$this->assertEqual(count($nids), 3, 'db_select() returns 3 nodes when no langcode is specified.');
$this->assertEqual(count($nids), 3, '$connection->select() returns 3 nodes when no langcode is specified.');
$this->assertTrue(array_key_exists($this->nodes['both_public']->id(), $nids), 'The node with both translations public is returned.');
$this->assertTrue(array_key_exists($this->nodes['ca_private']->id(), $nids), 'The node with only the Catalan translation private is returned.');
$this->assertTrue(array_key_exists($this->nodes['no_language_public']->id(), $nids), 'The node with no language is returned.');
......
......@@ -1296,7 +1296,6 @@ public function query($get_count = FALSE) {
}
// Go ahead and build the query.
// db_select doesn't support to specify the key, so use getConnection directly.
$query = Database::getConnection($target, $key)
->select($this->view->storage->get('base_table'), $this->view->storage->get('base_table'), $options)
->addTag('views')
......
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