on_page_version_add event does not return version comments

Permalink
Hi!
I set up notifications on page edits for my site. I would like to be informed about the comments, submitted for edited pages. Here's the code:

function on_page_version_add($page, $nv) {
  $l = new Log('content-change', true);
  if ($page->getCollectionPath()!=''){
    $l->write($nv->getVersionAuthorUserName() . " have changed page '" . $page->getCollectionName() . "'.");
    $l->write(BASE_URL . DIR_REL . $page->getCollectionPath());
  } else {
    $parent = Page::getByID($page->getCollectionParentID(), $version = 'RECENT');
    $l->write($nv->getVersionAuthorUserName() . " have changed page '" . $page->getCollectionName() . "' under the '" . $parent->getCollectionName() . "' page (" . BASE_URL . DIR_REL . $parent->getCollectionPath() . " ).");
  }
  $l->write("Comment: " . $cv->getVersionComments() );
  $l->close();
}


Unfortunately, instead of real version comment it returns something like default comment - "New Version 89". What am I doing wrong?

 
campbell replied on at Permalink Reply
campbell
Well, as far as I can tell (and I've been buried in this change notification stuff quite a bit), the on_page_version_add event fires as soon as an update to a block within the page is made. Because this event fires before the user clicks the Exit Edit Mode button (which, as you know, is where the option to enter version comments exists), the version is given a default name and number.

If there was a way to tie the notification to the Preview My Edits or Publish My Edits button clicks, that would theoretically make things work (or at least work right up until someone entered and exited edit mode without modifying anything, which will clear the most recent version comments back to a default... it's a bug).
Shotster replied on at Permalink Reply
Shotster
> (or at least work right up until someone entered and exited edit mode without
> modifying anything, which will clear the most recent version comments back to a
> default... it's a bug)

I've noticed some weirdness with version comments but never took the time to pin it down. Thanks for mentioning this. Has it been reported in the bug database?

-Steve
campbell replied on at Permalink Reply
campbell
I did add a bug report for it a couple of days ago, yep. :)