While running update.php on a migrated site the following messages are returned:

print_pdf module
Update #7000

    * Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'seven-print_pdf-print_pdf-top' 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] => print_pdf-top [:db_condition_placeholder_0] => print_pdf [:db_condition_placeholder_1] => 0 ) in update_fix_d7_block_deltas() (Zeile 363 von /var/www/html/cm7/includes/update.inc).

print_mail module
Update #7000

    * Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'seven-print_mail-print_mail-top' 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] => print_mail-top [:db_condition_placeholder_0] => print_mail [:db_condition_placeholder_1] => 0 ) in update_fix_d7_block_deltas() (Zeile 363 von /var/www/html/cm7/includes/update.inc).

print module
Update #7000

    * Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'seven-print-print-links' 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] => print-links [:db_condition_placeholder_0] => print [:db_condition_placeholder_1] => 0 ) in update_fix_d7_block_deltas() (Zeile 363 von /var/www/html/cm7/includes/update.inc).

After confirming the update messages the site seems not to be really affected.

The site was migrated from Drupal 6.20.

CommentFileSizeAuthor
#22 backup-2011-09-29T08-44-04.sql_.gz1.66 MBstrellman

Comments

shelleyp’s picture

Yes, I also received the following:

Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'garland-print-print-links' 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] => print-links [:db_condition_placeholder_0] => print [:db_condition_placeholder_1] => 0 ) in update_fix_d7_block_deltas() (line 363 of /home/frugalalgorithm/public_html/includes/update.inc).

shelleyp’s picture

Priority: Normal » Critical

moved this to critical, since the module is not usable as coded with an updated site

GStegemann’s picture

The problem occurs on migrated themes which already exists in Drupal 7, like "Seven" or others.

I fixed it by removing the old hardcoded deltas from the "block" table, like records where column "delta" has values like "0", "1", etc., which belong to the modules "print", "print_mail" or "print_pdf" and had already "new" deltas by name. After that update.php completed successfully.

The reported duplicated keys have to be interpreted in the following way, e.g "seven-print-print-links" whereby "seven" is the theme, "print" the effecitive module and "print-links" the block delta.

May be the error is not really related to the module "print" but possibly to the core function "update_fix_d7_block_deltas".

pillarsdotnet’s picture

Project: Printer, email and PDF versions » Drupal core
Version: 7.x-1.x-dev » 7.x-dev
Component: Code » database update system
marcingy’s picture

Priority: Critical » Major

This is not critical

strellman’s picture

Please clarify what is meant by #3.
Is this fixed in 7.x-dev?
Is the workaround to delete all themes or all blocks before upgrading? If so, how?

GStegemann’s picture

No, in my opinion nothing is fixed yet.

I've just described a workaround for the print module how to migrate a site from D6 to D7 and what is causing the problem. It may be possible that there is a bug in the core function "update_fix_d7_block_deltas" which used to perform this block delta conversions.

See also #6.

pillarsdotnet’s picture

agileware’s picture

Title: Update #7000 returns message "Duplicate entry 'seven-print_pdf-print_pdf-top'" » Possible bug in "update_fix_block_deltas" function.
pillarsdotnet’s picture

Title: Possible bug in "update_fix_block_deltas" function. » Possible bug in "update_fix_d7_block_deltas" function.
bfroehle’s picture

Does anybody have a D6 database dump which exhibits this error when you upgrade? Otherwise there really isn't enough here to go on...

GStegemann’s picture

No, not anymore. But comment #3 maybe of help.

bfroehle’s picture

Status: Active » Postponed (maintainer needs more info)

I don't think there is anything we can do here until there is at way to reproduce this.

GStegemann’s picture

I thought I had given enough details why these errors are thrown during a migration of a D6 site.

However, here are dumps of the relevant data from a D6 "blocks" and D7 "block" table:

D6 "blocks" table:

mysql> select * from igs_intra_blocks where module like 'print%' and theme='seven';
+-----+------------+-------+-------+--------+--------+---------+--------+----------+------------+-------+-------+-------+
| bid | module     | delta | theme | status | weight | region  | custom | throttle | visibility | pages | title | cache |
+-----+------------+-------+-------+--------+--------+---------+--------+----------+------------+-------+-------+-------+
| 983 | print      | 0     | seven |      0 |    -36 | content |      0 |        0 |          0 |       |       |     4 |
| 974 | print      | 1     | seven |      0 |    -45 | content |      0 |        0 |          0 |       |       |     8 |
| 971 | print_mail | 0     | seven |      0 |    -48 | content |      0 |        0 |          0 |       |       |     8 |
| 973 | print_pdf  | 0     | seven |      0 |    -46 | content |      0 |        0 |          0 |       |       |     8 |
+-----+------------+-------+-------+--------+--------+---------+--------+----------+------------+-------+-------+-------+


D7 "block" table:

