I received this error after running update.php...

The following updates returned messages

masquerade module

Update #7000
Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'bob-masquerade-masquerade' for key 2: UPDATE {block} SET delta=:db_update_placeholder_0 WHERE (module = :db_condition_placeholder_0) AND (delta = :db_condition_placeholder_1) ; Array ( [:db_update_placeholder_0] => masquerade [:db_condition_placeholder_0] => masquerade [:db_condition_placeholder_1] => 0 ) in masquerade_update_7000() (line 171 of /home/public_html/sites/all/modules/masquerade/masquerade.install).

Comments

andypost’s picture

Priority: Normal » Critical

Can someone reproduce this?

shark’s picture

I have what appears to be the same issue.

The following updates are pending:

masquerade module : 
  7000 -   Update masquerade block delta. 
  7001 -   Update masquerade block caching. 

Do you wish to run all pending updates? (y/n): y
7000SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'marinelli-masquerade-masquerade' for key 'tmd'                          [error]
Performed update: masquerade_update_7000                                                                                                       [ok]
Finished performing updates.           

In case it helps, here are the relevant database table rows:

mysql> select * from drupal_block where module = 'masquerade';
+-----+------------+------------+---------------+--------+--------+---------------+--------+------------+-------+-------+-------+
| bid | module     | delta      | theme         | status | weight | region        | custom | visibility | pages | title | cache |
+-----+------------+------------+---------------+--------+--------+---------------+--------+------------+-------+-------+-------+
|  60 | masquerade | masquerade | acquia_marina |      1 |      0 | sidebar_first |      0 |          0 | blank |       |    -1 |
|  69 | masquerade | masquerade | nitobe        |      0 |    -21 |               |      0 |          0 | blank |       |    -1 |
|  88 | masquerade | masquerade | rubik         |      0 |     -5 |               |      0 |          0 | blank |       |    -1 |
| 112 | masquerade | masquerade | absynthe      |      0 |      0 |               |      0 |          0 | blank |       |    -1 |
| 125 | masquerade | masquerade | beach         |      0 |      0 |               |      0 |          0 | blank |       |    -1 |
| 149 | masquerade | masquerade | tma           |      0 |      0 |               |      0 |          0 | blank |       |    -1 |
| 173 | masquerade | masquerade | garland       |      0 |      0 |               |      0 |          0 | blank |       |    -1 |
| 344 | masquerade | masquerade | magazeen      |      0 |    -21 |               |      0 |          0 | blank |       |    -1 |
| 375 | masquerade | 0          | marinelli     |      0 |    -21 |               |      0 |          0 | blank |       |    -1 |
| 418 | masquerade | 0          | custom        |      0 |    -21 | sidebar_first |      0 |          0 | blank |       |    -1 |
| 679 | masquerade | masquerade | marinelli     |      0 |      0 | -1            |      0 |          0 |       |       |    -1 |
+-----+------------+------------+---------------+--------+--------+---------------+--------+------------+-------+-------+-------+

Note that the blocks with IDs 375 and 679 have the same theme ("marinelli") and module ("masquerade") in the table results.

Quick Fix: I was able to get the update to run by removing the almost-duplicate row (679 in this example).

The other thing that may be unique about my situation I should note is that this happened during a Drupal upgrade (using drush site-upgrade from 6 to 7), where Marinelli theme was downloaded and upgraded (and drush had incorrectly downloaded it to the modules directory so I had to move it and enable it manually).

After masquerade_update_7000() ran without errors, my table looked as it should:

