Assert in setPrefix should include the argument type if not a string

Created on 19 September 2023, over 1 year ago
Updated 4 March 2024, 10 months ago

Problem/Motivation

The class web/core/lib/Drupal/Core/Database/Connection.php at method setPrefix($prefix) at first validate if the $prefix is a string. However at time to show the issue message, assumes that is a string

protected function setPrefix($prefix) {
    assert(is_string($prefix), 'The \'$prefix\' argument to ' . __METHOD__ . '() must be a string');
    $this->prefix = $prefix;
    $this->tablePlaceholderReplacements = [
      $this->identifierQuotes[0] . str_replace('.', $this->identifierQuotes[1] . '.' . $this->identifierQuotes[0], $prefix),
      $this->identifierQuotes[1],
    ];
  }

Steps to reproduce

I got this issue at time to deploy a project:

AssertionError: The '$prefix' argument to Drupal\Core\Database\Connection::setPrefix() must be a string in assert() (line 375 of ... /releases/20230915130755Z/web/core/lib/Drupal/Core/Database/Connnection.php).

Proposed resolution

Show the issue message as string.

📌 Task
Status

Closed: won't fix

Version

11.0 🔥

Component
Database 

Last updated 7 days ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇧🇴Bolivia vacho Cochabamba

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024