Fatal error: Uncaught ValueError: Invalid or uninitialized Zip object
Hi, I was trying to scan the site and came across this error. I don't know what the problem is, it's an exchange folder with an external product accounting system, maybe the file was deleted during the scan, or maybe the archive is not constistent, or maybe it's a php bug.
300770/462840 Complete ...
Fatal error: Uncaught ValueError: Invalid or uninitialized Zip object in phpmussel/core/src/ZipHandler.php:75
Stack trace:
#0 phpmussel/core/src/ZipHandler.php(75): ZipArchive->close()
#1 phpmussel/core/src/Scanner.php(3089): phpMussel\Core\ZipHandler->__destruct()
#2 phpmussel/core/src/Scanner.php(1051): phpMussel\Core\Scanner->archiveRecursor('PK\x03\x04\x14\x00\x00\x08\x08\x00\x1A\xADOYw...', '../..//upload/1...', 2, 'upload/exchange...')
#3 phpmussel/core/src/Scanner.php(799): phpMussel\Core\Scanner->recursor('../..//upload/1...', 1)
#4 phpmussel/core/src/Scanner.php(239): phpMussel\Core\Scanner->recursor('../..')
#5 phpmussel/cli/src/CLI.php(228): phpMussel\Core\Scanner->scan('../..')
#6 example-cli.php(13): phpMussel\CLI\CLI->__construct(Object(phpMussel\Core\Loader), Object(phpMussel\Core\Scanner))
#7 {main}
thrown in phpmussel/core/src/ZipHandler.php on line 75
PHP 8.1.3 phpMussel 3.5.1
Thank you for bringing this to my attention.
This is the first time I've ever seen this particular problem, but based on what I've found and read online, plus based on what's mentioned at the issue you've linked to above, I strongly suspect that the changes to the ZipArchive class as mentioned at said above-linked issue are the culprit behind the fatal error that we're seeing here.
I think, the ZipArchive class now producing fatal errors when it fails to read a zip file, instead of simply returning false or returning an error as had always been the case in the past, is going to be pose a problem, because... (...). I'll reply back a little later, after I've thought about the problem a little more.
Scratch all that.. Looked at the problem a little closer; The cause of the problem is not in opening zip files, but in destructing the zip object instance. Found a very easy, very simple way to fix the problem, and have committed changes accordingly.
Haven't tagged a new release yet; I'll aim to do that later tonight, and reply back again when done.
I've tagged and pushed a new release (v3.5.3). Problem should now be fixed. :-)