php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25449 Small fix for PEAR::Pager_Sliding
Submitted: 2003-09-09 08:12 UTC Modified: 2003-09-09 08:23 UTC
From: info at rhalff dot com Assigned: quipo (profile)
Status: Closed Package: PEAR related
PHP Version: Irrelevant OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: info at rhalff dot com
New email:
PHP Version: OS:

 

 [2003-09-09 08:12 UTC] info at rhalff dot com
Description:
------------
When using strict error handling Pager_Sliding will fail because of an undefined $_GET[$this->_urlVar]) in line 882

A simple fix for this would be, to check if it is empty:

if(!empty($_GET[$this->_urlVar])) {
$this->_currentPage = max((int)@$_GET[$this->_urlVar], 1);
}




Reproduce code:
---------------
<?
require_once 'PEAR.php';
require_once('Pager/Sliding.php');
error_reporting(E_ALL);

function php_error_handler($errno, $errstr, $errfile, $errline)  {
      echo "<b>$errfile ($errline)</b><br>$errstr";
      exit();
}
set_error_handler('php_error_handler');

$params['totalItems'] = 10;
$params['perPage']    = 10;

$pager = &new Pager_Sliding($params);
$links = $pager->getLinks();
print_r($links);
?>

Expected result:
----------------
Array
(
    [0] => 
    [1] => 
    [2] => 
    [3] => 
    [4] => 
    [5] => 
    [back] => 
    [pages] => 
    [next] => 
    [first] => 
    [last] => 
    [all] => 
)

Actual result:
--------------
/usr/lib/php/Pager/Sliding.php (882)
Undefined index: pageID

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-09 08:23 UTC] quipo@php.net
that happens because you use a different error handling, the "@" sign in front of $_GET[$this->_urlVar]  was meant to suppress that warning. Anyway,thanks for your report, I'll add a check for the next release. Fixed in CVS.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Oct 17 09:03:34 2021 UTC