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).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ilkkave’s picture

Here'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.

ilkkave’s picture

Status: Active » Needs review
e0ipso’s picture

Status: Needs review » Fixed

This has been merged.

Thank you for your contribution!!

  • e0ipso committed e10ef5e on 7.x-2.x authored by ilkkave
    Issue #2378025 by ilkkave [BUGFIX] Fix PDO Exception for duplicates
    
    The...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.