Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: ZIP plugin file requires archive subfolder, throws error otherwise.
etc wrote #340257:
If memory serves, the initial purpose of fs plugin storage was to avoid loading them from db via
eval()
, blocked by many hosts.
Yes, this. The other goal was also to ensure all uploads go through the verification process, which paved the way for upgrades from the Plugins panel.
Last edited by Bloke (2025-08-21 09:40:59)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: ZIP plugin file requires archive subfolder, throws error otherwise.
etc wrote #340255:
Probably yes, even before unzipping (untested).
It works, so we can read manifest.json
before taking further actions. But what is the ‘well-known’ location? This file can be
- at the root of
abc_plugin2.zip
(that’s ok, but not how Windows works) - in
abc_plugin2.zip/abc_plugin
subdirectory, but then how we know this subdirectory name?
Additionally, the function is sensitive to the directory separator, so we’d have to test various /
and \
combinations.
Offline
Re: ZIP plugin file requires archive subfolder, throws error otherwise.
etc wrote #340260:
at the root of
abc_plugin2.zip
(that’s ok, but not how Windows works) [or] inabc_plugin2.zip/abc_plugin
subdirectory, but then how we know this subdirectory name?
That’s a good point. The only way is to compare the filenames (irrespective of path) and read one that matches the name. We might be limited by the order the files were added to the archive.
Last edited by etc (2025-08-21 10:26:23)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: ZIP plugin file requires archive subfolder, throws error otherwise.
etc wrote #340260:
in
abc_plugin2.zip/abc_plugin
subdirectory, but then how we know this subdirectory name?Additionally, the function is sensitive to the directory separator, so we’d have to test various
/
and\
combinations.
There seems to be an easy solution, with FL_NODIR
flag, to locate manifest.json
:
$zip = new ZipArchive;
if ($zip->open('path/to/abc_plugin.zip') === TRUE) {
$index = $zip->locateName('manifest.json', ZipArchive::FL_NODIR);
if ($index !== false) {
dmp($zip->getFromIndex($index));
} else {// apply defaults}
$zip->close();
}
Offline
Re: ZIP plugin file requires archive subfolder, throws error otherwise.
Nice find!
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: ZIP plugin file requires archive subfolder, throws error otherwise.
etc wrote #340260:
- at the root […] (that’s ok, but not how Windows works)
I beg to differ. The layout of a zip file is solely determined by the user who builds it. See exhibit. This is how I build on Windows, according to the zip layout requirements I learned in this thread.
The only relevant variable is your current pwd
but not the O/S imho.
Offline
Re: ZIP plugin file requires archive subfolder, throws error otherwise.
Ok, let us say it’s not how me on Windows works. I develop plugins inside their folders and then compress the entire folder in Explorer, getting abc_plugin.zip/abc_plugin/manifest.json
paths instead of abc_plugin.zip/manifest.json
layout. The least effort..
Offline