Bug #6697 [NEW]: REQUIEST_URI insted of PHP_SELF for href generation

From: Date: Sun, 05 Feb 2006 15:05:58 +0000
Subject: Bug #6697 [NEW]: REQUIEST_URI insted of PHP_SELF for href generation
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-7489@lists.php.net to get a copy of this message
From: plamen at todorov dot biz Operating system: Windows Package version: PHP version: 5.1.0 Package: Documentation Bug Type: Bug Bug description: REQUIEST_URI insted of PHP_SELF for href generation Description: ------------ I found a bug and here is the description: If I'm using .htaccess with rewrite engine, Pager doesn't behave as it suppose to. So this is not ussual bug but can be fixed with few replacements, or with adding a new option for factory() method such as 'full_link_url'. So I found a solutions like this: in Common.php on line 44: /* if (substr($_SERVER['PHP_SELF'], -1) == '/') { define('CURRENT_FILENAME', ''); define('CURRENT_PATHNAME', str_replace('\\', '/', $_SERVER['PHP_SELF'])); } else { define('CURRENT_FILENAME', preg_replace('/(.*)\?.*/', '\\1', basename($_SERVER['PHP_SELF']))); define('CURRENT_PATHNAME', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']))); } */ insted this: /* if (substr($_SERVER['REQUEST_URI'], -1) == '/') { define('CURRENT_FILENAME', ''); define('CURRENT_PATHNAME', str_replace('\\', '/', $_SERVER['REQUEST_URI'])); } else { define('CURRENT_FILENAME', preg_replace('/(.*)\?.*/', '\\1', basename($_SERVER['REQUEST_URI']))); define('CURRENT_PATHNAME', str_replace('\\', '/', dirname($_SERVER['REQUEST_URI']))); } */ So if we change PHP_SELF to REQUEST_URI everything will be ok because PHP_SELF gets real file, not the file you provided with the rewrite_engine of .htaccess Test script: --------------- For .htaccess Options +Indexes RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^.*\.html$ index.php [L] In PHP Script: /* The page where I runing this script is search.html */ function pager($options) { require_once("Pager/Pager.php"); $defaults = array( 'mode' => 'Sliding', 'urlVar' => 'page', 'perPage' => 25, 'delta' => 5, 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1, ); $params = array_merge($defaults, $options); $pager = & Pager::factory($params); $links = $pager->getLinks(); return $links['all']; } Expected result: ---------------- The link generated href should be ?search.html?PageID=... Actual result: -------------- but it is ?index.php?PageID=... -- Edit bug report at http://pear.php.net/bugs/bug.php?id=6697&edit=1 --

« previous php.pear.doc (#7489) next »