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.
Problem/Motivation
Functions inside database.inc are deprecated and need to be replaced with their respective alternatives.
Proposed resolution
Replace db_and() and db_or() calls with Drupal\Core\Database\Query\Condition objects as specified in the function documentation.
Remaining tasks
User interface changes
API changes
Related Issues
Comment | File | Size | Author |
---|---|---|---|
#28 | interdif.txt | 1.42 KB | Pavan B S |
#28 | 2117305-28.patch | 22.44 KB | Pavan B S |
#25 | 2117305-25.patch | 22.33 KB | jofitz |
Comments
Comment #1
Crell CreditAttribution: Crell commentedIn concept I'm fine with this. I'd prefer something a bit less verbose than andConditionGroup(), but removing the wrapper functions is fine by me.
Comment #2
tim.plunkettCould just as easily be marked @deprecated. As long as we replace the usages in core, doesn't matter much to me.
Comment #3
jibran+1 for the change.
I see no purpose of this issue then :).
Comment #3.0
jibranUpdated issue summary.
Comment #4
disasm CreditAttribution: disasm commentedfirst go at this.
Comment #6
disasm CreditAttribution: disasm commentedundoing one views file that just doesn't have a query object accessible to the methods creating the conditions. It's probably going to need a refactor of some sort.
Comment #8
disasm CreditAttribution: disasm commentedgot a fix for views. The issue with search is the object returned by db_query does not have the method orConditionGroup on it. That hasn't been addressed yet.
Comment #9.0
(not verified) CreditAttribution: commentedUpdated issue summary.
Comment #10
chx CreditAttribution: chx commented> The issue with search is the object returned by db_query does not have the method orConditionGroup on it
Care to tell me a little more? db_query returns a statement, there's no more conditions on that. Where / what should I look at?
Comment #11
sunComment #12
andypostShould be marked when to remove, suppose 9.0
Comment #13
JeroenTFunctions were already marked deprecated in #1894396: Mark db_*() wrappers in database.inc as @deprecated for 9.x.
Comment #14
JeroenTComment #15
JeroenTComment #16
Crell CreditAttribution: Crell as a volunteer commentedIf they're marked deprecated that means working to remove their usage is entirely OK and encouraged for Drupal 8.
Comment #17
Mile23Setting to 8.1.x because I think that's where code cleanup type stuff is supposed to happen. Happy to be mistaken.
Setting parent issue to #2319859: [META] Deprecate contents of database.inc
Note that db_or() and db_and() have simple replacements spelled out in their @deprecation docs, so I'm adding the 'needs issue summary update' tag.
Comment #20
ieguskiza CreditAttribution: ieguskiza as a volunteer commentedHi,
I'm uploading a new patch based on the comment on #17: replacing db_and and db_or with Drupal\Core\Database\Query\Condition objects.
Comment #21
ieguskiza CreditAttribution: ieguskiza as a volunteer commentedI have cleaned up the tags for the issue and tried to rewrite the summary in order to reflect the problem and solution.
Comment #23
daffie CreditAttribution: daffie commentedComment #24
cilefen CreditAttribution: cilefen commentedI am reparenting this to a new meta.
Comment #25
jofitz CreditAttribution: jofitz at ComputerMinds commentedRe-roll.
Comment #26
daffie CreditAttribution: daffie commentedAll code changes are good.
All instances of the usage of
db_and()
anddb_or()
are replaced.The patch looks good to me.
Two minor documentation nitpicks can be fixed on commit.
Documentation should be filled out to the 80 character line.
The no documentation beyond the 80 character line rule is broken.
Comment #27
xjmLet's fix those docs errors in the patch. :) Thanks!
Comment #28
Pavan B S CreditAttribution: Pavan B S at Valuebound commentedApplying the patch as suggested in the comment #26 , please review .
Comment #29
jofitz CreditAttribution: jofitz at ComputerMinds commentedOnly documentation changes so setting back to RTBC.
Comment #30
alexpottCommitted 23d140f and pushed to 8.4.x. Thanks!
These original comments are a bit odd I've tried to make them a bit simpler and less about the code and more about what is actually relevant.