PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » Pager » Bug #1377

getPageData() returns no data when $pageID is specified.

Details

Submitted2004-05-10 23:29 UTC
Fromieure at php dot net
Assignedquipo
StatusClosed
PackagePager
PHP VersionIrrelevant
OSLinux
Roadmaps(Not assigned)

Comments

[2004-05-10 23:29 UTC] ieure at php dot net

Description:
------------
Calling getPageData() with a specific pageID to get the data for
never returns data.

Examining the function, it's obvious that the data isn't generated if
a pageID is specified.

Additionally, there is no need for getPageData() to call itself again
after the _generatePageData() call.

This patch fixes both issues:

diff -u -r1.11 Common.php
--- Common.php 29 Apr 2004 17:27:49 -0000 1.11
+++ Common.php 10 May 2004 23:35:38 -0000
@@ -364,19 +364,16 @@
*/
function getPageData($pageID = null)
{
- if (isset($pageID)) {
- if (!empty($this->_pageData[$pageID])) {
- return $this->_pageData[$pageID];
- } else {
- return false;
- }
- }
+ $pageID = $pageID ? $pageID : $this->_currentPage;

if (!isset($this->_pageData)) {
$this->_generatePageData();
}

- return $this->getPageData($this->_currentPage);
+ if (!empty($this->_pageData[$pageID])) {
+ return $this->_pageData[$pageID];
+ }
+ return false;
}

// }}}

Reproduce code:
---------------
$pager = new Pager();
...
$data = $pager->getPageData(2);

Expected result:
----------------
$data should contain data for page 2.

Actual result:
--------------
$data is boolean false.