Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
drush en redirect get the following error but when I run the drush command again it says that redirect is already installed
exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 3072 bytes' in
drupal/includes/database/database.inc:2204
Stack trace:
#0
drupal/includes/database/database.inc(2204):
PDOStatement->execute(Array)
#1
drupal/includes/database/database.inc(683):
DatabaseStatementBase->execute(Array, Array)
#2
drupal/includes/database/schema.inc(664):
DatabaseConnection->query('CREATE TABLE {r...')
#3
drupal/includes/database/database.inc(2753):
DatabaseSchema->createTable('redirect', Array)
#4
drupal/includes/common.inc(7334):
db_create_table('redirect', Array)
#5
drupal/includes/module.inc(479):
drupal_install_schema('redirect')
#6
phar:///usr/local/bin/drush/commands/core/drupal/environment_7.inc(143):
module_enable(Array)
#7 phar:///usr/local/bin/drush/commands/pm/pm.drush.inc(1167):
drush_module_enable(Array)
#8 [internal function]: drush_pm_enable('redirect')
#9 phar:///usr/local/bin/drush/includes/command.inc(371):
call_user_func_array('drush_pm_enable', Array)
#10 phar:///usr/local/bin/drush/includes/command.inc(222):
_drush_invoke_hooks(Array, Array)
#11 [internal function]: drush_command('redirect')
#12 phar:///usr/local/bin/drush/includes/command.inc(190):
call_user_func_array('drush_command', Array)
#13 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#14 phar:///usr/local/bin/drush/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#15 phar:///usr/local/bin/drush/includes/startup.inc(458):
drush_main()
#16 phar:///usr/local/bin/drush/includes/startup.inc(365):
drush_run_main(false, '/', 'Phar detected. ...')
#17 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#18 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#19 {main}
Comment | File | Size | Author |
---|---|---|---|
#11 | redirect-index-length-2815099-11.patch | 896 bytes | andralex |
Comments
Comment #2
malcomio CreditAttribution: malcomio at Capgemini commentedComment #3
malcomio CreditAttribution: malcomio at Capgemini commentedOn several sites that were running 7.x-1.0-rc1, I've observed a similar issue trying to run update 7101 after upgrading to 7.x-1.0-rc3, even after applying the changes in #2541304: update 7101 failing.
Comment #4
malcomio CreditAttribution: malcomio at Capgemini commentedStill need to investigate further, but the error I've observed seems to relate to an instance where the size of the redirect and source columns had been increased at some point in the history of the site.
After reducing them to match the module schema (i.e. varchar 255), the updates completed successfully.
See also #2057615: Increase size of source field to hold long URLs
Comment #5
anrikun CreditAttribution: anrikun commentedStill an issue in 7.x-1.x.
New install crashes with exception:
PDOException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 3072 bytes: CREATE TABLE {redirect} ( `rid` INT NOT NULL auto_increment COMMENT 'Primary Key: Unique redirect ID.', `hash` VARCHAR(64) NOT NULL COMMENT 'A unique hash based on source, source_options, and language.', `type` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'The redirect type; if value is ’redirect’ it is a normal redirect handled by the module.', `uid` INT unsigned NOT NULL DEFAULT 0 COMMENT 'The users.uid of the user who created the redirect.', `source` VARCHAR(900) NOT NULL COMMENT 'The source path to redirect from.', `source_options` BLOB NOT NULL COMMENT 'A serialized array of source options.', `redirect` VARCHAR(900) NOT NULL COMMENT 'The destination path to redirect to.', `redirect_options` BLOB NOT NULL COMMENT 'A serialized array of redirect options.', `language` VARCHAR(12) NOT NULL DEFAULT 'und' COMMENT 'The language this redirect is for; if blank, the alias will be used for unknown languages.', `status_code` SMALLINT NOT NULL COMMENT 'The HTTP status code to use for the redirect.', `count` INT unsigned NOT NULL DEFAULT 0 COMMENT 'The number of times the redirect has been used.', `access` INT unsigned NOT NULL DEFAULT 0 COMMENT 'The timestamp of when the redirect was last accessed.', `status` SMALLINT NOT NULL DEFAULT 1 COMMENT 'Boolean indicating whether the redirect is enabled (visible to non-administrators).', PRIMARY KEY (`rid`), UNIQUE KEY `hash` (`hash`), INDEX `expires` (`type`, `access`), INDEX `status_source_language` (`status`, `source`(255), `language`), INDEX `redirect` (`redirect`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT 'Stores information on redirects.'; Array ( ) dans db_create_table() (ligne 2776 dans [...]/includes/database/database.inc).
Comment #6
Tolyan4ik CreditAttribution: Tolyan4ik at EPAM Systems commentedI installed the module using the drash command on branch 7.x-1.x, 7.x-2.x and everything is working fine, can you provide more information how I can reproduce the error.
Comment #7
anrikun CreditAttribution: anrikun commentedYou must use collate utf8mb4_general_ci to reproduce this bug.
Comment #8
andralex CreditAttribution: andralex at EPAM Systems for EPAM Systems commentedI've used collate utf8mb4_general_ci on the database:
Tested on commit 4fdcb8fe519f1c25b8a2ab0b2d883d9c6ebaaf09 from branch 7.x-1.x and it works for me.
The same result is on 7.x-2.x branch for 6d8aa2aa85752f37e2b45628a1d12717cc652b04 commit.
Comment #9
anrikun CreditAttribution: anrikun commentedYour query reports utf8_general_ci, not utf8mb4_general_ci!
To reproduce the bug, you must try to install the module on a utf8mb4_general_ci installation.
See https://www.drupal.org/node/2754539
Comment #10
andralex CreditAttribution: andralex at EPAM Systems for EPAM Systems commentedSorry, my bad. It's reproduced now with exact collation.
Comment #11
andralex CreditAttribution: andralex at EPAM Systems for EPAM Systems commentedI've fixed the issue by reducing the index length for 'redirect' and 'source' columns.
Comment #12
andralex CreditAttribution: andralex at EPAM Systems for EPAM Systems commentedComment #13
anrikun CreditAttribution: anrikun commentedIt works thanks!
Comment #14
pifagorComment #16
pifagor