When attempting to save a revision as a new record by uuid, entity_uuid_save() will change the revision flag to 0 (since the vid isn't set because the vuuid doesn't exist, but the is_new flag is turned off because the UUID does exist in the database) in entity_make_entity_local() before it calls entity_save(), and therefore the node will only get updated and revisions will not be saved.

CommentFileSizeAuthor
#4 save_node_new_revision-1890666.patch811 bytestimaholt

Comments

getweed’s picture

Version: 7.x-1.0-alpha3 » 7.x-1.x-dev
Component: Code » Documentation
Assigned: Unassigned » getweed
Category: bug » task
Status: Active » Patch (to be ported)
skwashd’s picture

Component: Documentation » Code
Category: task » bug
Status: Patch (to be ported) » Active

Updating fields to reflect the correct information for the issue.

@getweed are you planning on fixing this issue? If not please unassign it from yourself.

timaholt’s picture

@getweed what is your use case here? I'm about to work up a patch to change this behavior if the vuuid does exist if the revision is being pushed in via deploy. It's easy enough to check for isset($entity->{$vuuid_key}) and then flick the revision switch to 1, but that is the use case I have for it. It sounds like you have a use case where you are saving the node without a vid or vuuid, but still want to force a revision?

timaholt’s picture

Assigned: getweed » Unassigned
Status: Active » Needs review
StatusFileSize
new811 bytes

Ok attached is a patch that will see if the content type has revisions enabled by default, and then change $entity->revision to 1 if that is the case. This should work for both of our use cases. Can you review?

dixon_’s picture

Issue summary: View changes
Status: Needs review » Fixed

Simple fix. Committed. Thanks.

dixon_’s picture

I ended up moving this code to a place that I thought made more sense. Please see: http://drupalcode.org/project/uuid.git/blobdiff/0dafb9f59b171adba74aea13...

Edit: I also added some tests.

Status: Fixed » Closed (fixed)

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