diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index f68cba6d6..fcb5ead30 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -20,6 +20,9 @@ - Fixed a bug in the 7.2.3-7.3.0 upgrade script related to calendar migration. - Fixed a bug with RSS feed generation and attachments. + - fix: notifications from postings + - Refactored the autocommit system to fix the notifications bug above. + 7.3.4 - fix: SQLForm - cannot add new asset (Martin Kamerbeek / Oqapi) diff --git a/lib/WebGUI/Asset/Event.pm b/lib/WebGUI/Asset/Event.pm index f93d44785..3d5ff3e36 100644 --- a/lib/WebGUI/Asset/Event.pm +++ b/lib/WebGUI/Asset/Event.pm @@ -230,7 +230,9 @@ sub generateRecurringEvents $properties->{endDate} = $dt->clone->add(days => $duration_days)->strftime('%F'); - $parent->addChild($properties); + my $newEvent = $parent->addChild($properties); + $newEvent->requestAutoCommit; + } return 1; @@ -1497,9 +1499,11 @@ sub processPropertiesFromFormPost $properties->{endDate} = $event->get("endDate"); $event->addRevision($self->get); + $event->requestAutoCommit; } } } + $self->requestAutoCommit; } diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index 64a398077..9c1c784b6 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -795,6 +795,7 @@ sub postProcess { $size += $storage->getFileSize($file); } $self->setSize($size); + $self->requestAutoCommit; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/WikiPage.pm b/lib/WebGUI/Asset/WikiPage.pm index 44d742706..edb998e4e 100644 --- a/lib/WebGUI/Asset/WikiPage.pm +++ b/lib/WebGUI/Asset/WikiPage.pm @@ -262,6 +262,7 @@ sub processPropertiesFromFormPost { } $self->setSize($size); + $self->requestAutoCommit; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm index c58cf8c56..651a9d411 100644 --- a/lib/WebGUI/AssetVersioning.pm +++ b/lib/WebGUI/AssetVersioning.pm @@ -85,7 +85,7 @@ sub addRevision { $newVersion->setVersionLock; $properties->{status} = 'pending'; $newVersion->update($properties); - $workingTag->requestCommit if ($autoCommitId); + $newVersion->setAutoCommitTag($workingTag) if (defined $autoCommitId); return $newVersion; } @@ -121,13 +121,11 @@ sub commit { $self->indexContent; } - - #------------------------------------------------------------------- =head2 getAutoCommitWorkflowId ( ) -Override this method in your asset if you want your asset to auto-commit its workflow each time addRevision() is called on it. Your overridden method must return the workflow Id of the workflow to run on autocommit. +Override this method in your asset if you want your asset to automatically run its commit workflow. When this method is specified you addRevision() will instanciate the version tag, set this as the workflow for that version tag, and then call setAutoCommitTag(). Then sometime later in your code before the asset is destroyed you need to call requestAutoCommit() to trigger the workflow. =cut @@ -257,6 +255,42 @@ sub purgeRevision { } +#------------------------------------------------------------------- + +=head2 requestAutoCommit ( ) + +Requests an autocommit tag be commited. See also getAutoCommitWorkflowId() and setAutoCommitTag(). + +=cut + +sub requestAutoCommit { + my $self = shift; + my $tag = $self->{_autoCommitTag}; + if (defined $tag) { + $tag->requestCommit; + delete $self->{_autoCommitTag}; + } +} + + +#------------------------------------------------------------------- + +=head2 setAutoCommitTag ( tag ) + +Stores the current working auto commit tag temporarily in the live asset object. See also requestAutoCommit() and getAutoCommitWorkflowId(). + +=head3 tag + +A WebGUI::VersionTag object. + +=cut + +sub setAutoCommitTag { + my $self = shift; + my $tag = shift; + $self->{_autoCommitTag} = $tag; +} + #------------------------------------------------------------------- =head2 setVersionLock ( ) diff --git a/lib/WebGUI/Workflow/Activity/CalendarUpdateFeeds.pm b/lib/WebGUI/Workflow/Activity/CalendarUpdateFeeds.pm index dbd204a4a..0040331aa 100755 --- a/lib/WebGUI/Workflow/Activity/CalendarUpdateFeeds.pm +++ b/lib/WebGUI/Workflow/Activity/CalendarUpdateFeeds.pm @@ -297,6 +297,7 @@ sub execute { { my $calendar = WebGUI::Asset->newByDynamicClass($self->session,$feed->{assetId}); my $event = $calendar->addChild($properties); + $event->requestAutoCommit; $added++; }