Requirement error because drupal_utf8mb4_test table was not dropped

Created on 17 March 2017, about 7 years ago
Updated 30 April 2024, about 1 month ago

Problem/Motivation

For some reason, in a site I maintain, the drupal_utf8mb4_test table was not dropped on one of my sites after a requirement check. This left me with a requirement error stating that my system did not support utf8mb4.

Proposed resolution

Either DatabaseConnection_mysql::utf8mb4IsSupported() should only try to create the table if it does not exist or the requirement should warn about the existing table.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Needs review

Version

7.0 โšฐ๏ธ

Component
Databaseย  โ†’

Last updated less than a minute ago

  • Maintained by
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands @daffie
Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany morenstrat Bochum, Germany

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • last update about 1 month ago
    run-tests.sh exception
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Pravesh_Poonia

    yes, issues are looking fixed now

  • Status changed to Needs review about 1 month ago
  • ๐Ÿ‡ธ๐Ÿ‡ฐSlovakia poker10

    Thanks all for working on this!

    Testing core gate now has an exception, specifying when tests are not needed, see: https://www.drupal.org/about/core/policies/core-change-policies/core-gat... โ†’ . One of the conditions is that

    "The issue has clear โ€˜Steps to reproduceโ€™ in the Issue Summary."

    .

    So my question is - beside the manual table creation - do we know a way how we can achieve that the table is created, exception is thrown only afterwards and therefore the table is not deleted correctly? What other exceptions can be thrown after the table is created and before it is dropped? If there are some possibilities, then great. If not, should not we consider an alternative approach to check and drop the table in the catch block instead?

    I have looked at all CREATE TABLE statements in D7 core and none of these is using IF NOT EXISTS.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    What this issue reports is that the current code returns FALSE even when the test table already exists, which would be understood as the utf8mb4 support is not available.

      try {
        $this->query("CREATE TABLE {drupal_utf8mb4_test} (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB");
      } catch (Exception $e) {
        return FALSE;
      }
    

    I cannot say that what described happens very often. I can see that another CMS, to check the utf8mb4 support, first deletes the test table if it exists, then it tries to create it, and deletes it once done the test. The equivalent Drupal code would be similar to the following one.

    // Ensure that the MySQL server supports large prefixes and utf8mb4.
      try {
        $this->query("DROP TABLE IF EXISTS {drupal_utf8mb4_test}");
        $this->query("CREATE TABLE {drupal_utf8mb4_test} (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB");
      }
      catch (Exception $e) {
        return FALSE;
      }
      $this->query("DROP TABLE IF EXISTS {drupal_utf8mb4_test}");
      return TRUE;
    }
    
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    I checked what Drupal 10.x does, but I did not find any code which verifies utf8mb4 is supported. (I guess Drupal 10 requires a MySQL version which surely supports utf8mb4.)

Production build 0.69.0 2024