From: exbeinfo at gmail dot com Operating system: Windows 7 PHP version: 5.4.13 Package: PHAR related Bug Type: Bug Bug description:Impossible to disable Phar::interceptFileFuncs() behaviour
Description: ------------ Current implementation of Phar stub doesn't provide any way to disable impact of Phar::interceptFileFuncs(). If you tried to run the test script for text file in the same folder php my.phar test.txt: File:test.txt Path:C:\projects\PrimordialCode\php\glitches\open stat issue\test.txt is_file: is_readable: file_exists: file_get_contents:I'm the test text. The same execution for test.php: php my.phar test.php File:test.php Path:C:\projects\PrimordialCode\php\glitches\open stat issue\test.php is_file:1 is_readable:1 file_exists:1 file_get_contents:<?php $file = isset($argv[1]) ? $argv[1] : null; if(is_null($file)) exit('Please specify a file'); echo "\n File:" . $file; echo "\n Path:" . realpath($file); echo "\n is_file:" . is_file($file); echo "\n is_readable:" . is_readable($file); echo "\n file_exists:" . file_exists($file); echo "\n file_get_contents:" . file_get_contents($file); The issue caused by https://github.com/php/php-src/blob/master/ext/phar/stub.h E.g. line with Phar::interceptFileFuncs() hardcoded call: static const char newstub1_0[] = "';\n\nif (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {\nPhar::interceptFileFuncs();\n .... Test script: --------------- <?php // Script to build phar $phar = new Phar("my.phar",0, "my.phar"); $phar["test.php"] = file_get_contents("test.php"); $phar->setStub($phar->createDefaultStub("test.php")); // Content of test.php <?php $file = isset($argv[1]) ? $argv[1] : null; if(is_null($file)) exit('Please specify a file'); echo "\n File:" . $file; echo "\n Path:" . realpath($file); echo "\n is_file:" . is_file($file); echo "\n is_readable:" . is_readable($file); echo "\n file_exists:" . file_exists($file); echo "\n file_get_contents:" . file_get_contents($file); Expected result: ---------------- Provide a switch to disable/enabled the function call or phar header customization. Actual result: -------------- Unexpected behavior of file lookup -- Edit bug report at https://bugs.php.net/bug.php?id=64500&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64500&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64500&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64500&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64500&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64500&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64500&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64500&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64500&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64500&r=support Expected behavior: https://bugs.php.net/fix.php?id=64500&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64500&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64500&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64500&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64500&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64500&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64500&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64500&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64500&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64500&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64500&r=mysqlcfg