Bug #64500 [Opn->Nab]: Impossible to disable Phar::interceptFileFuncs() behaviour

From: Date: Mon, 30 Mar 2015 14:18:00 +0000
Subject: Bug #64500 [Opn->Nab]: Impossible to disable Phar::interceptFileFuncs() behaviour
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191728@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64500&edit=1 ID: 64500 Updated by: mike@php.net Reported by: exbeinfo at gmail dot com Summary: Impossible to disable Phar::interceptFileFuncs() behaviour -Status: Open +Status: Not a bug Type: Bug Package: PHAR related Operating System: Windows 7 PHP Version: 5.4.13 Block user comment: N Private report: N New Comment: One can set a custom stub. Previous Comments: ------------------------------------------------------------------------ [2013-03-24 07:21:46] exbeinfo at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=64500&edit=1

« previous php.bugs (#191728) next »