Bug #79714 [NEW]: Extension bcgen + PHAR archives appear not to be able to work together
| From: | henry dot wood dot dk at gmail dot com | Date: | Thu, 18 Jun 2020 20:09:41 +0000 |
| Subject: | Bug #79714 [NEW]: Extension bcgen + PHAR archives appear not to be able to work together | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-227543@lists.php.net to get a copy of this message | ||
From: henry dot wood dot dk at gmail dot com
Operating system: Ubuntu 18.04
PHP version: 7.2.31
Package: PHAR related
Bug Type: Bug
Bug description:Extension bcgen + PHAR archives appear not to be able to work together
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 bug report at https://bugs.php.net/bug.php?id=79714&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79714&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79714&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79714&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79714&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79714&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79714&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79714&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79714&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79714&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79714&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79714&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79714&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79714&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79714&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79714&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79714&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79714&r=mysqlcfg