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.
field_encrypt_update_7000()
runs with mysql errors (duplicate insert). But by that time, db_drop_table('field_encrypt');
has already dropped the table. So all data is lost.
This kind of drop_table statement should be in a separate field_encrypt_update_7001()
, so the first update can run correctly before dropping the table. To avoid data loss.
I luckily had a backup so I could restore the field_encrypt table.
Comment | File | Size | Author |
---|---|---|---|
#16 | 2314327-16.patch | 7.36 KB | Manuel Garcia |
#16 | interdiff-2314327-14-16.txt | 12.85 KB | Manuel Garcia |
#14 | update_revisions_memory_long_run.patch | 9.08 KB | tom.smith |
#11 | Update_error-2314327-11.patch | 1.42 KB | nileshlohar |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedAnd this is the error I get
Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'profile2-10-0-0-und' for key 'PRIMARY': INSERT INTO {field_data_field_account_holder_name} (entity_type, bundle, deleted, entity_id, revision_id, language, delta, field_account_holder_name_value) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => profile2 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => 10 [:db_insert_placeholder_4] => 10 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => a:6:{s:4:"text";s:44:"07sxEubjWRhUOijXS0sTQLTrWZL/N9q9imuz5+D0hTc=";s:6:"method";s:14:"mcrypt_rij_256";s:12:"key_provider";s:4:"file";s:7:"options";a:1:{s:6:"base64";b:1;}s:15:"method_settings";s:0:"";s:17:"provider_settings";a:2:{s:4:"path";s:37:"/var/www/vhosts/123.io/secure_files";s:6:"method";s:13:"file_contents";}} ) in drupal_write_record() (line 7209 of /var/www/vhosts/123.io/httpdocs/includes/common.inc).
Comment #2
eelkeblokWouldn't it be enough to move the db_drop_table to below all the migration logic, instead of making a whole separate update hook?
Comment #3
Deciphered CreditAttribution: Deciphered commentedThe update hook has been updated in the latest Dev release, please re-test and confirm whether this is still an issue.
Comment #4
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commentedThe "7.x-1.0-beta2" has been released 3 years ago.
Could you release another one, even still in beta ?
Comment #5
Deciphered CreditAttribution: Deciphered commentedMaybe if people tested the latest dev releases and confirmed issues had been resolved I'd be able to reliably release the next version ;)
The current dev should be good for a release, but I've had no feedback yet.
Comment #6
Kcannick CreditAttribution: Kcannick commented@deciphered how can I help with testing?
Comment #7
Deciphered CreditAttribution: Deciphered commented@Kcannick,
Use it, determine if there are any bugs in it. Anything helps.
Comment #8
colanI just opened #2779853: EntityStorageException: Missing bundle for entity type node.
Comment #9
Deciphered CreditAttribution: Deciphered commented@colan,
This issue is about 7.x, that issue is about 8.x.
Comment #10
Kcannick CreditAttribution: Kcannick commentedI am randomly receiving ERROR messages throughout site. "Decryption failed because the HMAC could not be validated." Error appears multiple times on a page load. Using Encrypt 2.3
Comment #11
nileshlohar CreditAttribution: nileshlohar commentedI got the following error in field_encrypt_update_7000() while updating from 7.x-1.0-beta2 to 7.x-1.0-beta3.
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node-3-0-0-und' for key 'PRIMARY' [error]
Scenario :
When node revisioning is enabled "field_encrypt" table has multiple records for single node id.
and in field_encrypt_update_7000() it tries to copy all records from field_encrypt to both field_data_body and field_revision_body (body field example) DB tables.
and get Integrity constraint violation error on field_data_body table.
Solution :
Attaching a patch which checks the revision id of record being migrated from "field_encrypt" table, and depending on the revision id it migrates only
current revision to field_data_body and field_revision_body table else to field_revision_body only.
Also moving Drop table statement to end of the function so even if we get any error during update there is no data loss and we can re-run the update hook.
Comment #12
tom.smith CreditAttribution: tom.smith commented@nileshlohar I think you patch is messed up. Whenever I try and apply it is I get a 1 out of 3 Hunks failed. Ill try and make another one sometimes this week but wanted to mention it here. But thanks for solving the revisions issue.
Comment #13
tom.smith CreditAttribution: tom.smith as a volunteer commentedI wanted to give an update. I am almost done rewriting the field_encrypt_update_7000 update. I am adding support for multipass update to stop the out of memory errors for datasets over 15k. Not exactly related to the revision bug but does kill the update.
It is causing me to have to rewrite field_encrypt_do_encrypt and field_encrypt_un_encrypt too. Hopefully this will be beneficial to anyone using this module for a lot of data...
Comment #14
tom.smith CreditAttribution: tom.smith as a volunteer commentedI have added my patch. It extends the patch made by @nileshlohar.
The major improvements is batch processing to keep from running out of memory or timing out in php.
I have tested with about 250MB (200k) of encrypted data and it works fine.
Comment #15
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThanks for the patch @tom.smith, here's just a CS review:
Unrelated, and incorrect indentation.
Unrelated, and wrong indentation.
Also, the function
field_encrypt_update_7000
is incorrectly indented, and the install file needs a newline at end of file.Comment #16
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedJust fixing my own CS review in order to facilitate an easier code review:
Comment #17
nubeli CreditAttribution: nubeli as a volunteer and at Freeform Solutions commentedLooks like this is unlikely to be fixed in the 7.x-1,x branch. Thank you Tom and Manuel for the patches. I ended up using the batched process patch (https://www.drupal.org/files/issues/2018-05-31/2314327-16.patch) in my patch to the Backdrop port of this module: https://github.com/backdrop-contrib/field_encrypt/pull/6/files. It is almost identical so I thought I'd share it here. I had to fix some issues with that patch:
$vid == $result->revision_id
, not$id == $result->revision_id
. In the latter it never populates thefield_data_*
tablefield_encrypt_encrypt()
call that has a fatal error because it's missing a line to load the inc file. Should havemodule_load_include('inc', 'field_encrypt', 'field_encrypt');
above the foreach.db_table_exists()
because you never know.After that it ran fine, and I believe it should work fine for Drupal 7 as well. I had a client that was using the old beta and there is no working upgrade path for the 7.x-1.x branch so I decided to incorporate it into the Backdrop port so others can benefit as well.