getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.59k stars 1.41k forks source link

GPM Installer unZip() returning unexpected package folder name #2688

Open msqueeg opened 5 years ago

msqueeg commented 5 years ago

I encountered the following issue trying to use the Direct Upload interface in the Grav Admin plugin (Grav v1.6.16 - Admin v1.9.10 with PHP 7.2.19). On line 191 of Installer.php, $zip->getNameIndex(0) is returning the first subfolder of the theme (quark/assets) rather than the theme folder. This causes the the upload to fail because GravGPM::getPackageType() can't locate the blueprints.yaml in the given folder (line 228 in Grav\Plugin\Admin\Gpm). This seems to be unexpected behavior from getNameIndex(), not sure if something changed recently with the PHP 7.2.x. I've also encountered this with PHP 7.3.9 running on Ubuntu 18.04.

rhukster commented 5 years ago

What file are you trying to direct install?

mbabker commented 2 years ago

I just ran into this issue today with PHP 8.0.20 and Grav 1.7.34. In this case, the intention was to build a ZIP of a custom theme in our CI and use the direct-install command to update that when necessary (just a simple zip -r ../../theme.zip . from inside the user/themes/custom directory after our NPM scripts run).

It fails because Grav\Common\GPM\GPM::getPackageType() is called with the path /home/<site>/public_html/tmp/Grav-62b0b1b6c75ce/blueprints/, it needs to be one level higher for the command to work.

hdwebpros commented 2 years ago

We discovered that this issue only happens when the theme isn't zipped into it's containing folder.

Long story short, Basically, unzipping themefolder.zip would contain themefolder / blueprints, themefolder / css etc. If the zip file just contains blueprints, etc, then it will fail. This can be closed @rhukster