PEAR is archived and read-only

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

Home » HTML » Pager » Bug #7657

not compatible with autoload

Details

Submitted2006-05-18 08:26 UTC
Frommirko at stranicata dot com
Assignedquipo
StatusClosed
PackagePager
PHP Version5.1.2
OSWindows
Roadmaps(Not assigned)

Comments

[2006-05-18 08:26 UTC] mirko at stranicata dot com

Description:
------------
If the script that uses the Pager class has some tipical use of autoloading(http://php.net/manual/en/language.oop5.autoload.php) the script will fail becuse when you make a check if the file is already included in the factory method (Pager.php line 177) you don't pass second (for autoload) argument false to
class_exists function - this means that autoload will be called and trying to load $classname...

To fix this just pass false as second arg to class_exist

Test script:
---------------
<?PHP
require_once 'Pager/Pager.php';
$params = array(
'mode' => 'Sliding',
'perPage' => 3,
'delta' => 2,
'itemData' => array('a','b','c','d','e')
);
$pager = & Pager::factory($params);
// do some stuff ...

function __autoload($class_name)
{
include_once $class_name . ".php";
}
?>

Fix:
Pager 177:
if (!class_exists($classname)) {
to become
if (!class_exists($classname), FALSE) {

Actual result:
--------------
<br />
<b>Warning</b>: include_once() [<a href='function.include'>function.include</a>]: Failed opening 'Pager_Sliding.php' for inclusion (include_path='.;C:/xampp/php/pear/;Z:/projects/libs/php/custom;Z:/projects/libs/php/smarty') in <b>D:\projects\test.php</b> on line <b>21</b><br />
bool(false)