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
The patch for #1184082: Like queries failing on postgres with standard_conforming_strings turned on. removed the calls to $this->quote() but did not remove the comment and additional code added in #910388: Installation fails on PostgreSQL >=8.4: Invalid escape sequence..
Follow-up: Cleanup use of static usage within method.
Proposed resolution
Replace static $variables
with a static class variable with an appropriate name after mapConditionOperator method.
Remaining tasks
- Write patch
- Review patch
User interface changes
None.
API changes
Yes. Add a class variable to the database class, but does not remove any functionality.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#23 | interdiff-13-23.txt | 3.43 KB | bzrudi71 |
#23 | drupal-1565972-map-condition-operator-static-fix-23.patch | 6.46 KB | bzrudi71 |
#13 | interdiff-1565972-8-13.txt | 6.49 KB | mradcliffe |
#13 | drupal-1565972-map-condition-operator-static-fix-13.patch | 6.5 KB | mradcliffe |
Comments
Comment #1
c960657 CreditAttribution: c960657 commentedComment #2
tstoecklerI have no clue about Postgres, but if this comes back green, I feel comfortable RTBCing this. :)
Comment #3
catchThis looks fine to remove that extra logic, so I've committed pushed it, however why are we keeping a static in that method just to save building the array each time? Moving back to active to discuss.
Comment #3.0
catchtypo
Comment #8
pjohans CreditAttribution: pjohans commentedWe should get rid of the static keyword - it is not needed - the array will be set no matter what
Comment #9
pjohans CreditAttribution: pjohans commentedComment #10
mradcliffeThanks for the patch, @pjohans. I queued up a postgresql test since this affects that driver only.
Perhaps this should be a protected static variable on the Connection class instead of a scoped variable that's instantiated every time. I doubt there would be any meaningful performance leaving it without static though.
Comment #11
daffie CreditAttribution: daffie commentedMaking the specials array a class property would be in my eyes the best solution from a OOP perspective. Can we give the class variable the same name as the method that it belongs to.
The same problem exists with the Connection class from the SQLite driver and with the class Drupal\Core\Database\Query\Condition.
Also adding some docblocks to mapConditionOperator methods would not be a mistake. They are all inheritdocs.
Comment #12
mradcliffeComment #13
mradcliffeHow about this for PostgreSQL, SQLite and Condition operator?
I made the static protected variables unique to each class because the implementation might be different. I don't think we have an interface that's for all 3.
Flipped to 8.3.x because I applied to 8.3.x. The patch should still apply to 8.2.x.
Comment #15
mradcliffeRe-rolled for 8.2.x.
Comment #18
daffie CreditAttribution: daffie commentedI am reviewing this issue for the patch from comment #13, because that is the patch for Drupal 8.3.
This issue is not a bug, so this patch cannot be applied to 8.2.
THe patch for 8.3 looks good to me. I have only one nitpick and that can be fixed on commit:
The same comment twice. Please remove the second one.
@mradcliffe: Would you be interested in reviewing the PostgreSQL issues: #2057693: PostgreSQL orderBy method adds fields it doesn't need to, leading to fatal errors when the result is used as an insert subquery and #2238253: Add bindValue to a PDO::PARAM_* type in database query arguments?
Comment #19
mradcliffeYep. I need a bit of detox and de-jetlag. I haven't made it home yet.
Comment #20
Crell CreditAttribution: Crell at Platform.sh commentedThis change seems fine to me as a cleanup.
Comment #21
tim.plunkettNit, switch to
protected static
Not that we'd often be extending this class, but wouldn't
static::
be more useful thanself::
?Comment #22
catchCNW for #21, both good changes.
Comment #23
bzrudi71 CreditAttribution: bzrudi71 commentedAddressing #18 and #21
Comment #24
mradcliffeManually confirmed that #18 and #21 comments were applied to the patch.
Comment #25
Crell CreditAttribution: Crell at Platform.sh commentedThen I guess it's RTBC again.
Comment #26
alexpottCommitted dc5b0a4 and pushed to 8.3.x. Thanks!