Problem/Motivation
Mostly everything in core/database.inc is deprecated starting from 8.0 but removal of usage require to @trigger_error() with a link to change record
This is a soft blocker for #2319859: [META] Deprecate contents of database.inc to deprecate remains
Also a soft blocker for lot of issues in #2848161: [meta] Replace calls to deprecated db_*() wrappers
Also this issue may patch all the places according to current deprecation standard https://www.drupal.org/core/deprecation as pointed in #2848817: Replace all calls to db_table_exists, which is deprecated.
Also setting default target is missing at "objectified" db subsystem #2947775: Move setting default target out of db_merge() and other deprecated db_* functions - probably makes sense to mention at in separate CR
Proposed resolution
- Create change record mentioning all deprecated
db_*functions + #2286235: Deprecate db_ignore_replica() and convert it to service - Identify common pattern of message
- add regression test to
core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.phpfor each function (usegroup @legacyto annotate exception - Promote in core gdo about that all since 8.6 extra call to
trigger_error()will happen for all deprecated functions like
Remaining tasks
- decide on message for exception
- file CR draft listing functions and which of them will start throw exceptions on usage
- create patch to fix all @deprecated content in core/database.inc
User interface changes
no
API changes
no
Data model changes
no
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | interdiff-2947946-19-20.txt | 16.16 KB | voleger |
| #20 | 2947946-20.patch | 90.56 KB | voleger |
Comments
Comment #3
volegerFor the legacy tests, we use
\Drupal\KernelTests\Core\Database\DatabaseLegacyTestfor now. See #2991542: Introduce a DatabaseLegacyTest class for deprecation testingComment #4
volegerAdded initial change record for the db_* functions.
https://www.drupal.org/node/2993033
We need to mention all previously published CR related to deprecation of db_* functions.
Also, introduce examples of usage of alternative method to each function.
Comment #5
volegerComment #6
mondrakeEdited the CR with a table of deprecated->new functions and examples on how to obtain the database connection objects taken from #2991337: Document the recommended ways to obtain the database connection object.
Comment #7
volegerHere the path that fixes the related deprecation messages.
Should we change the original deprecation message for each function if any of them will contain the link to the CR?
Comment #8
mondrakeI like the idea to refer to the same issue for all the deprecated functions; however, I believe that per the Drupal core deprecation policy, we should also add a @see annotation in the PHPDoc block of all the functions, and the deprecation message in the @trigger_error should end with a '.' (full-stop).
But most important here we should finalise the CR, and I am not sure there is still consensus on the recommended way to get the database connection in the test code.
Comment #9
volegerAddressed #8, added @see annotation and fixed full stop signs.
Still blocked by #2991337: Document the recommended ways to obtain the database connection object
Comment #11
volegerRevert changes in expected deprecation message for db_set_active.
Comment #12
andypostBetter to wait for common format in related issue
I'm sure that dot at the end should be removed to prevent links to be opened with it at the end 2993033.
Comment #14
volegerSo lets set a proper status of this issue. Postponed on #3024461: Adopt consistent deprecation format for core and contrib deprecation messages
Comment #15
volegerActually #3024461: Adopt consistent deprecation format for core and contrib deprecation messages already adopted the messages structure and only blocked by the CS rule implementation. so we can go further here.
Comment #16
volegerComment #17
volegerThe last
db_queryfunction calls replaced in the codebase, we need to publish CR.Updated
Introduced in versionversion value to8.8.0.Comment #18
berdirI think the patch above needs to be rerolled?
Comment #19
volegerReroll
Comment #20
volegerFix few CS issues. This one should be ready to review.
Comment #22
mondrakePatch is good cleanup, RTBC. However, the CR still needs #2991337: Document the recommended ways to obtain the database connection object to be complete.
Comment #23
alexpottCrediting @andypost and @mondrake for reviews.
Comment #24
alexpottCommitted 8a56839 and pushed to 8.8.x. Thanks!
Comment #27
jonathan1055 commentedThere is a typo in the deprecation message for db_select. The example for replcement has
->db_select()when it should be just->select(). When viewing the deprecation message we get the slightly confusingThe line in the commit above is
https://git.drupalcode.org/project/drupal/commit/8a56839#5a8148978c99bbf...
Would be nice to have the suggested example correct, but I realise that this might be too trivial for a fix in it's own right.