Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2025-08-21 09:28:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,876
Website GitHub

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

#14 2025-08-21 09:49:54

etc
Developer
Registered: 2010-11-11
Posts: 5,427
Website GitHub

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

#15 2025-08-21 10:10:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,876
Website GitHub

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] in abc_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

#16 2025-08-21 10:35:54

etc
Developer
Registered: 2010-11-11
Posts: 5,427
Website GitHub

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

#17 2025-08-21 10:53:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,876
Website GitHub

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

#18 2025-08-21 20:30:39

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,369
Website GitHub Mastodon

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

#19 Yesterday 15:23:12

etc
Developer
Registered: 2010-11-11
Posts: 5,427
Website GitHub

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

#20 Today 13:56:27

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,413
GitHub

Re: ZIP plugin file requires archive subfolder, throws error otherwise.

wet wrote #340251:

1 […] enmattification […].

Narrator: an Automattic-affiliated lawyer is heard stirring.

Offline

Board footer

Powered by FluxBB