WSOD error - Unable to uninstall due to SQL Integrity Constraint Violation

Created on 25 October 2019, over 4 years ago
Updated 27 November 2023, 7 months ago

Drupal 8.7.6

When I try to uninstall the module I get a WSOD: The website encountered an unexpected error. Please try again later. Once I refresh the page /admin/modules/uninstall/confirm I get the following message:

The selected modules could not be uninstalled, either due to a website problem or due to the uninstall confirmation form timing out. Please try again.

DBLog shows the following fatal error:Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '4-4-1-0-en' for key 'PRIMARY': INSERT INTO {field_deleted_revision_d6e93e100c} (bundle, entity_id, revision_id, langcode, link_override_uri, link_override_title, link_override_options, deleted, delta) SELECT base_table.bundle AS bundle, entity_table.id AS entity_id, entity_table.revision_id AS revision_id, entity_table.langcode AS langcode, entity_table.link_override__uri AS link_override_uri, entity_table.link_override__title AS link_override_title, entity_table.link_override__options AS link_override_options, :deleted AS deleted, :delta AS delta FROM {menu_link_content_data} entity_table INNER JOIN {menu_link_content_data} base_table ON entity_table.id = base_table.id WHERE (entity_table.link_override__uri IS NOT NULL) OR (entity_table.link_override__title IS NOT NULL) OR (entity_table.link_override__options IS NOT NULL) FOR UPDATE; Array ( [:deleted] => 1 [:delta] => 0 ) in Drupal\Core\Database\Connection->handleQueryException() (line 689 of /core/lib/Drupal/Core/Database/Connection.php).

I eventually removed the module folder and ran /core/rebuild.php and everything seemed ok after that, though I still see these columns in the menu_link_content_data table in the database:

  • link_override__uri
  • link_override__title
  • link_override__options

I manually deleted any data in those columns (there were some "N;" still in the link_override__options column), put back the module folder, and re-ran the uninstall, and it gave no errors. (But the columns are still there - shouldn't they be deleted?)

πŸ› Bug report
Status

Closed: cannot reproduce

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States matthewv789

Live updates comments and jobs are added and updated live.
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.

  • Hi everyone, I would suggest the following hook to update your database

    ** you should replace N by 8002, 9002
    ** after adding ->setRevisionable(TRUE), old users must re-install the module :/ which is not good (data loss). We should't add a hook to update table for old users

    function translatable_menu_link_uri_update_N() {
      $database = \Drupal::database();
    
      $columns_schema = [
        'link_override__uri' => [
          'type' => 'varchar',
          'length' => 2048,
          'not null' => FALSE,
          'description' => 'The URI of the link.',
        ],
        'link_override__title' => [
          'type' => 'varchar',
          'length' => 255,
          'not null' => FALSE,
          'description' => 'The link text.',
        ],
        'link_override__options' => [
          'type' => 'blob',
          'not null' => FALSE,
          'size' => 'big',
          'description' => 'Serialized array of options for the link.',
        ],
      ];
    
      foreach ($columns_schema as $field_name => $column_schema) {
        // Create fields if they don't already exist.
        if (!$database->schema()->fieldExists('menu_link_content_field_revision', $field_name)) {
          $database->schema()
            ->addField('menu_link_content_field_revision', $field_name, $column_schema);
        }
      }
    }
    
    
Production build 0.69.0 2024