Fix direct linking to posts and threads when their pagination is set to 0. Fixes bug #11464.
This commit is contained in:
parent
eccf6a5021
commit
21e321012c
4 changed files with 12 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
7.9.1
|
||||
- fixed #11464: blank page after setting posts per page in Collaboration System to 0 (zero)
|
||||
|
||||
7.9.0
|
||||
- added #11383: AJAX username checks at registration (Luke Robinson / Orchard Solutions)
|
||||
|
|
|
|||
|
|
@ -506,7 +506,8 @@ Returns the URL for this Post, which links directly to its anchor and page.
|
|||
sub getThreadLinkUrl {
|
||||
my $self = shift;
|
||||
my $url;
|
||||
my $page_size = $self->getThread->getParent->get('postsPerPage');
|
||||
my $paginator = WebGUI::Paginator->new($self->session, '', $self->getThread->getParent->get('postsPerPage'));
|
||||
my $page_size = $paginator->{_rpp}; ##To make sure defaults are handled correctly.
|
||||
my $place = $self->getRank+1;
|
||||
my $page = int($place/$page_size) + 1;
|
||||
my $page_frag = 'pn='.$page;
|
||||
|
|
|
|||
|
|
@ -352,7 +352,8 @@ sub getCSLinkUrl {
|
|||
my $self = shift;
|
||||
my $url;
|
||||
my $cs = $self->getParent;
|
||||
my $page_size = $cs->get('threadsPerPage');
|
||||
my $paginator = WebGUI::Paginator->new($self->session, '', $self->getParent->get('threadsPerPage'));
|
||||
my $page_size = $paginator->{_rpp}; ##To make sure defaults are handled correctly.
|
||||
my $place = $self->getRank+1;
|
||||
my $last_place = $cs->getLastChild->getRank+1;
|
||||
my $page = int(($last_place - $place)/$page_size) + 1;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@ use strict;
|
|||
use lib "$FindBin::Bin/../../lib";
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 9; # increment this value for each test you create
|
||||
use Test::More tests => 11; # increment this value for each test you create
|
||||
use Test::MockObject::Extends;
|
||||
use Test::Exception;
|
||||
use WebGUI::Asset::Wobject::Collaboration;
|
||||
use WebGUI::Asset::Post::Thread;
|
||||
|
||||
|
|
@ -72,6 +73,9 @@ note 'getThreadLinkUrl';
|
|||
unlike $thread->getThreadLinkUrl, qr/\?pn=\d+/, 'threads do not need pagination url query fragments';
|
||||
unlike $uncommittedThread->getThreadLinkUrl, qr/\?pn=\d+/, 'uncommitted threads, too';
|
||||
like $uncommittedThread->getThreadLinkUrl, qr/\?revision=\d+/, 'uncommitted threads do have a revision query param';
|
||||
$collab->update({threadsPerPage => 0, postsPerPage => 0,});
|
||||
lives_ok { $uncommittedThread->getThreadLinkUrl } '... works when pagination set to 0';
|
||||
$collab->update({threadsPerPage => 3, postsPerPage => 10,});
|
||||
|
||||
note 'getCSLinkUrl';
|
||||
my @newThreads;
|
||||
|
|
@ -82,5 +86,7 @@ like $newThreads[-1]->getCSLinkUrl, qr/^$csUrl/, 'getCsLinkUrl returns URL of th
|
|||
like $newThreads[-1]->getCSLinkUrl, qr/\?pn=1/, 'and has the right page number';
|
||||
like $newThreads[-1]->getCSLinkUrl, qr/\?pn=1;sortBy=lineage;sortOrder=desc/, 'and has the right sort parameters';
|
||||
like $thread->getCSLinkUrl, qr/\?pn=2/, 'checking 2nd thread on another page';
|
||||
$collab->update({threadsPerPage => 0, postsPerPage => 0,});
|
||||
lives_ok { $uncommittedThread->getCSLinkUrl } '... works when pagination set to 0';
|
||||
|
||||
# vim: syntax=perl filetype=perl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue