After submitting a patch for #3125842: Block facets don't apply contextual filters on ajax response I noticed that the default tests appear to be failing using PHP 7.3 & MySQL 5.6, Drupal 8.9.16. The most recent tests on 8.x-1.x-dev did pass but that was on 6 Oct 2021.
One example:
1) Drupal\Tests\facets\FunctionalJavascript\WidgetJSTest::testAddFacet
Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes: CREATE TABLE {search_api_task} (
`id` INT unsigned NOT NULL auto_increment,
`type` VARCHAR(50) NULL DEFAULT NULL,
`server_id` VARCHAR(50) NULL DEFAULT NULL,
`index_id` VARCHAR(50) NULL DEFAULT NULL,
`data` LONGTEXT NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `task__unique` (`type`, `server_id`, `index_id`, `data`(255))
) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT 'The base table for search_api_task entities.'; Array
(
)
/var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:1619
/var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:1538
/var/www/html/core/lib/Drupal/Core/Entity/EntityTypeListener.php:93
/var/www/html/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php:232
/var/www/html/core/lib/Drupal/Core/Extension/ModuleInstaller.php:254
/var/www/html/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php:83
/var/www/html/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:476
/var/www/html/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:83
/var/www/html/core/tests/Drupal/Tests/BrowserTestBase.php:578
/var/www/html/core/tests/Drupal/Tests/BrowserTestBase.php:406
/var/www/html/modules/contrib/facets/tests/src/FunctionalJavascript/JsBase.php:34
Caused by
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes: CREATE TABLE {search_api_task} (
`id` INT unsigned NOT NULL auto_increment,
`type` VARCHAR(50) NULL DEFAULT NULL,
`server_id` VARCHAR(50) NULL DEFAULT NULL,
`index_id` VARCHAR(50) NULL DEFAULT NULL,
`data` LONGTEXT NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `task__unique` (`type`, `server_id`, `index_id`, `data`(255))
) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT 'The base table for search_api_task entities.'; Array
(
)
/var/www/html/core/lib/Drupal/Core/Database/Connection.php:701
/var/www/html/core/lib/Drupal/Core/Database/Connection.php:665
/var/www/html/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:357
/var/www/html/core/lib/Drupal/Core/Database/Schema.php:656
/var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php:432
/var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:1537
/var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:1611
/var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:1538
/var/www/html/core/lib/Drupal/Core/Entity/EntityTypeListener.php:93
/var/www/html/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php:232
/var/www/html/core/lib/Drupal/Core/Extension/ModuleInstaller.php:254
/var/www/html/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php:83
/var/www/html/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:476
/var/www/html/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:83
/var/www/html/core/tests/Drupal/Tests/BrowserTestBase.php:578
/var/www/html/core/tests/Drupal/Tests/BrowserTestBase.php:406
/var/www/html/modules/contrib/facets/tests/src/FunctionalJavascript/JsBase.php:34
Caused by
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
/var/www/html/core/lib/Drupal/Core/Database/Statement.php:59
/var/www/html/core/lib/Drupal/Core/Database/Connection.php:640
/var/www/html/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:357
/var/www/html/core/lib/Drupal/Core/Database/Schema.php:656
/var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php:432
/var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:1537
/var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:1611
/var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:1538
/var/www/html/core/lib/Drupal/Core/Entity/EntityTypeListener.php:93
/var/www/html/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php:232
/var/www/html/core/lib/Drupal/Core/Extension/ModuleInstaller.php:254
/var/www/html/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php:83
/var/www/html/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:476
/var/www/html/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:83
/var/www/html/core/tests/Drupal/Tests/BrowserTestBase.php:578
/var/www/html/core/tests/Drupal/Tests/BrowserTestBase.php:406
/var/www/html/modules/contrib/facets/tests/src/FunctionalJavascript/JsBase.php:34
It seems that the issue stems somehow from Search API which had a 8.x-1.21 release on 4 Nov that included #3228210: Fix current test failures. The weird thing is that issue was reporting a similar error but should have fixed it so I'm not quite sure why this is now causing test failures here.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3248297-9.patch | 14.22 KB | wells |
| #10 | interdiff_8-9.txt | 1.46 KB | wells |
| #2 | 3248297-2.patch | 338 bytes | wells |
Issue fork facets-3248297
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wellsAdding a patch with a small, trivial change just to trigger tests. Assuming this work there should be a result similar
8.x-1.x: PHP 7.3 & MySQL 5.6, D8.9.16 309 pass, 34 fail.Comment #3
wellsBased on the discussion in #3228210: Fix current test failures it seems that Search API is is just no longer compatible with MySQL 5.6 as of 8.x-1.21. That seems reasonable given that Drupal 8 is now EOL and Drupal 9+ requires MySQL 5.7.
I ran the
PHP 7.3 & MySQL 5.7, Drupal 8.9.xtests and they all pass fine so maybe Facets should update to use those as the default for commits and issues?Incidentally, I also ran the
PHP 7.3 & MySQL 5.7, Drupal 9.3.xtests and that has a number of failures unrelated to this specific issue. I think it would be worth using this issue to get those fixed up and either set that as the default tests or include it in regular tests.Comment #4
wellsKnocking out an easy one first --
Zend\Stdlib\ArrayObjectis no longer available in D9+ so changing all instances to the SPLArrayObject(as others tests do).Comment #5
wellsFour additional issues to address from the last test:
Fixed. This was caused by
\Drupal\Tests\facets_summary\Functional\IntegrationTest::testBlockDeletereferencing theclassytheme when it is no longer the default theme in tests (I think...). I updated that test to reference\Drupal\Tests\facets\Functional\FacetsTestBase::$defaultThemeinstead of using a hardcoded string. I think this will resolve the issue in D9 tests without affecting D8 tests.Fixed by #7. Not sure about this one yet. The expected value is
/search-api-test-fulltext?y[0]=facet||itemand actual is/search-api-test-fulltext?y[0]=facet:item. I'm not seeing the double-pipes tested anywhere else and I'm unclear on what they are for. This is somehow related to\Drupal\facets_query_processor\Plugin\facets\url_processor\DummyQuerybut, again, it's unclear what that is or what it is testing.Unfixed. Ditto unsure here. The expected value is
/search-api-test-fulltext?f[0]=facet:item&test=funand the actual is/search-api-test-fulltext?test=fun&f[0]=facet:item. So the order of the query parameters are just switched. I don't think that should matter so maybe a change can be made to the assertion to support either result?Fixed by #3248533: Attempting to create a facet with a duplicate machine name causes a PHP error in Drupal 9.
Comment #6
wellsOne additional issue discovered in #3248533: Attempting to create a facet with a duplicate machine name causes a PHP error in Drupal 9 -- after that patch is merged tests will also hit an error in
\Drupal\Tests\facets\Functional\IntegrationTest::testFrameworkdue to a change in the success message when deleting a block which is asserted inDrupal\Tests\facets\Functional\BlockTestTrait::deleteBlock. This change was made by #2839558: Blocks do not have a "remove" contextual link in Drupal 9.3.Attached patch removes the old logic for this message that addressed Drupal 8.3 (since the module now only supports 8.8+) and replaces it with logic for the Drupal 9.3 change. I won't run tests on this patch as it won't show any difference here until #3248533: Attempting to create a facet with a duplicate machine name causes a PHP error in Drupal 9 is merged.
Comment #7
wellsNext patch attached! I think this will fix the second fail from #5. This test was failing because
\Drupal\facets_query_processor\Plugin\facets\url_processor\DummyQuerywas setting a$separatorvalue but that value was being overwritten by\Drupal\facets\UrlProcessor\UrlProcessorPluginBase::__construct. This patch changesDummyQueryto implement it's separator override in it's own__constructoverride. The test now passes in D9 but I'm unclear on how this was even passing in D8 so I'm curious to see if this causes a fail in the D8 tests in CI.So that only leaves the third fail from #5 and I'm entirely unsure whats happening with that one. I can't find any changes to URL or query parameter handling that would have made the order of those parameters switch between D8 and D9 (or their dependencies). I tested manually using the test modules and configuration and sure enough they are switched in D9. I don't have a D8 install to test with but I assume the expected order is correct there because all the D8 tests pass. Supporting either result would require refactoring
\Drupal\Tests\facets\Functional\TestHelperTrait::checkClickedFacetUrland the tests that rely on it so I'm avoiding that for now (though I think it would really just mean moving the asserting outside that method).Comment #8
wellsOk last fix! This patch refactors
\Drupal\Tests\facets\Functional\TestHelperTrait::checkClickedFacetUrlas\Drupal\Tests\facets\Functional\TestHelperTrait::clickFacetand only clicks but does not assert any URL. That allows\Drupal\Tests\facets\Functional\UrlIntegrationTest::testFacetUrlCanBeChangedto be changed in such a way that it just tests for the existence of the relevant query parameters on the URL independently instead of relying on an exact URL string.This should be the last patch needed after #3248533: Attempting to create a facet with a duplicate machine name causes a PHP error in Drupal 9 is merged (i.e., there will still be one failure here).
Moving this to Needs review though it will of course fail and reset to Needs work (:
Comment #10
wellsJinxed myself! This patch removes the
toString()'s I added to the relevant URLs in #8 because apparently that causes some unhappiness when testing (see #2986962: BrowserTestBase::drupalGet() does not appear to be handling base url properly). This change should get the patch back to passing in D8 and one fail in D9 (again, pending merge of #3248533: Attempting to create a facet with a duplicate machine name causes a PHP error in Drupal 9).Comment #11
mkalkbrennerComment #13
mkalkbrenner