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.
PDOException is thrown when saving a new environment with existing hostname.
Can be produced by:
Saving a new environment with machine name "example" and hostname "example.com".
When saving another environment with the same machine name "example" and some hostname eg. "example.org", following error is thrown:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'example' for key 'name': INSERT INTO {environment_indicator_environment} (machine, name, regexurl, settings) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => example [:db_insert_placeholder_1] => example [:db_insert_placeholder_2] => example.org [:db_insert_placeholder_3] => a:5:{s:5:"color";s:7:"#d0d0d0";s:10:"text_color";s:7:"#ffffff";s:6:"weight";s:0:"";s:8:"position";s:3:"top";s:5:"fixed";i:0;} ) in drupal_write_record() (line 7239 of /private/var/www/vanilla/includes/common.inc).
Comment | File | Size | Author |
---|---|---|---|
#1 | environment_indicator-existing-machine-names-2378025-1.patch | 795 bytes | ilkkave |
Comments
Comment #1
ilkkave CreditAttribution: ilkkave commentedHere's a patch for the issue.
Argument placeholder in db_query() function was wrapped in single quotes, resulting in wrong return value when checking if machine name is available.
Comment #2
ilkkave CreditAttribution: ilkkave commentedComment #3
e0ipsoThis has been merged.
Thank you for your contribution!!