From b5f5f8f6e8b33b30c87b23e7137453d2df031e86 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 7 Jan 2010 08:34:27 -0800 Subject: [PATCH] Threads should not show pagination query params in their URLs. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Post/Thread.pm | 20 ++++++++++++++++++++ t/Asset/Post/Thread.t | 8 +++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 6ca2e0c29..659daf78d 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,5 @@ 7.8.10 + - fixed #11332: Pagination in webgui.org forum urls 7.8.9 - fixed #11235: wiki search diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index f4c6e060b..9fb5c3d2a 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -336,6 +336,26 @@ sub getAutoCommitWorkflowId { return $self->getThread->getParent->get("threadApprovalWorkflow"); } +#------------------------------------------------------------------- + +=head2 getDirectLinkUrl ( ) + +Extend the base method from Post to remove the pagination query fragment + +=cut + +sub getDirectLinkUrl { + my $self = shift; + my $url = $self->SUPER::getDirectLinkUrl(); + $url =~ s/\?pn=\d+//; + if ($url =~ m{;revision=\d+}) { + $url =~ s/;revision/?revision/; + } + + return $url; +} + + #------------------------------------------------------------------- =head2 getLastPost diff --git a/t/Asset/Post/Thread.t b/t/Asset/Post/Thread.t index eb476c533..4a81f82b7 100644 --- a/t/Asset/Post/Thread.t +++ b/t/Asset/Post/Thread.t @@ -13,7 +13,7 @@ use strict; use lib "$FindBin::Bin/../../lib"; use WebGUI::Test; use WebGUI::Session; -use Test::More tests => 2; # increment this value for each test you create +use Test::More tests => 5; # increment this value for each test you create use Test::MockObject::Extends; use WebGUI::Asset::Wobject::Collaboration; use WebGUI::Asset::Post::Thread; @@ -44,6 +44,8 @@ my $thread = $collab->addChild($props, @addArgs); $versionTag->commit(); +my $uncommittedThread = $collab->addChild($props, @addArgs); + # Test for a sane object type isa_ok($thread, 'WebGUI::Asset::Post::Thread'); @@ -61,4 +63,8 @@ $thread->rate(1); $thread->trash; is($thread->get('threadRating'), 0, 'trash does not die, and updates the threadRating to 0'); +unlike $thread->getDirectLinkUrl, qr/\?pn=\d+/, 'threads do not need pagination url query fragments'; +unlike $uncommittedThread->getDirectLinkUrl, qr/\?pn=\d+/, 'uncommitted threads, too'; +like $uncommittedThread->getDirectLinkUrl, qr/\?revision=\d+/, 'uncommitted threads do have a revision query param'; + # vim: syntax=perl filetype=perl