diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 6881e7628..c0741d966 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -18,6 +18,7 @@ - fixed #11932: Bad URL in the newly templated recover password email - fixed #11938: upgrade script always removes specialState - fixed #11937: Duplicating events does not duplicate storage locations + - fixed #11935: shortcut uses wrong value for getContentLastModified 7.10.3 - fixed #11903: Unnecessary debug in Thingy diff --git a/lib/WebGUI/Asset/Shortcut.pm b/lib/WebGUI/Asset/Shortcut.pm index 67059c907..c2a62051d 100644 --- a/lib/WebGUI/Asset/Shortcut.pm +++ b/lib/WebGUI/Asset/Shortcut.pm @@ -278,7 +278,7 @@ sub getContentLastModified { my $shortcut = $self->getShortcut; my $shortcuttedRev; if (defined $shortcut) { - $shortcuttedRev = $shortcut->get('revisionDate'); + $shortcuttedRev = $shortcut->getContentLastModified; return $assetRev > $shortcuttedRev ? $assetRev : $shortcuttedRev; } else { return 0; diff --git a/t/Asset/Shortcut/020-content-last-modified.t b/t/Asset/Shortcut/020-content-last-modified.t new file mode 100644 index 000000000..3be51bd89 --- /dev/null +++ b/t/Asset/Shortcut/020-content-last-modified.t @@ -0,0 +1,66 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2009 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use FindBin; +use strict; +use lib "$FindBin::Bin/../../lib"; + +## The goal of this test is to test the link between the asset and its shortcut +# and that changes to the asset are propagated to the shortcut + +use Scalar::Util qw( blessed ); +use WebGUI::Test; +use WebGUI::Session; +use Test::More; +use WebGUI::Asset::Shortcut; +use WebGUI::Asset::Snippet; + +#---------------------------------------------------------------------------- +# Init +my $session = WebGUI::Test->session; +my $node = WebGUI::Asset->getImportNode($session); + +my $versionTag = WebGUI::VersionTag->getWorking($session); +$versionTag->set({name=>"Shortcut Test"}); +WebGUI::Test->addToCleanup($versionTag); +# Make a snippet to shortcut +my $now = time(); +my $snippet = $node->addChild({ + className => "WebGUI::Asset::Snippet", + }, + undef, $now-50); + +my $shortcut = $node->addChild({ + className => "WebGUI::Asset::Shortcut", + shortcutToAssetId => $snippet->getId, + }, + undef, $now-10); +$versionTag->commit; +$session->db->write(q|update assetData set lastModified=? where assetId=?|,[WebGUI::Test->webguiBirthday, $snippet->getId]); +foreach my $asset ($snippet, $shortcut) { + $asset = $asset->cloneFromDb; +} + + +#---------------------------------------------------------------------------- +# Tests +plan tests => 2; + +is( $shortcut->getContentLastModified, $now-10, "getContentLastModified: returns date of shortcut since it has a newer revision date."); + +$snippet->update({snippet => 'updated', }, $now-5); + +diag $snippet->get('lastModified'); +diag $snippet->getContentLastModified; +$shortcut = $shortcut->cloneFromDb; ##Wipe the cached version of the shortcut. + +is( $shortcut->getContentLastModified, $snippet->get('lastModified'), "returns lastModified when shortcutted asset has a more recent date"); + +