Problem/Motivation

In #3106531: Notify in Status Report that per-table database prefixes are no longer supported, and will throw errors in Drupal 10.0 we deprecated per-table prefixing and the 'prefix' connection array key in array form.

The per-table prefixing needs to be removed in D10.

Proposed resolution

  • Deprecated for removal in D11 the class variables (all protected): Drupal\Core\Database\Connection::$prefixes, Drupal\Core\Database\Connection::$prefixSearch, Drupal\Core\Database\Connection::$prefixReplace and Drupal\Core\Database\Connection::$unprefixedTablesMap.
  • Deprecated for removal in D11 the method Drupal\Core\Database\Connection::getUnprefixedTablesMap()
  • Added the class variables (private): Drupal\Core\Database\Connection::$prefix and Drupal\Core\Database\Connection::$tablePlaceholderReplacements.
  • ::setPrefix() now accepts only strings.

Remaining tasks

User interface changes

API changes

See proposed solution.

Data model changes

Release notes snippet

Drupal previously supported per-table prefixing for complex multisite setups. This functionality has been deprecated since Drupal 8.2, and warnings are displayed on the status reports of sites stil using this functionality since Drupal 9.3.0. The functionality has been removed from Drupal 10. See the change record for alternatives to per-table prefixing.

Issue fork drupal-3124382

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mondrake created an issue. See original summary.

daffie’s picture

Issue summary: View changes
mondrake’s picture

StatusFileSize
new2.99 KB

Just a curiosity to see what breaks.

mondrake’s picture

StatusFileSize
new7.98 KB
mondrake’s picture

StatusFileSize
new15.35 KB
mondrake’s picture

StatusFileSize
new14.37 KB
mondrake’s picture

mondrake’s picture

Title: Remove per-table prefixing » [PP-1] Remove per-table prefixing

mondrake’s picture

Title: [PP-1] Remove per-table prefixing » Remove per-table prefixing
Status: Postponed » Needs review
mondrake’s picture

Issue summary: View changes
daffie’s picture

Status: Needs review » Needs work

In the method Drupal\pgsql\Driver\Database\pgsql\Schema::findTables() is the deprecated method getUnprefixedTablesMap() called.

Patch looks good.

mondrake’s picture

Status: Needs work » Needs review

Thanks @daffie

daffie’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record

The MR is for me RTBC.

I will work on the CR tomorrow.

daffie’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record

All code changes look good to me.
The IS and the CR are in order.
For me it is RTBC.

mondrake’s picture

Status: Reviewed & tested by the community » Needs work

we need to update the MR with the actual number of the CR

mondrake’s picture

Status: Needs work » Needs review
daffie’s picture

Status: Needs review » Reviewed & tested by the community

we need to update the MR with the actual number of the CR

Oeps!

It is fixed.
Back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I think the change as it current is results in an change in the output of function unexpectedly.

mondrake’s picture

Status: Needs work » Reviewed & tested by the community

That code comes straight from D8 https://git.drupalcode.org/project/drupal/-/blob/8.9.x/core/lib/Drupal/C...

Doing some archeocodololgy, AFAICS the idea was to convert the 'prefix' element (that was an array there) to a list of tables that had a different prefix than the default -- $table_name as a variable name is not a very happy one, it's the key of the 'prefix' array.

In other words, a 'prefix' array like

[
  'default' => 'bar_',
  'users' => 'foo_',
  'node => 'qux_',
]

would result in ::getUnprefixedTablesMap() returning

[
  'foo_users' => 'users',
  'qux_node => 'node',
]

Since we no longer have per-table prefixes as a result of this patch, ::getUnprefixedTablesMap() would return an empty array which is correct IMHO.

catch’s picture

Status: Reviewed & tested by the community » Needs review

Couple of questions on the MR.

mondrake’s picture

Thanks @catch, addressed your points.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Both points of @catch have been addressed.

The "extra_prefix" stuff from the SQLite database driver makes it for me that we can only do this in D10 and remove it in D11. Just a lot cleaner and it is not in the way.

  • catch committed e1c6ba3 on 10.0.x
    Issue #3124382 by mondrake, daffie, alexpott, catch: Remove per-table...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed e1c6ba3 and pushed to 10.0.x. Thanks!

mondrake’s picture

Published CR

xjm’s picture

I went ahead and attached the original CR to this issue (from all the way back in Drupal 8.2): https://www.drupal.org/node/2768219

I'm confused though. The IS says:

The functionality needs to be removed in D10.

But then it goes onto say a bunch of stuff is deprecated for removal in D11, and the patch is adding deprecations for D11 removal as well, not removing any existing deprecations.

I would've expected this issue to wait for 10.1.x. Do we need to mention it in the release notes? Or does the followup to actually remove the feature get mentioned in the 11.0.0 release notes?

daffie’s picture

Issue summary: View changes

@xjm: The per-table prefixing is removed in D10. A number of class variables and method are deprecated in D10.0 and will be removed in D11.0.

xjm’s picture

Issue tags: +10.0.0 release notes

OK, let's put this in the release notes then since this would blow your site up if you missed it. Thanks!

xjm’s picture

Issue summary: View changes

Adding a release note.

xjm’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.