mysql> select * from igs_intra_block where module like 'print%' and theme='seven';
+------+------------+----------------+-------+--------+--------+--------+--------+----------+------------+-------+-------+-------+-----------+
| bid  | module     | delta          | theme | status | weight | region | custom | throttle | visibility | pages | title | cache | i18n_mode |
+------+------------+----------------+-------+--------+--------+--------+--------+----------+------------+-------+-------+-------+-----------+
| 1572 | print      | print-links    | seven |      0 |      0 | -1     |      0 |        0 |          0 |       |       |     4 |         0 |
| 1573 | print      | print-top      | seven |      0 |      0 | -1     |      0 |        0 |          0 |       |       |     8 |         0 |
| 1185 | print_mail | print_mail-top | seven |      0 |      0 | -1     |      0 |        0 |          0 |       |       |     8 |         0 |
| 1186 | print_pdf  | print_pdf-top  | seven |      0 |      0 | -1     |      0 |        0 |          0 |       |       |     8 |         0 |
+------+------------+----------------+-------+--------+--------+--------+--------+----------+------------+-------+-------+-------+-----------+


The key information is:

  • an identical theme must be installed in both versions (D6 site to be migrated and D7 installation),
  • a contributed module like Print PDF is part of the migration.

  • The job of the core function "update_fix_d7_block_deltas" is to convert the data in column 'delta' into a D7 compatible format. But the function fails when the to be migrated "block deltas" do already exist in D7; i.e. when the contributed module is already installed in D7 and both installation have also the same theme installed. Then a clash occurs, since the D6 numerical "block deltas" are about to be converted to D7 "block deltas" with identical names/IDs.

    In my opinion "update_fix_d7_block_deltas" should check this and skip any possible duplicates.

    I hope this helps.

    pillarsdotnet’s picture

    Status: Postponed (maintainer needs more info) » Active
    bfroehle’s picture

    Title: Possible bug in "update_fix_d7_block_deltas" function. » update_fix_d7_block_deltas() should silently succeed if block deltas have already been migrated.

    Thanks @GStegemann. So what's happening is that you upgrade to D7, install the new version contributed modules, use the site for a bit (so that the new version's blocks are added to the database), then run upgrade.php but it throws these duplicate key errors.

    This means the issue could be avoided in two ways. The first is to immediately run update.php upon installing the new D7 modules. The second, as you suggest, is to make update_fix_d7_block_deltas() succeed in cases where there would otherwise be duplicate key errors.

    GStegemann’s picture

    @bfroehle, you're welcome.

    No, the scenario was a little bit different. I migrated the site as described in the Drupal 7 Upgrade Guide. The Print PDF module was already installed on the D6 site. After installation of Drupal 7 I migrated module by module and ran update.php immediately once a module was enabled. And during the migration of the Print PDF module the reported errors were displayed.

    So I see no way to avoid this issue in this context. Maybe one other possible way to avoid this is not to have the same themes installed which have enabled blocks of such a module.

    And the third way of course is, just to ignore any possible duplicate keys. And instead of throwing error messages just showing/logging a warning message.

    catch’s picture

    Issue tags: +D7 upgrade path

    tagging.

    sun’s picture

    Version: 7.x-dev » 8.x-dev
    Priority: Major » Normal
    Issue tags: +Needs backport to D7

    1) Looks like contrib modules' updates need to run after this update. We have hook_update_dependencies() for that.

    2) Looks like this could be easily resolved by switching to a merge query.

    3) There's a workaround for this issue (see 1)), so demoting to normal.

    peterx’s picture

    I upgraded D6.22 to D7.4 and hit the 7004 problem. As per #3, I checked for print module entries in the block table. There were no print module entries in the block table. There was nothing for non core modules because I deleted all the non core modules before the update. I deleted everything for every theme except Garland and still hit the 7004 problem. I then emptied the block table and update 7004 worked.

    strellman’s picture

    StatusFileSize
    new1.66 MB

    I am still unable to update this site to D7. I first reported this problem with block update 33 weeks ago.
    not sure why this issue is on D8 now.
    I tried solution #21, no joy.

    Update #7004
    Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Contact page help' for key 'info': INSERT INTO {block_custom} (body, info, format) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => Find us at this place. [:db_insert_placeholder_1] => Contact page help [:db_insert_placeholder_2] => 3 ) in block_update_7004() (line 304 of /home1/mysite/public_html/d7/modules/block/block.install).

    Attached is the D6.22 backup I am trying to upgrade to D7.8
    Update.php should fail on a clean D7.8 install.

    strellman’s picture

    I only had 2 custom blocks, both were simple text. So I went back to Drupal 6.22 and deleted both blocks, redid my backup, disabled all modules (even some of the core optional), then ran update.php and it worked. Complained about my marinelli theme, guess I should have made something else the default, but that is easy.

    I can leave the backup there for a week or two in case someone wants to use that as a test case that causes the block update to fail.

    catch’s picture

    Version: 8.x-dev » 7.x-dev
    Priority: Normal » Major

    It's at least major if the upgrade path fails. I don't see a workaround in #1. Also moving back to D7.

    catch’s picture

    Priority: Major » Normal

    Hmm I might have mis-read #20 - hook_update_dependencies() is probably enough of a workaround.

    Since this hasn't been reported since over a year ago, demoting the issue - however if you're following this issue and it's still a problem for you, please bump back to major.

    Status: Active » Closed (outdated)

    Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.