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

Error from dependency zipstream-php MyCLabs\Enum\Enum #3786

Closed
fabiomattei opened this issue Nov 8, 2023 · 7 comments
Closed

Error from dependency zipstream-php MyCLabs\Enum\Enum #3786

fabiomattei opened this issue Nov 8, 2023 · 7 comments

Comments

@fabiomattei
Copy link

This is a bug report:

It seems there is an issue in
zipstream-php/src/Option/Archive.php

In line 7 they write: use MyCLabs\Enum\Enum;
This dependecy does not match with any calsspath.

I checked the zipstream library out and I see they fixed this issue, do you maybe need to upgrade your dependency to the latest version?

Stack trace:
[ERROR] NOTICE: PHP message: PHP Fatal error: Uncaught Error: Class "MyCLabs\Enum\Enum" not found in /home/site/wwwroot/vendor/maennchen/zipstream-php/src/Option/Method.php:18
[ERROR] Stack trace:
[ERROR] #0 /home/site/wwwroot/vendor/composer/ClassLoader.php(444): include()
[ERROR] #1 /home/site/wwwroot/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/home/site/wwwr...')
[ERROR] #2 /home/site/wwwroot/vendor/maennchen/zipstream-php/src/Option/Archive.php(131): Composer\Autoload\ClassLoader->loadClass('ZipStream\Optio...')
[ERROR] #3 /home/site/wwwroot/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream2.php(15): ZipStream\Option\Archive->__construct()
[ERROR] #4 /home/site/wwwroot/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream0.php(15): PhpOffice\PhpSpreadsheet\Writer\ZipStream2::newZipStream(Resource id #27)
[ERROR] #5 /home/site/wwwroot/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php(548): PhpOffice\PhpSpreadsheet\Writer\ZipStream0::newZipStream(Resource id #27)
[ERROR] #6 /home/site/wwwroot/src/Controllers/UnitExcelExporter.php(169): PhpOffice\PhpSpreadsheet\Writer\Xlsx->save('php://output')
[ERROR] #7 /home/site/wwwroot/vendor/fabiomattei/uglyduckling/src/Common/Controllers/Controller.php(255): Fabiom\UDDemo\Controllers\UnitExcelExporter->getRequest()
[ERROR] #8 /home/site/wwwroot/index_saml.php(161): Fabiom\UglyDuckling\Common\Controllers\Controller->showPage()
[ERROR] #9 /home/site/wwwroot/index.php(11): require('/home/site/wwwr...')
[ERROR] #10 {main}
[ERROR] thrown in /home/site/wwwroot/vendor/maennchen/zipstream-php/src/Option/Method.php on line 18

@oleibman
Copy link
Collaborator

oleibman commented Nov 9, 2023

Our unit test suite runs with both ZipStream3 (nightly) and ZipStream2 (8.0, 8.1, 8.2), and none of those report a problem. It sounds like there is a problem in your environment, possibly due to Composer caching. Please see #3615 (comment) and other comments in that thread for suggestions.

@fabiomattei
Copy link
Author

Tahnk you very much, I am going to check that.

@oleibman
Copy link
Collaborator

No update in 9 months, closing.

@richardczeiger
Copy link

Hi all, I'm having exactly the same propblem. Using 3.3.0 I get the same issue.
It seems that you're calling ZIPSTREAM as a dependency but version 3.1.0 of ZIPSTREAM has NO 'Option" folder at all... This was removed from verion 3.0.0 of ZipStream. So you need to either update your code (my preferred option!) or downgrade the ZipStream dependency back to version 2.4.0.

The current dependency in your JSON file is set to:
"maennchen/zipstream-php": "^2.1 || ^3.0"

Here's the error:

[03-Oct-2024 11:26:36 Australia/Sydney] PHP Fatal error:  Uncaught Error: Class "MyCLabs\Enum\Enum" not found in /home/customer/www/root/public_html/vendor/maennchen/zipstream-php/src/Option/Method.php:18
Stack trace:
#0 /home/customer/www/root/public_html/vendor/composer/ClassLoader.php(576): include()
#1 /home/customer/www/root/public_html/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/home/customer/...')
#2 /home/customer/www/root/public_html/vendor/maennchen/zipstream-php/src/Option/Archive.php(131): Composer\Autoload\ClassLoader->loadClass('ZipStream\\Optio...')
#3 /home/customer/www/root/public_html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream2.php(15): ZipStream\Option\Archive->__construct()
#4 /home/customer/www/root/public_html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream0.php(15): PhpOffice\PhpSpreadsheet\Writer\ZipStream2::newZipStream(Resource id #147)
#5 /home/customer/www/root/public_html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php(513): PhpOffice\PhpSpreadsheet\Writer\ZipStream0::newZipStream(Resource id #147)
#6 /home/customer/www/root/public_html/content/report-hub-order.php(205): PhpOffice\PhpSpreadsheet\Writer\Xlsx->save('php://output')
#7 /home/customer/www/root/public_html/includes/page.php(15): require_once('/home/customer/...')
#8 /home/customer/www/root/public_html/index.php(9): require_once('/home/customer/...')
#9 {main}
  thrown in /home/customer/www/root/public_html/vendor/maennchen/zipstream-php/src/Option/Method.php on line 18

Many thanks! :)

@oleibman
Copy link
Collaborator

oleibman commented Oct 5, 2024

PhpSpreadsheet can handle either version of ZipStream. You have a problem with your composer cache. Please see #3615 (comment)

@richardczeiger
Copy link

richardczeiger commented Oct 8, 2024

PhpSpreadsheet can handle either version of ZipStream. You have a problem with your composer cache. Please see #3615 (comment)

Yup - I had already tried that but to no avail. Can you please explain HOW your code can use bother versions when your code calls a file that no longer exists in Zipstream version 3?? You code calls:
/vendor/maennchen/zipstream-php/src/Option/Archive.php(131)
But as I said in th original comment, this file no longer exists in ^3.0
Thanks :)

@oleibman
Copy link
Collaborator

oleibman commented Oct 9, 2024

Sure, you can tell by looking at your stack trace. The code calls ZipStream0::newZipStream. That routine tests for the existence of ZipStream\Option\Archive. If it exists, it calls ZipStream2::newZipStream; if it doesn't exist, it calls ZipStream3::newZipStream. From your stack trace, it calls ZipStream2, which means that it thinks ZipStream\Option\Archive exists. But, as you yourself confirmed, that does not exist, so it should be calling ZipStream3. So, as far as I can tell, the problem seems to be that Composer is using a cached version of ZipStream\Option\Archive, and will do so until the cache is cleaned up. If you can suggest another reason why the code appears to take the wrong path, please do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants