After enabling the bean_uuid module, it creates a uuid field on the bean table and vuuid on the bean_revision table. The existing bean data is updated to include unique UUIDs for both of these fields and this works as expected. However, subsequent bean revisions that are created after enabling the bean_uuid module re-use the same vuuid. The vuuid values should be unique per revision, not unique per bean entity as it is now.

Comments

badjava created an issue. See original summary.

skwashd’s picture

I haven't had time to roll and test a patch for this but I've had a look through the code. The bean_uuid sub module needs to implement hook_bean_presave(). The hook should check if $bean->is_new_revision isset() to see if it is a new revision. If it is a new revision then $bean->vuuid needs to be assigned a new UUID by calling uuid_generate(). Something like this should do the trick:

<?php
/**
 * Implements bean_presave().
 */
function bean_uuid_bean_presave(&$bean) {
  if (isset($bean->is_new_revision()) {
    $bean->vuuid = uuid_generate();
  }
}

?>
badjava’s picture

Status: Active » Needs review
StatusFileSize
new536 bytes

Here is a patch based on @skwashd's comments. We may want to add a hook_update function to clean up all the existing revisions with duplicate vuuids.

dixon_’s picture

Status: Needs review » Reviewed & tested by the community

Looks good

damienmckenna’s picture

Status: Reviewed & tested by the community » Needs work

Agreed, this needs an update script.

badjava’s picture

Status: Needs work » Needs review
StatusFileSize
new1.18 KB

Patch has been updated with a hook_update implementation.

badjava’s picture

Status: Needs review » Needs work
badjava’s picture

Status: Needs work » Needs review
StatusFileSize
new1.35 KB

Updated the hook_update implementation to only empty the value of inactive revisions as they will contain duplicate vuuids and then regenerate them. The active revision is left alone with its existing vuuid.

Status: Needs review » Needs work

The last submitted patch, 8: bean-duplicate-revision-uuids-2857677-8.patch, failed testing.

skwashd’s picture

Status: Needs work » Reviewed & tested by the community

Let's see if the bot is still misbehaving.

skwashd’s picture

Status: Reviewed & tested by the community » Needs review

Fixing status

damienmckenna’s picture

Status: Needs review » Needs work

In case there are a large number of UUID-enabled entities in the system, I think uuid_sync_all() should be in its own update script.

badjava’s picture

Status: Needs work » Needs review
StatusFileSize
new1.45 KB
new972 bytes

Agreed and good catch - here is an updated patch with an interdiff from #8.

timaholt’s picture

Status: Needs review » Reviewed & tested by the community

I've reviewed the code and tested the patch in #13 in a complex site with the parent issue, and the module and update hooks resolve the issue for me.

badjava’s picture

Is it possible to get this patch committed? Thanks!

damienmckenna’s picture

Thinking through the logic here.. if uuid_sync_all() times out in bean_uuid_update_7203() what would happen? IIRC the process will fail and the next time the updates are ran it'll try to do the same update only with fewer records to go. Right?

damienmckenna’s picture

Now that we have support for Devel (Contrib) Generate via #2894053 I'm going to see about manually testing this with a bazillion beans.

indytechcook’s picture

A site with a bazillion beans (fun to say) would be running this via drush anyway. PHP CLI default timeout is 0 so it would just run forever. I'm committing this. Good work!

  • indytechcook committed f90a5fb on 7.x-1.x authored by badjava
    Issue #2857677 by badjava, DamienMcKenna, skwashd: Revision UUIDs are...
indytechcook’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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