Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.7.2

Bug #3696 PHP SAPI check in debugPackageFile() not reliable, use php_sapi_name() instead
Submitted: 2005-03-03 22:38 UTC
From: michaels at crye-leike dot com Assigned: cellog
Status: Closed Package: PEAR_PackageFileManager
PHP Version: 5.0.3 OS: Linux
Roadmaps: (Not assigned)    

 [2005-03-03 22:38 UTC] michaels at crye-leike dot com
Description: ------------ Using PEAR_PackageFileManager 1.4.0 PHP 5.0.3 configured with: ./configure --with-mysql=/usr --with-pgsql=/usr --with-sybase-ct=/usr/local --with-zlib --with-apxs=/usr/bin/apxs --enable-memory-limit --with-xsl PEAR_PackageFileManager::debugPackageFile() uses isset($_SERVER['PATH_TRANSLATED']) to determine if the current SAPI is a webserver or the CLI. However, on my installation $_SERVER['PATH_TRANSLATED'] is set even for CLI scripts (when ran from a shell script with a shabang line and the executable bit set). It seems that: $webinterface = (php_sapi_name() != 'cli'); is better than $webinterface = isset($_SERVER['PATH_TRANSLATED']); (line 995 of PackageFileManager.php) Reproduce code: --------------- #!/usr/local/bin/php <? require_once'PEAR/PackageFileManager.php'; $packagexml = new PEAR_PackageFileManager; $packagexml->setOptions(array( 'package' => 'MyPackage', 'summary' => 'This is a test summary', 'description' => 'This is a test description', 'version' => '1.0.0', 'state' => 'stable', 'baseinstalldir' => '/', 'packagedirectory' => dirname(__FILE__) )); $packagexml->addMaintainer('example', 'lead', 'Lead Dev', ''); //unset($_SERVER['PATH_TRANSLATED']); //Uncomment this line to work around problem $packagexml->debugPackageFile(); ?> Expected result: ---------------- Standard XML document written to stdout without <pre> tags and without htmlentities() escaping Actual result: -------------- XML document written to stdout surrounded by <pre> tags and with xml content processed via htmlentities()


 [2005-03-26 17:39 UTC] cellog
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on In case this was a website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.