Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
database system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
31 Jan 2022 at 20:44 UTC
Updated:
25 Sep 2022 at 08:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
catchSo we changed the dump command without re-exporting the dumps. If we'd re-exported the dumps, then the import test would have caught the bug, but because we didn't, it didn't. So I think #3261486: Remove core updates added prior to 9.3.0 and adjust test coverage is OK for test coverage since it corrects the fixtures. If we re-exported the dumps here, it'd mean a conflict with that issue.
Comment #3
daffie commentedLooks good to me.
Comment #4
dwwSince this is blocking #3261486: Remove core updates added prior to 9.3.0 and adjust test coverage which blocks lots of others, tagging to be smashed. Hopefully promptly. 😉
The patch is tiny and looks good to me, too. $RTBC++;
Thanks y'all!
-Derek
Comment #5
mradcliffeWould this also be needed for @mondrake's "dbal" driver? I don't know if that matters.
Comment #6
mondrake#5 hopefully noone is using that driver in production, let alone making dumps with it :) And if they do, well, they're on their own anyway.
But the point is valid:
driver()!==databaseType(). With the change here, any driver that will declare serving a 'mysql' database will be executing this statement.IMHO we should aim a more permanent solution like #3222127: Add the SQL mode NO_AUTO_VALUE_ON_ZERO to the MySQL database connection or even better, avoid to rely on hardcoded ID on insert like #3225350: Avoid passing arbitrary values to the serial column on INSERT but that's far away AFAICS
Comment #7
alexpottCommitted and pushed affdb3e70a7 to 10.0.x and e157b9c05e1 to 9.4.x and 0d1783be0a1 to 9.3.x. Thanks!
One thing I'm wondering is that we only change the mode during user insert so that's what the dump should do - but we change the mode for all tables. That means our dumps are essentially behaving like #3222127: Add the SQL mode NO_AUTO_VALUE_ON_ZERO to the MySQL database connection is implemented. I think we should open a follow-up to move the sql mode setting into \Drupal\Core\Command\DbDumpCommand::getTableScript() and hardcode the user table.
Comment #11
alexpottActually I'm not sure about that. If a contrib module has managed to insert a 0 into a serial field by doing something similar to the user entity then the current code is going to make it work for db dumps. So yeah I don't think we need a follow-up. Hopefully #3222127: Add the SQL mode NO_AUTO_VALUE_ON_ZERO to the MySQL database connection will land and we can remove this code because it will be set on the connection.
Comment #12
wim leersDoes this have implications for migration tests? In core? In contrib?
Comment #13
catch@Wim Leers so the issue surfaced on #3261486: Remove core updates added prior to 9.3.0 and adjust test coverage. The dumps weren't updated when the dumping script was (because they're from versions prior to the change, or overlooked). When I updated them to 9.3.0, the @sql_mode change was added to the dump, and then the dump failed to load into an sqlite database (which is the dump/load test in core).
So... this bug fix shouldn't change anything really, but if there are dumps in contrib made between #838992: Change the uid field from integer to serial by leveraging NO_AUTO_VALUE_ON_ZERO on MySQL and this issue, they won't load into non-MySQL databases. The solution would be to load them into mysql, then dump them again with this fix applied (or it's also an easy change to make manually tbh).
Comment #14
wim leersThanks, @catch, that helps!
And … not sure yet if this is directly related to #3260111: Regression AND bug: SQLite source and id map tables aren't joinable anymore, but SqlBase::mapJoinable() is unaware of this, but it sure seems related.
Comment #15
dwwYay, glad to see this in. Thanks!
Are we not crediting folks for reviews? Even if it's a small patch? 😉
Comment #17
xjmAdding credit for @Wim Leers, @mradcliffe, and @mondrake for substantive reviews under our core credit guidelines. Thanks @dww for raising the issue. Once in awhile issue credits get reverted by a crosspost when the committer saves the issue.
Edit: Also some of the helpful discussion here was post-commit. The "looks good to me, +1" reviews on the initial patch are helpful but do not qualify for credit. :)
Comment #18
quietone commentedRemoving tag per #11