Bug #79714 [Opn->Fbk]: Extension bcgen + PHAR archives appear not to be able to work together
| From: | nikic@php.net | Date: | Thu, 18 Jun 2020 20:21:15 +0000 |
| Subject: | Bug #79714 [Opn->Fbk]: Extension bcgen + PHAR archives appear not to be able to work together | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227545@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79714&edit=1
ID: 79714
Updated by: nikic@php.net
Reported by: henry dot wood dot dk at gmail dot com
Summary: Extension bcgen + PHAR archives appear not to be
able to work together
-Status: Open
+Status: Feedback
Type: Bug
Package: PHAR related
Operating System: Ubuntu 18.04
PHP Version: 7.2.31
Block user comment: N
Private report: N
New Comment:
Do you have any specific reason to believe this issue is on the phar side rather than the bcgen
side? I would recommend reporting the issue with bcgen first.
As the project is compatible only with PHP 7.2 and PHP 7.2 is no longer actively supported, we will
not be able to fix anything anyway (though if the issue is indeed on the phar side, future versions
may be fixed -- that's a big if though).
Previous Comments:
------------------------------------------------------------------------
[2020-06-18 20:11:29] henry dot wood dot dk at gmail dot com
Possible conclusion:
Any compiled file *WITHIN* the phar archive 'simple.phar' is simply read as-is and not
parsed/evaluated/executed - however, the BCGEN header appears to be stripped from the output.
Any normal PHP file *WITHIN* the phar archive 'simple.phar' is read, parsed, evaluted and
executed as expected.
------------------------------------------------------------------------
[2020-06-18 20:09:41] henry dot wood dot dk at gmail dot com
Description:
------------
I am trying to build a PHAR archive which contains both files compiled by bcgen (See: https://github.com/vjardin/bcgen) and normal PHP files
I would then expect the PHAR file to be runnable via the command line, regardless which type of
file is referenced (either a bcgen compiled file or a normal php file) as this is what is explained
in the README of bcgen.
NOTE: Also note that this INI setting should be set:
bcgen.enable (default "1")
BCgen On/Off switch. When set to Off, bytecode files cannot be read
Test script:
---------------
<?php
// CHECK FOR BCGEN
if (! extension_loaded('Zend BCgen')) {
echo "ERROR: Needs Zend BCgen extension".PHP_EOL;
die(-1);
}
// COMPILE test.phb FROM test.php
// CONTENTS OF test.php: <?php echo "HELLO FROM BCGEN...".PHP_EOL;
file_put_contents('test.php', '<?php echo "HELLO FROM
BCGEN...".PHP_EOL;');
bcgen_compile_file('test.php', 'b.phb');
// MAKE test2.php
file_put_contents('test2.php', '<?php echo "HELLO FROM NORMAL
PHP...".PHP_EOL;');
// Make PHAR
$phar = new Phar( 'simple.phar' );
$phar->addFile('test.phb', 'b.phb');
$phar->addFile('test2.php', 'c.php');
$phar['a.php'] = '<?php echo "Hola Mundo\n"; include("b.phb");
include("c.php")?>';
$pharfile = 'simple.phar';
$startfile = 'a.php';
$stub = <<< "EOT"
#!/usr/bin/env php
<?php
Phar::mapPhar( '$pharfile' );
set_include_path( 'phar://' . __FILE__ . PATH_SEPARATOR . get_include_path() );
require( '$startfile' );
__HALT_COMPILER();
EOT;
$phar->setStub( $stub );
echo "DONE ...".PHP_EOL;
Expected result:
----------------
After running the test script to build the PHAR archive, I would expect running the simple.phar file
from command line to output:
Expected output:
Hola Mundo
HELLO FROM BCGEN...
HELLO FROM NORMAL PHP...
Actual result:
--------------
Actual output:
Hola Mundo
/tmp/test.phpâââââââââ`âf/â,âHELLO FROM
BCGEN...
iââââ>
HELLO FROM NORMAL PHP...
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79714&edit=1