Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including dependencies packed with clue/phar-composer results in exception #19

Closed
cumuru opened this issue Mar 1, 2019 · 8 comments
Closed

Comments

@cumuru
Copy link

cumuru commented Mar 1, 2019

In a non-composer TYPO3 project I follow @helhum‘s suggestions here https://insight.helhum.io/post/148112375750/how-to-use-php-libraries-in-legacy-extensions to require third party dependencies.
After an update to a TYPO3 version including phar-stream-wrapper I‘m facing this exception:

#1530103999: Method stream_select() cannot be used

thrown in the line that does actually require the autoload.php file inside the phar, equally to

@include 'phar://' . ExtensionManagementUtility::extPath('ext-key') . 'Libraries/symfony-process.phar/vendor/autoload.php';

Expected behaviour:
Register classes inside phar and load classes from there as needed.

PHP is 5.6.24 and target TYPO3 version is 6.2.40

@ohader
Copy link
Member

ohader commented Mar 1, 2019

Interesting! Can you please share the Phar archive and it's source code that you're using, as well as how to execute it (I assume it's a CLI application). Thx

@ohader
Copy link
Member

ohader commented Mar 1, 2019

stream_select seems to be related to #8 (which could not be verified, yet)

@cumuru
Copy link
Author

cumuru commented Mar 1, 2019

Sure. That‘s my composer scripts packing the phar archive:

"scripts": {
      "extension-create-libs": [
        "mkdir -p Libraries/temp Libraries/build",
        "if [ ! -f Libraries/build/vendor/bin/phar-composer ]; then cd Libraries/build && composer require clue/phar-composer; fi",
        "if [ ! -f Libraries/php-iban.phar ]; then cd Libraries/temp && composer require globalcitizen/php-iban && composer config classmap-authoritative true && composer config prepend-autoloader false && composer dump-autoload; fi",
        "[ -f Libraries/php-iban.phar ] || Libraries/build/vendor/bin/phar-composer build Libraries/temp/ Libraries/php-iban.phar",
        "chmod -x Libraries/*.phar",
        "rm -rf Libraries/temp Libraries/build"
      ],
      "extension-build": [
        "@extension-create-libs"
      ],
      "extension-clean": [
        "rm -rf Libraries"
      ]
    }

It‘s not strictly a CLI application but a TYPO3 eID script call. I attached the phar for reference.
See the phar source code here: https://github.com/globalcitizen/php-iban

php-iban.phar.zip

@ohader
Copy link
Member

ohader commented Mar 1, 2019

I could not reproduce using include('phar://php-iban.phar/vendor/autoload.php');. The initial report mentioned symfony-process.phar, could you please attach that file as well in case you've just shared the wrong bundle?

My isolated test scenario just looked like this:

<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';

call_user_func(function () {
    \TYPO3\PharStreamWrapper\Manager::initialize(
        (new \TYPO3\PharStreamWrapper\Behavior())
            ->withAssertion(new \TYPO3\PharStreamWrapper\Interceptor\PharExtensionInterceptor())
    );
    if (in_array('phar', stream_get_wrappers())) {
        stream_wrapper_unregister('phar');
        stream_wrapper_register('phar', \TYPO3\PharStreamWrapper\PharStreamWrapper::class);
    }

    include('phar://php-iban.pharx/vendor/autoload.php');
});

@mbrodala
Copy link
Member

mbrodala commented May 9, 2019

I just got a similar report in pagemachine/typo3-formlog#23 apparently affecting stream_open. Any idea what I can do?

@ohader
Copy link
Member

ohader commented May 9, 2019

@mbrodala stream_open seems to be unrelated to this issue here... Reading the issue you referenced it's for sure the interceptor (https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/IO/PharStreamWrapperInterceptor.php#L50-L59) that blocks the request. I guess(!) it might be related to PATH_site and using a couple of symbolic links there...

@ohader
Copy link
Member

ohader commented May 15, 2019

The issue mentioned in pagemachine/typo3-formlog#23 was a different one.

Back to this very issue, invocation of stream_select within the wrapper is still a mystery. Looking forward to a locally reproducible scenario (Docker, DDEV, Vagrant, ...)

@ohader
Copy link
Member

ohader commented Sep 16, 2021

There haven't been much more details on this topic during the last two years. I guess it's fine to close this issue.

@ohader ohader closed this as completed Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants