Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-up to #2848161: [meta] Replace calls to deprecated db_*() wrappers
Problem/Motivation
#1894396: Mark db_*() wrappers in database.inc as @deprecated for 9.x deprecated the db_* family of functions. Update documentation recommending them.
Proposed resolution
This can help find them git grep -E "^\s*(\/\/|\*).*db_\w+"
Remaining tasks
Comment | File | Size | Author |
---|---|---|---|
#49 | interdiff-2849745-47-49.txt | 615 bytes | voleger |
#49 | 2849745-49.patch | 21.69 KB | voleger |
Comments
Comment #2
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedFor the start i am uploading this patch , i know it needs more work. Is this the right way to do it??
Comment #3
cilefen CreditAttribution: cilefen commentedUse \Drupal.
I added a search script to help find these to the issue summary.
Comment #4
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedDid some more , tell me if i am wrong.
Comment #5
cilefen CreditAttribution: cilefen commentedDon't change CHANGELOG.TXT but it seems like you are going in the right direction.
Comment #6
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedFixed Some more.
Comment #7
xjmComment #8
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound commentedLine exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters & There are 2 spaces.
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Line exceeding 80 characters
Comment #9
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound commentedComment #11
cilefen CreditAttribution: cilefen commentedComment #12
himanshu-dixit CreditAttribution: himanshu-dixit as a volunteer commentedComment #14
cilefen CreditAttribution: cilefen commentedComment #16
daffie CreditAttribution: daffie commentedComment #17
yogeshmpawarUploading same patch with another naming conventions. may be it will solve "patch validation error."
Comment #18
daffie CreditAttribution: daffie commented@Yogesh Pawar: Thanks for the reroll.
The patch looks good, but I do have some remarks:
You have only to change
$result = db_select('example')
to$result = \Drupal::database()->select('example')
. Remember to remove the semicolon. The rest of the change is not necessary. There are multiple instances of this problem.This change is not necessary.
Comment #19
yogeshmpawar@daffie- thanks for your suggestions.
Comment #20
daffie CreditAttribution: daffie commentedAll documentation changes look good to me. I have only one remark:
These need to change in the same way as comment #18.1.
The problem with this patch is that it is impossible to check if we have changed all that must be changed.
Comment #21
yogeshmpawarThanks @daffie, made changes as per remark, also added a interdiff.
Comment #22
daffie CreditAttribution: daffie commentedThe patch looks good only one nitpick left.
Nitpick: A space between the arrow and dropPrimaryKey.
The problem with this patch is that it is impossible to check if we have changed all that must be changed. Maybe we should set this issue to postponed untill all other sub-issues of #2319859: [META] Deprecate contents of database.inc are fixed.
Comment #23
cilefen CreditAttribution: cilefen commentedHow is it impossible?
Comment #24
daffie CreditAttribution: daffie commented@cilefen: I do a string search for function that must be changed. And for this issue that are a lot of functions to search for. Each search gives a lot of false positives that are not documentation. If we postponed this issue until all code changes are made, we will have no more false positives. If you know a better way to checking if all instances are changed, please let me know!
Comment #25
cilefen CreditAttribution: cilefen commentedI was just asking. The reason this big issue exists is that it was becoming untenable to write patches for documentation when some doc lines mention several db_ functions in a single line, although the original plan had been to change each function with its documentation in single issues. That idea is not set in stone and suggestions on getting this done are welcome! It's complicated, as you know.
Also, note that #2848161: [meta] Replace calls to deprecated db_*() wrappers exists to collect the db_ usages so we don't clutter up #2319859: [META] Deprecate contents of database.inc although you could re-child all the issues there if you are ambitious.
Comment #26
cilefen CreditAttribution: cilefen commentedOh, I see https://www.drupal.org/node/2319859#comment-11966287. I'm still open to suggestions on the docs part: whether it is easier to do the docs by function with the usages, or this big bang issue.
Comment #27
daffie CreditAttribution: daffie commented@cilefen: What we also can do patch in this issue with most of the documentation changes and followup after all the code changes are done if we forgot something in documentation. You are the committer and you may decide.
Comment #31
Mile23I've been working on #2634356: Replace deprecated db calls with injected connection in dbtng_example for Examples and it sure would be nice if database.api.php weren't wrong. :-)
Let's split out database.api.php as a special case: #2987399: Update database.api.php to remove deprecated db_*() functions.
Comment #32
vacho CreditAttribution: vacho at Skilld commentedPatch rerolled
Comment #33
savkaviktor16@gmail.com CreditAttribution: savkaviktor16@gmail.com at Skilld commentedComment #35
volegerIf we fix the issue #2947946: Create change record for all deprecated db_* functions
we can unblock and close the issue #2848161: [meta] Replace calls to deprecated db_*() wrappers
so that's will unblock current issue.
Also, there is a discussion regarding how correctly get connection to the database in the various code context. See #2991337: Document the recommended ways to obtain the database connection object
Comment #36
voleger#2848161: [meta] Replace calls to deprecated db_*() wrappers Needs review as all required child issues were resolved.
So we can unblock this issue.
Comment #37
BerdirRerolled, a few cases were already updated. I did look for other instances of db_* functions mentioned in in comments where they shouldn't be and updated them mostly test descriptions and assertion messages.
Comment #38
BerdirQuite a few replacements seem strange and actually backwards, neither are do these methods use _ nor are they on the connection object, often the old version was actually correct?
Comment #39
volegerRerolled patch.
Some changes were reverted.
Found a few lines for replacement.
Comment #41
BerdirLooks much better now, reviewed with word diff, found just these 3 nitpicks.
This is also an example where it would possibly make more sense to just write a proper english sentence: .. run two temporary queries in the same request.
above we have an example that does self::processField(), this just does ::query and it's also missing (), we should probably make that a bit more consistent (not 100% sure that self or so is actually valid in a docblock.
method?
Comment #42
volegerAddressed #41
Comment #44
volegerUnrelated test fails. Ready for review.
Comment #45
daffie CreditAttribution: daffie commentedThe patch looks good to me.
The 3 nitpicks from @Berdir are addressed.
The patch is RTBC for me.
Comment #46
catchA bit out of scope but this could also point to \Drupal::database()->merge()
\Drupal::database()->like() isn't a method, should probably be \Drupal::database()->escapeLike(). Needs work for that.
Comment #47
volegerAddressed #46
Back to RTBC
Comment #48
catchThis is fine now except 'respectively' doesn't work because there's not a 1-1 match, so we should just remove that word.
Comment #49
volegerAddressed #48
Comment #51
catchCommitted 383b06f and pushed to 8.8.x. Thanks!