Closed (fixed)
Project:
Drupal core
Version:
8.8.x-dev
Component:
database system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 May 2017 at 16:39 UTC
Updated:
10 Jun 2019 at 21:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
erozqba commentedComment #3
erozqba commentedComment #5
erozqba commentedComment #6
erozqba commentedComment #10
volegerreroll against 8.6.x
Comment #12
volegerComment #13
volegerComment #14
volegerMaybe this patch should be chunked into the smaller patches? Like it was with #2924538: [META] Remove all usages of drupal_set_message and drupal_get_messages
Comment #15
volegerThis patch is too big, so I will attach smaller patches in the followups:
Comment #16
volegerUpdated issue summary
Comment #17
volegerComment #18
volegerReturning to the usual task issue. Regarding https://www.drupal.org/core/scope#examples we should follow good scope.
So as @alexpott had mentioned in the followup issues, to reduce the complexity of maintaining huge patch, it should be scripted.
Initial replacements.
Comment #19
volegerComment #20
joshmillerWorking on scripting this patch. Here's what I have so far:
It replaces all instances, which is unfortunate, because that replaces the `function db_query(` in database.inc as well. Once I figure out how to quickly revert that one change, I'll update this issue and close child issues.
EDIT: Whoops, looks like @voleger beat me to it (I worked on this last week, but just now getting around to posting it). His script looks more comprehensive, especially handling the object oriented test, etc.
Comment #21
volegerAlso, the script should avoid replacing function calls at tests for the function itself like
Drupal\KernelTests\Core\Database\QueryTestComment #22
volegerNext iteration.
Bulk replacements that cover all places where
db_queryfunction is used.The next step should be to find out files where Database class not used in current namespace and then fix related errors.
That step also should be scripted.
Also I guess we shouldn't remove
db_queryfunction name from the next array incore/lib/Drupal/Core/Utility/Error.php:50file:Comment #24
volegerLet's see which files require additional attention.
Here's scripted patch from #22 script.
No interdiff. Patch was scripted.
Comment #25
volegerTry manually to add usages of required Database class in files
Comment #26
volegerReupload interdiff
Comment #27
volegerFixed comments
Comment #28
volegerComment #29
volegerNeed some review of #27 and ideas on how to fix the Migration and Logger tests.
Comment #31
andypostI think better to get in db_delete & db_merge then patch will be smaller because in some places there will be
$connectionvariableComment #32
volegerAgreed
Postponed on:
#2848137: Replace all calls to db_update, which is deprecated
#2850033: Replace all calls to db_delete, which is deprecated
#2873684: Replace all calls to db_select, which is deprecated
Comment #33
mondrakeThere is a lot of calls to
db_query('SELECT COUNT(*) ...');.Find for example just those in test code with
find . -type f -name '*Test.php' -exec grep -Ei "QUERY.*COUNT.*\(\*\)" {} \+.We might convert those to
$injected_database->select(...)->countQuery()and then the conversion here would be more digestible...Comment #34
mondrakeOpened #2994904: Convert query('SELECT ... FROM {xxx}') to select('xxx')->... in tests.
Comment #35
voleger#2848137: Replace all calls to db_update, which is deprecated is fixed.
Still postponed on:
#2853118: Replace all calls to db_insert, which is deprecated
#2850033: Replace all calls to db_delete, which is deprecated
#2873684: Replace all calls to db_select, which is deprecated
Comment #36
volegerComment #37
voleger#2850033: Replace all calls to db_delete, which is deprecated fixed
Comment #38
volegerComment #39
volegerPostopend on #2873684: Replace all calls to db_select, which is deprecated
Comment #40
volegerAlso, make it postponed on #2994904: Convert query('SELECT ... FROM {xxx}') to select('xxx')->... in tests that will convert some
queryintoselectcallsComment #41
volegerComment #42
mondrakeComment #43
mondrakedb_select #2873684: Replace all calls to db_select, which is deprecated is gone
Comment #44
mondrakeComment #45
mondrake#3001216: Use the database.replica service where appropriate has gone
Comment #46
mondrakeI do not think this is blocked on #2994904: Convert query('SELECT ... FROM {xxx}') to select('xxx')->... in tests - it would help for sure but can do without.
Comment #47
volegerI agree those issues are not the blockers no more.
Scripting of the patch will not help because it also become outdated and it's complicated to script adding missing namespaces, loop construction situations,
::getConnectioncalls optimization, connections to the replica database.Added rerolled patch.
Skipped D6 and D7 scripts, because they should be executed against related codebase version.
Skipped documentation updates for db_* functions, because they are deprecated and usually linked to deprecated db_* functions that are also deprecated.
Comment #49
andypostYep, as other conversions landed let's get this one next before "count" issue in bikeshed
Comment #50
volegerI'm not sure about replacement in LoggingTest. Trying not pass test property in the callable array.
Comment #52
mondrakeWe need #2999962: Unify Database/Log::findCaller and Utility/Error::getLastCaller before we can address the LoggingTest issue.
Comment #53
volegerAs logger already works not properly, is it possible to fix an issue related to the LoggingTest in the followup issue? It will unblock a huge amount of replacements.
Comment #54
mondrakeAs discussed in #2994904: Convert query('SELECT ... FROM {xxx}') to select('xxx')->... in tests, we probably need to have separate issues to convert
db_queryusages on entity related tables to use the Entity Query API, since neither converting toConnection::querynor toConnection::selectseems the right thing to do in these cases.Comment #55
volegerSince amounts replacements in this issue much more than replacements in #3012599: Replace all db calls to aggregator_feed and aggregator_item tables with Entity APIs and this issue already blocked by #2999962: Unify Database/Log::findCaller and Utility/Error::getLastCaller, I suggest postponing this issue also on #3012599: Replace all db calls to aggregator_feed and aggregator_item tables with Entity APIs as there are no blockers.
Comment #56
volegerOops wrong issue
Comment #57
volegerFixed #3012599: Replace all db calls to aggregator_feed and aggregator_item tables with Entity APIs
Still postponed on #2999962: Unify Database/Log::findCaller and Utility/Error::getLastCaller
Comment #58
volegerComment #59
volegerComment #60
volegerJust reroll. Still blocked by #2999962: Unify Database/Log::findCaller and Utility/Error::getLastCaller
Comment #61
mondrakeIMHO, we should also decide on the fate of #2994904: Convert query('SELECT ... FROM {xxx}') to select('xxx')->... in tests before unpostponing - with that in, this patch would be 100kb+ smaller and much easier to review.
Comment #62
berdir@voleger: I think the #2999962: Unify Database/Log::findCaller and Utility/Error::getLastCaller is tricky to resolve, is this really a hard blocker, can't we just keep those duplicated pieces of code and update them separately?
Comment #64
volegerBlocker for #3049380: Complete deprecation of _db_get_target() function
Comment #65
berdirI'm still not sure about blocking issue and it just feels hard to review for me.
Why don't we just fix it like this? Took me a while to understand it, but the trick as much as I understand it really is to find the last call of the backtrace that's still *inside* the database system and then report the next, but the line/file is actually on this part.
We already check for the db_* function not being the next, so as far as I see, we just need to change the namespace check to the same. That means it behave consistently, whether or not the call goes through db_query(). Also added explicit tests for that.
Comment #66
volegerNice. +1 for the fix.
Cleanup of unused use definitions. Updated deprecation messages to fix CS issues.
Fixed typo and comments CS issue.
Comment #67
thallesLooks good!
But why not use the $this->connection->query?
Comment #68
volegerThis line will test the logging of procedural call of the
db_queryfunction as we introduce the fix for the logging service. BTW this test in thelegacygroup, so that line will be removed from drupal:9.0.0.Comment #69
thallesThanks @voleger!
Comment #71
berdirStill applies and test is still green, looks like another random test fail in MediaLibraryTest?
Comment #73
yogeshmpawarAll looks good so setting back to RTBC! Tests failure is not related (see #3055648: Frequent random fail in \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTest).
Comment #74
volegerUpdated IS
Comment #76
volegerSee #2901792: Disable all animations in Javascript testing
Comment #77
volegerComment #78
catchNeeds a re-roll.
Comment #79
berdirTwo conflicts in EntityApiTest. Adding a patch diff to show that there are only context changes compared to the last patch and setting back to RTBC.
Comment #80
volegerRerolled
Updated changes in
db_queryfunction definition. See #3000931: Connection::query() does not support 'target' optionComment #81
volegerAnd actual rerolled patch
Comment #82
larowlanadding review credit for mondrake for co-ordination and management tasks
Comment #84
larowlanCommitted 275c864 and pushed to 8.8.
🎉