phpDocumentor
phpDocumentor copied to clipboard
Phar is modified on a run
I'm still getting an error with phive on Docker:
Notice: require(): zlib: data error in /tools/.phive/phars/phpdocumentor-3.4.1.phar on line 11
Warning: require(phar://phpdocumentor.phar/bin/phpdoc): Failed to open stream: phar error: internal corruption of phar "/tools/.phive/phars/phpdocumentor-3.4.1.phar" (actual filesize mismatch on file "bin/phpdoc") in /tools/.phive/phars/phpdocumentor-3.4.1.phar on line 11
Fatal error: Uncaught Error: Failed opening required 'phar://phpdocumentor.phar/bin/phpdoc' (include_path='.:/usr/local/lib/php') in /tools/.phive/phars/phpdocumentor-3.4.1.phar:11
Stack trace:
#0 {main}
thrown in /tools/.phive/phars/phpdocumentor-3.4.1.phar on line 11
Interestingly, phpDocumentor works when image is being built, but not when I run it on the built image. Perhaps a docker issue.
Originally posted by @jakzal in https://github.com/phpDocumentor/phpDocumentor/issues/3562#issuecomment-1709886494
Copied from #3562. The phar works fine the first time it’s run but gets corrupted.
I can reproduce the problem now.
-
Start a PHP Docker container
docker run -it --rm jakzal/phpqa:alpine sh
-
Install phpDocumentor with phar
phive --no-progress --home /tools/.phive install \ --trust-gpg-keys 8AC0BAA79732DD42 phpDocumentor \ -t /tools/.phive/tmp/f474e60df5620536af2224cbc21a1668 \ && mv /tools/.phive/tmp/f474e60df5620536af2224cbc21a1668/* /tools/phpDocumentor
-
Run phpDocumentor (works fine)
/tools/phpDocumentor
-
Run phpDocumentor again (phar is now corrupted)
/tools/phpDocumentor
Other phar files on the image do not get corrupted.
I'm trying to reproduce this issue with the steps you provide... but it does download php 3.3.1 for me? Do I need to update something before phive will pull the correct version?
Strange. As you see on my screenshot it downloaded 3.4.1 for me.
Have you tried @dharmann's steps instead? https://github.com/phpDocumentor/phpDocumentor/issues/3562#issuecomment-1731218311
This should definitely download v3.4.1:
wget https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.4.1/phpDocumentor.phar
chmod +x phpDocumentor.phar
./phpDocumentor.phar --version
The same issue persists.
ok, I got a way to reproduce this, it seems to be related to the php setting phar.readonly
when you execute:
php -d phar.readonly=off ./phpdocumentor.phar
it will keep working.
Neverless it should not be modified after execution. I will continue the research on this.
Confirmed phar.readonly=on
makes it continues to work after the first run 👍 great find!
Hm... this is gonna be a though search... I cannot extract the corrupted phar, So I have no clue on what has been changed
Hm... this is gonna be a though search... I cannot extract the corrupted phar, So I have no clue on what has been changed
Sorry, maybe I don't really understand your sentence, because a phar can be extract simply using
$ phar extract -f </PATH/OF/FILE.PHAR>
Ah I was not aware of the existence of phar, I do always use php for this
Ah I was not aware of the existence of phar, I do always use php for this
In a Debian like Linux distro you can find it in /usr/bin/phar
, and in windows I think it could be phar.pharbat
or pharcommand.phar
Can you confirm this phar keeps working? It's not zipped like the released phar. It's a zip file because github does not allow me to upload phar files in issues.
Can you confirm this phar keeps working? It's not zipped like the released phar. It's a zip file because github does not allow me to upload phar files in issues.
It worked like a charm! Every time (three) that I ran it!
The only difference between this phar, and another one I created on the same code base version was the Boxphp setting compression, in the release this was set to GZ. to compress the release and make it a smaller download.
The version you tested was not compressed.
https://github.com/phpDocumentor/phpDocumentor/commit/d85524df238467baae619b02b7435b0797fc4a51
This seems to be the cause of the issue, I will try to do a new release soon, but I have to wrap things up. As I made some significant changes since the last release.
This seems to be the cause of the issue, I will try to do a new release soon, but I have to wrap things up. As I made some significant changes since the last release.
Good job! Thank you very much!
I am getting the same issue by downloading it from the web with v3.4.0 and v3.4.1
I just released v3.4.2, this should fix this issue. Please let me know when you face any issues with the new release.
I just released v3.4.2, this should fix this issue. Please let me know when you face any issues with the new release.
Sadly I got the exactly same error:
$ ./phpDocumentor.phar version
PHP Notice: require(): zlib: data error in /tmp/phpDocumentor.phar on line 11 PHP Warning: require(phar://phpdocumentor.phar/bin/phpdoc): Failed to open stream: phar error: internal corruption of phar "/tmp/phpDocumentor.phar" (actual filesize mismatch on file "bin/phpdoc") in /tmp/phpDocumentor.phar on line 11 PHP Fatal error: Uncaught Error: Failed opening required 'phar://phpdocumentor.phar/bin/phpdoc' (include_path='.:/usr/share/php') in /tmp/phpDocumentor.phar:11 Stack trace: #0 {main} thrown in /tmp/phpDocumentor.phar on line 11
Here the checksum of the phar before and after it's usage:
$ md5sum phpDocumentor.phar*
948baaac402ad96ba519398a45dd49e1 phpDocumentor.phar.original
230d6188965737cd98764c32f50858a7 phpDocumentor.phar
The latest version works for me 👍
@dharmann can you provide the values of the phar
settings in your ini file with me?
@dharmann can you provide the values of the
phar
settings in your ini file with me?
For sure! I'm using PHP 8.1.2 and following is the "phar part" of phpinfo() output on CLI:
Phar
Phar: PHP Archive support => enabled Phar API version => 1.1.1 Phar-based phar archives => enabled Tar-based phar archives => enabled ZIP-based phar archives => enabled gzip compression => enabled bzip2 compression => disabled (install ext/bz2) Native OpenSSL support => enabled
Phar based on pear/PHP_Archive, original concept by Davey Shafik. Phar fully realized by Gregory Beaver and Marcus Boerger. Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle. Directive => Local Value => Master Value phar.cache_list => no value => no value phar.readonly => Off => Off phar.require_hash => On => On
Is it enough?
I've updated to 3.4.3 and the problem seems to persist. ;-(
I've updated to 3.4.3 and the problem seems to persist. ;-(
I'm sharing in attachment the content of the phar BEFORE and AFTER the first run. Due to a limitation of github, I can't attach the whole zipped file (27MB), but a link to download it
Please, let me know if it's ok.
Thank you!