starting to get my head around the node revision code for the save as draft feature, and it seems that logging in the node revision code is buggy.

first, a versioned node's log has its div's stripped on pages that use the restricted html filter. i think this is a bug. moving the appending of the log message to the node body after node_prepare() in node_view() seems to fix this. if this doesn't sound bad, i'll roll a patch.

second, a versioned node displays the last revision log message by default, and there doesn't seem to be any way to turn it off. seems like there should be a way for an admin to control this.

third, the content of the log is just wrong. if i edit a versioned node that has a log associated with it, then the log from the edited revision is inherited by the new revision, regardless of whether its accurate.

i'm happy to roll some patches for these, because i'll be knee deep in the node code for the next few weeks, but i'd like some feedback.

CommentFileSizeAuthor
#6 node_revision_log.1.patch.txt654 bytesAnonymous (not verified)
#4 node_revision_log.patch.txt654 bytesAnonymous (not verified)
#3 node_log.1.patch.txt1.07 KBAnonymous (not verified)
#1 node_log.patch.txt635 bytesAnonymous (not verified)

Comments

Anonymous’s picture

Assigned: Unassigned »
Status: Active » Needs review
StatusFileSize
new635 bytes

here's a patch for the log having its div stripped problem.

killes@www.drop.org’s picture

Would you mind to re-roll that patch as a nufied patch? diff -up

Anonymous’s picture

StatusFileSize
new1.07 KB

attached.

Anonymous’s picture

StatusFileSize
new654 bytes

just tested eaton's $node->body with arrays patch, and it doesn't fix any of the revision log bugs, so here's a patch that ensures that if a $node->log is saved, it came from a revision operation, and not just from the node being updated.

dries’s picture

Status: Needs review » Needs work

Not tested, but the variable name in the code comment doesn't match. Personally, this looks like a strange fix (a bit of a hack). How come the value is set incorrectly in the first place? Needs more investigation, IMO.

Anonymous’s picture

StatusFileSize
new654 bytes

new patch with typo in comment attached.

Not tested, but the variable name in the code comment doesn't match. Personally, this looks like a strange fix (a bit of a hack). How come the value is set incorrectly in the first place? Needs more investigation, IMO.

the value is not so much set incorrectly as just carried over from node_load(). backtracking a bit - node_revision_revert is the only code in node.module that sets a value for $node->log:

$node->log = t('Copy of the revision from %date.', array('%date' => theme('placeholder', format_date($node->revision_timestamp))));
$node->taxonomy = array_keys($node->taxonomy);

node_save($node);

problem is, when the node with the revision log is updated, if $node->log on the $node passed in to node _save is not set, then the log message is just carried over, because of this code in node_save:

// We need to ensure that all node fields are filled.
$node_current = node_load($node->nid);
foreach ($node as $field => $data) {
  $node_current->$field = $data;
}

so, my first thought was to patch node_save to make sure it didn't save the log from the old revision if the node being passed in doesn't have a log value.

alternatively, we could:
- ensure that the $node passed in to node_save always has $node->log set, even if its empty
- implement hook_load or hook_nodeapi in node.module to handle the unsetting $node->log

suggestions as to which way to go?

moshe weitzman’s picture

the current behavior where you see the last log message upon editing is odd to me. i think this field should always be blank when you start editing. it is a place for entering the *new* log message. So, I suggest setting #default_value to '' for the log textarea.

my .02

pwolanin’s picture

Probably will need to be changed to accomodate this:

http://drupal.org/node/74326

I think Moshe's suggestion that each revision should have a separate/empty log message is a pretty reasonable one.

dww’s picture

Status: Needs work » Closed (duplicate)

this has been previously reported in http://drupal.org/node/39124.
i was just about to submit my own issue and patch for this, but found these duplicates, instead. ;)
so, i posted my patch in #39124. i had come to the exact same conclusion it seems folks in here have converged on: just don't fill in the #default_value for the 'log message' field and all is well.

anyway, please stop using this issue, and move any further discussion/review/patches to the older, original issue.

thanks,
-derek

Anonymous’s picture

Status: Closed (duplicate) » Closed (fixed)