Problem/Motivation
We now have the method Drupal\Core\Database\Connection::prefixTable($table) which returns the prefix for the table. In D9 and before there was the possibility to have different prefixes for different tables. In D10 there is only a single prefix for all tables. The method and its parameter suggest that it is still possible to have per table prefixing. This does not improve the developer experience.
Proposed resolution
Deprecate method Drupal\Core\Database\Connection::prefixTable($table) and create the new method method Drupal\Core\Database\Connection::getPrefix(). The new method has no parameters. It just return the class variable $prefix.
Remaining tasks
TBD
User interface changes
None
API changes
See propesed solution.
Data model changes
None
Release notes snippet
TBD
Issue fork drupal-3257201
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
Comment #2
daffie commentedThis issue is postponed on #3124382: Remove per-table prefixing.
Comment #3
mondrakeComment #4
elberComment #5
elberComment #6
beatrizrodriguesI'll work on that.
Comment #8
beatrizrodriguesI applied the proposed solution and created the change record too. I hope everything is correct.
Comment #9
daffie commentedBack to needs work for the unresolved threads.
Comment #10
mondrakeNeed to wait for #3124382: Remove per-table prefixing
Comment #11
daffie commented#3124382: Remove per-table prefixing has landed.
Comment #14
murilohp commentedComment #15
murilohp commentedHey everyone! I had to rebase the branch with D10 branch, I also fixed some stuff, thank you for the commits @beatrizrodrigues and @ravi.shankar, you've helped a lot!
@daffie, it would be nice to have your thoughts here again.
Thanks!
Comment #16
daffie commentedThe MR looks good to me.
The old method is deprecated with a deprecation message test.
The IS and the CR are in order.
For me it is RTBC.
Comment #17
catchIn general we're only adding deprecations in Drupal 10 for removal in Drupal 11 if it's necessary to fix Drupal 10-blocking issues. Most general clean-up type changes would get deferred to 10.1.x at this point. This is because phpstan will warn people about all deprecations regardless of versions, but if replacements aren't in 9.x, then they can't be resolved without breaking Drupal 9 compatibility.
Could we not add the method to 9.4.x with a deprecation for Drupal 10? Even if the method only works for single table prefixes in 9.4 this might be fine - but I did not properly review the issue yet, so apologies if this has been asked and answered already.
Comment #18
catchMoving to 10.1.x since this has missed 9.4.x, MR needs an update to change the deprecation message.
Comment #19
ravi.shankar commentedMade changes as per comment #18, please review.
Comment #20
daffie commentedAll usage of the old method has been replaced by the new method.
A deprecation message and test has been added to the MR.
I have updated the CR.
For me it is RTBC.
Comment #21
mondrakeCouple of comments on the MR - not sure they warrant un-RTBCing
Comment #23
catchCommitted 20e4bae and pushed to 10.1.x. Thanks!
Comment #24
mondrakeSetting @internal has not to do with the visibility, the method itself must remain public. The usage of the method in migrate is borderline - it seems to me is more to circumvent a shortcoming in the DB API (unable to process identifiers longer than 63 chars in PgSQL) than anything else.
We are discussing to make DB API methods @internal for usage within db drivers here #3118629: Add @internal to public database API methods where appropriate and here #3281962: Add @internal to Database API methods that should only be called by driver code, will add this one there.
Comment #26
quietone commentedUpdated and published the change record.