panel icon indicating copy to clipboard operation
panel copied to clipboard

fix: child folder detection in ZIP for plugin extraction

Open UndercoverNL opened this issue 1 month ago • 3 comments

locateName does not support directory detection, fixed with new changes

Plugins can now correctly be uploaded as 1 zipped directory.

UndercoverNL avatar Nov 28 '25 16:11 UndercoverNL

[!IMPORTANT]

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 28 '25 16:11 coderabbitai[bot]

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

github-actions[bot] avatar Nov 28 '25 16:11 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

UndercoverNL avatar Nov 28 '25 16:11 UndercoverNL

Thanks, but I don't understand the problem with locateName? It does detect directories?

I tried with a zip that directly contains the plugin data and a zip that has a folder with the plugin data and both imported fine. grafik grafik

Boy132 avatar Dec 01 '25 07:12 Boy132

That's strange, on me it does not, with the current state of the branch when I upload: my-plugin.zip/my-plugin/plugin.json it creates /root/plugins/my-plugin/my-plugin/plugin.json, since when I dd $zip->locateName($pluginName . '/') it gives false even tho the zip structure is my-plugin.zip/my-plugin/plugin.json

UndercoverNL avatar Dec 01 '25 12:12 UndercoverNL

aaa I found the issue, so the issue is not locateName not detecting directories, but different ZIP tools not creating directory entries, for example, a ZIP tool which does not create a directory entry would only contain:

my-plugin/plugin.json
my-plugin/src/MyPluginPlugin.php

While a ZIP tool which does create a directory entry would actually contain

my-plugin/
my-plugin/plugin.json
my-plugin/src/MyPluginPlugin.php

Which would indeed work with the current code, so a more reliable way to check for this is by checking for the plugin.json file instead of the root directory it self:

$extractPath = $zip->locateName($pluginName . '/plugin.json') !== false ? base_path('plugins') : plugin_path($pluginName);

UndercoverNL avatar Dec 01 '25 12:12 UndercoverNL