01333: Pagelist count parameter ignores zero

Summary: Pagelist count parameter ignores zero
Created: 2014-01-29 11:50
Status: Open
Category: Bug
From: RandyB
Priority: 2
Version: 2.2.60

Description: Pagelist's count parameter fails to limit the listing to zero pages when its count parameter is zero. Instead it lists all pages.

For example:

(:pagelist group=Main count=2:)
Main /
AboutThisSite  Site description page (linked from Light Skin page)
(:pagelist group=Main count=0:)
Main /
AboutThisSite  Site description page (linked from Light Skin page)
HomePage  The default home page for the PmWiki distribution

Why would anyone ever specify zero for count? Here's one reason: The count might be entered dynamically via a URL request. If we want to suppress the pagelist entirely, we would naturally specify zero for count. Obviously one could instead add conditionals to only show the pagelist if the count is greater than zero, but that complicates the markup. It seems to me when the markup says to show up to zero pages, that's what pagelist should do.

RandyB January 29, 2014, at 11:50 AM

I have reviewed the CalcRange() function and I believe the count=0 is returning unlimited results by design, similarly to SQL database queries. Imagine someone in a situation opposite to yours, the page displays some results, and a user can dynamically request to show all results. Because this is really embedded into the guts of that function, I'm afraid we cannot change it without potentially breaking some wikis relying on that feature. But as usual, there is a workaround here, see below. --Petko January 29, 2014, at 04:45 PM

(:pagelist group=Main count=9999..9999:)

No results found.