mysql> select * from drupal_block where module = 'masquerade';
+-----+------------+------------+---------------+--------+--------+---------------+--------+------------+-------+-------+-------+
| bid | module     | delta      | theme         | status | weight | region        | custom | visibility | pages | title | cache |
+-----+------------+------------+---------------+--------+--------+---------------+--------+------------+-------+-------+-------+
|  60 | masquerade | masquerade | acquia_marina |      1 |      0 | sidebar_first |      0 |          0 | blank |       |    -1 |
|  69 | masquerade | masquerade | nitobe        |      0 |    -21 |               |      0 |          0 | blank |       |    -1 |
|  88 | masquerade | masquerade | rubik         |      0 |     -5 |               |      0 |          0 | blank |       |    -1 |
| 112 | masquerade | masquerade | absynthe      |      0 |      0 |               |      0 |          0 | blank |       |    -1 |
| 125 | masquerade | masquerade | beach         |      0 |      0 |               |      0 |          0 | blank |       |    -1 |
| 149 | masquerade | masquerade | tma           |      0 |      0 |               |      0 |          0 | blank |       |    -1 |
| 173 | masquerade | masquerade | garland       |      0 |      0 |               |      0 |          0 | blank |       |    -1 |
| 344 | masquerade | masquerade | magazeen      |      0 |    -21 |               |      0 |          0 | blank |       |    -1 |
| 375 | masquerade | masquerade | marinelli     |      0 |    -21 |               |      0 |          0 | blank |       |    -1 |
| 418 | masquerade | masquerade | custom        |      0 |    -21 | sidebar_first |      0 |          0 | blank |       |    -1 |
+-----+------------+------------+---------------+--------+--------+---------------+--------+------------+-------+-------+-------+

Hope that helps anyone else who might have this issue.

shark’s picture

Also, I found this comment useful: http://drupal.org/node/1700662#comment-6302130

Jim Bacon’s picture

Upgrading from Masquerade 6.x-1.9 to 7.x-1.0-rc7 received the error

a. Update #7000 Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'garland-masquerade-masquerade' for key 'tmd': UPDATE {block} SET delta=:db_update_placeholder_0 WHERE (module = :db_condition_placeholder_0) AND (delta = :db_condition_placeholder_1) ; Array ( [:db_update_placeholder_0] => masquerade [:db_condition_placeholder_0] => masquerade [:db_condition_placeholder_1] => 0 ) in masquerade_update_7000() (line 171 of sites\all\modules\masquerade\masquerade.install).

Contents of blocks table (minus a couple of columns) as follows

| bid | module     | delta      | theme   | status | weight | region |
|-----|------------|------------|---------|--------|--------|--------|
| 47  | masquerade | 0          | irecord | 1      | -9     | footer |
| 53  | masquerade | 0          | garland | 0      | 0      |        |
| 67  | masquerade | masquerade | garland | 0      | 0      | -1     |

Deleted block with bid=67, ran update.php again and all seems well.

macman’s picture

Issue summary: View changes

Thanks kruser. Worked a treat

tinker’s picture

Well this is a weird one. This module's update code (7000 and 7001) both looks fine and should not cause this problem. I too experienced this doing a D6 -> D7 upgrade. I was using drush for the upgrade. My D6 DB has the following (similar column values omitted for brevity):

+-----+-------+-----------+--------+--------+--------+-------+
| bid | delta | theme     | status | weight | region | cache |
+-----+-------+-----------+--------+--------+--------+-------+
| 223 | 0     | co_custom |      1 |    -66 | right  |    -1 |
| 226 | 0     | blueprint |      0 |      0 |        |    -1 |
| 293 | 0     | garland   |      0 |      0 |        |    -1 |
+-----+-------+-----------+--------+--------+--------+-------+

But the D7 DB has:

+-----+------------+-----------+--------+--------+----------------+-------+
| bid | delta      | theme     | status | weight | region         | cache |
+-----+------------+-----------+--------+--------+----------------+-------+
| 223 | masquerade | co_custom |      1 |    -66 | sidebar_second |    -1 |
| 226 | masquerade | blueprint |      0 |      0 |                |    -1 |
| 293 | 0          | garland   |      0 |      0 |                |    -1 |
| 508 | masquerade | garland   |      0 |      0 | -1             |    -1 |
+-----+------------+-----------+--------+--------+----------------+-------+

I have no idea where bid '508' came from and bid '293' should have delta 'masquerade'. This looks to be caused by another module?

rossb89’s picture

Can confirm this issue as well from a Drupal 6 -> 7 site upgrade.

Haven't got time to step through exactly and see why there are 'duplicate' blocks being inserted into the database *with* the masquerade delta, thus causing masquerade_update_7000 to fail.

Confirmed that the quick fix is to delete the duplicate entries in the {block} table, maybe one day if I have more time can try and see at what point in the site upgrade process this issue occurs and can work a fix :)

geekinpink’s picture

#2 works for me ...Thanks