-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RelationshipCache - Trigger should adapt to active collation #18721
Conversation
(Standard links)
|
Good catch. I think this should be against 5.31. If the |
6a20e0c
to
18ef1ba
Compare
I've rebased it to be against 5.31 |
Do we need some update process to rebuild the whatnots or is that always done as part of an upgrade? |
I'm thinking the |
I think bin is needed:
|
makes sense, I'll amend to use getInUseCollation() How's this ↓ looking, then? |
18ef1ba
to
5ecfba6
Compare
Hey @artfulrobot - what you have to do in order to get this to merge cleanly into 5.31 is:
|
What are the fields we are comparing? Having to use collate raises alarm bells with me in terms of possibly by-passing indexes |
It's a trigger comparing the same field to itself's new value. I don't think indexes would be involved. |
I just want to agree with everything @demeritcowboy has said. :)
|
Should be an automatic part of the upgrade ( |
@totten we are pretty clear about assuming that mysql has to be configured to be non-case sensitive - so the collation is NOT required for that. That was the basis on which we removed all the index bypasses using LOWER() |
Hmm this is bringing up an interesting point. If I have trigger-based logging turned on (admin - system settings - misc - logging) my expectation is that if I change a contact's first name from "robert" to "Robert" it should get logged, but it doesn't because the logging triggers don't have |
@demeritcowboy no - you are probably the first to think of it |
5ecfba6
to
7dd3301
Compare
@colemanw I've rebased it on top of 5.31. I'm not sure why the tests are failing though, perhaps unrelated? Presumably decisions and discussions about default collations should be a lab issue? This PR is to do with fixing something and maintaining the existing logic, not changing the logic. |
@artfulrobot it looks like you didn't delete all of the extraneous commits during that rebase. There are still 3 unrelated commits in this PR, whereas there should only be your one commit and no others. |
@colemanw oops, sorry I'll fix. |
7dd3301
to
5fff827
Compare
Possibly the current test fail (DB Error: syntax error) is because getInUseCollation() doesn't work during For the other discussion topic issue: https://lab.civicrm.org/dev/core/-/issues/2114 |
5fff827
to
a98180d
Compare
@demeritcowboy cool. I've added a catch for that. |
Oh I see the problem. All the db tables have been loaded already when this runs so that's not it. The problem is that where $collation is used is inside a closure inside a call to array_map(), so it's not defined at that point. |
Ah, doh! Will sort, thanks @demeritcowboy |
a98180d
to
1d53963
Compare
Thanks @artfulrobot this looks good. Ran with both utf8 and utf8mb4. Upgrade does rebuild triggers BUT the utf8conversion task does not so the triggers are still utf8_bin at that point, but I think this should be merged and can deal with that separately. |
Have added #18751 to rebuild triggers after running the utf8conversion . |
Overview
Upgrade your database to utf8mb4 and you can no longer edit relationship types (e.g. even trying to disable one fails) because of an SQL trigger that forces the
utf8_bin
collation on one side of a column comparison expression.Before
Trigger forced invalid COLLATE. Cannot edit Relationship Types.
After
Can edit Relationship Types.
Trigger no longer specifies a collation, thereby inheriting the collation from the column(/table/database). Since these collations should all be the same (esp after running system.utf8conversion) then I don't see the need for the explicit colaltion.
Technical Details
This requires a trigger rebuild (
civicrm/menu/rebuild?reset=1&triggerRebuild=1
orcv api System.flush triggers=1
)