Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.Problem/Motivation
See https://www.drupal.org/pift-ci-job/1604603
There was 1 failure:
1) Drupal\KernelTests\Core\Database\SelectTest::testUnion
First query returned correct name.
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'George'
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | 3118454-89x.patch | 731 bytes | catch |
| #10 | 3118454-interdiff.txt | 611 bytes | catch |
| #10 | 3118454-10.patch | 724 bytes | catch |
| #3 | 3118454-3.patch | 710 bytes | andypost |
Comments
Comment #2
mradcliffeIt looks like there isn't any explicit order by. Not sure why 10 behaves differently here when 9 or 12 do not, but order by is still important in those versions as well. Could it be pg_tgrm?
I'm not sure if we could programmatically add an order when the query is compiled.
The first query includes both George and Ringo, but those could be in any order. I think this should work to change the test. I don't have time to create a patch.
Comment #3
andypostThis test does not use ordering so could be simplified
Comment #4
xjm#3 still seems to fail.
Comment #5
xjmTagging since this is blocking #2846994: Increase minimum version requirement for Postgres to 10 and require the pg_trgm extension.
Comment #6
andypostpg 12.1 also has 10 a time field errors in queries
Comment #7
catchWe need to sort the arrays before comparison, looks like there is a $canonicalize param to do that:
https://api.drupal.org/api/drupal/vendor%21sebastian%21comparator%21src%...
Comment #8
mondrake#7 that argument is deprecated. Maybe assertEqualsCanonicalizing will do, it is supported since PHPUnit8.
Comment #9
catchHere it is: https://phpunit.readthedocs.io/en/9.0/assertions.html#assertequalscanoni...
Looks like the right one indeed.
Comment #10
catchComment #11
xjmQueued a 8.9.x/Postgres 9.5 version to make sure this is safe for backport, as well as a few other flavors of database (Postgres and otherwise) given recent experience. We can expect the Postgres 12 one to fail with different issues, but this one shouldn't be in its list anymore.
Comment #12
xjm#10 failed on 8.9.x / Postgres 9.1 with:
...but that's a fail I see in HEAD sometimes, so requeuing that environment
Comment #13
catchDo we have an issue for that? Looks like another possible case for assertEqualsCanonicalizing
Comment #14
xjmRE: #13 Yep, #2982755: Random failure in SchemaTest::testSchemaChangePrimaryKey with order of composite primary key.
Comment #15
andypostIt sounds like deja vu with assert equals vs identical before
Comment #16
xjmMeanwhile, the retest passed. I think this fix is ready to go.
Comment #17
xjmMeanwhile, I also posted #3118591: Datetime-related test failures on PostgreSQL 12.
Comment #18
gábor hojtsyHm, according to #8, the assertEqualsCanonicalizing() method in the fix was introduced in PHPUnit 8. Drupal 9 was updated to require at least PHPUnit 8 in https://www.drupal.org/node/3113653 but Drupal 8.9 still has
"phpunit/phpunit": "^6.5 || ^7",in https://git.drupalcode.org/project/drupal/-/blob/8.9.x/composer.json (I was looking to see if we maybe allow PHPUnit 8 with newer PHP versions in Drupal 8.9 as well, but did not find evidence).Given all of that and that https://phpunit.readthedocs.io/en/7.0/search.html?q=assertEqualsCanonica... comes back empty (assertEqualsCanonicalizing() not mentioned in PHPUnit 7 docs), I am a bit puzzled how can this pass on Drupal 8.9.
Comment #19
gábor hojtsyUpon further URL hackery I found that it still does not appear in https://phpunit.readthedocs.io/en/7.4/assertions.html#assertequalscanoni... but it starts appearing in https://phpunit.readthedocs.io/en/7.5/assertions.html#assertequalscanoni... so this fix would require us to move to at least PHPUnit 7.5 as well.
Comment #20
catchLet's get this into 9.0.x then backport to 8.9.x using the deprecated arg to assertEquals. We shouldn't be introducing new deprecated code usages in 9.x either.
Comment #22
gábor hojtsyThat's a good approach as well.
Comment #23
catchI couldn't get the $canonicalize parameter to work, but this does the same thing in practice and should pass on 8.9.x
Comment #24
xjmAdded an SQLite test to be safe, but RTBC assuming they all pass.
Comment #25
xjmFor reviewers: the 10 Postgres 12 failures are expected and will be addressed in #3118591: Datetime-related test failures on PostgreSQL 12 The minimum requirement for this issue is that the test pass on the other databases tested above.
Comment #28
gábor hojtsySuperb, thanks for this version.