-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Why phar stream is being unregistered? #21973
Comments
Hi @kassner. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
For more details, please, review the Magento Contributor Assistant documentation. @kassner do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
This was likely added due to |
Hi @engcom-backlog-nazar. Thank you for working on this issue.
|
HI @kassner thank you for you report, I'm closing this one as this is resolved, if not, feel free to reopen ticket, thanks for collaboration. |
Hi there, We just ran into this issue and had to comment out the added line of code, which is ... not ideal. We are running a 2.3.1 Community Magento. @engcom-backlog-nazar I don't see where it's been fixed, did I miss something ? I looked into 2.3-develop but it's untouched from what I can tell. Thanks for your support. |
Hi @kassner. Thank you for your report. The fix will be available with the upcoming 2.3.2 release. |
Warning is eliminated by mentioned PR but I doubt that
is now solved. @kassner why did you include bootstrap instead of |
@orlangur I use it because I'm loading the ObjectManager, mainly to validate my code against the generated factories/interceptors/etc, which gives me more safety and avoids ignoring tons of errors on phpstan, at the expense of a slower run. But, I fixed that with custom code based on this. Now I rely on <?php
/* Find autoload path */
$rootPath = realpath(dirname(__FILE__));
while (!file_exists($rootPath . '/app/autoload.php') || $rootPath == '/') {
$rootPath = realpath(dirname($rootPath));
}
/* Include Magento autoload file */
require_once $rootPath . '/app/autoload.php';
$loadedClasses = [];
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
spl_autoload_register(function ($class) use ($objectManager, $loadedClasses) {
if (isset($loadedClasses[$class])) {
return $loadedClasses[$class];
}
try {
$objectManager->get($class);
$loadedClasses[$class] = true;
} catch (\Throwable $e) {
$loadedClasses[$class] = false;
}
return $loadedClasses[$class];
}); And my
|
I bumped into my own ticket trying to run phpunit via a phar this time, and although I can understand the rationale of not having PHAR enabled in production, I believe this should be a responsability of the environment, not Magento's own code. It's feasible (and even safer) to disable PHAR via php.ini instead. Alternatively, I managed to run the integration tests without much fuss once I applied this patch:
|
I've managed to fix this by adding a file <?php
// See https://github.com/magento/magento2/issues/21973
// Magento 2.3.1 removes phar stream wrapper.
if (!in_array('phar', \stream_get_wrappers())) {
\stream_wrapper_restore('phar');
} then I've added it to the
|
Summary
The 2.3.1 release introduced the line
stream_wrapper_unregister('phar');
in the app/boostrap.php. It's unclear why it was added, but it breaks a few external tools, like PHPStan.Examples
And removing the aforementioned line:
Proposed solution
Ideally, we wouldn't have this line at all in the code, but someone added it there for some reason. I couldn't find any context about it why it's there, it's not mentioned in the Release Notes for the 2.3.1 version, neither the commit that introduced it gives any context about it.
Can we either have it removed or have an explanation about why we can't?
Thanks!
The text was updated successfully, but these errors were encountered: