Duplicate xf-addon:build is broken in 2.0.10

Sim

Well-known member
Affected version
2.0.10
The changes made to XF\Service\AddOn\ReleaseBuilder in XF 2.0.10 introduced a bug where the release zip file is saved with leading slashes in all paths making them absolute rather than relative.

As a result:
  • Windows 10 cannot open the release zip files at all (reports them as empty)
  • 7zip opens them, identifies the root and lets you navigate to the upload folder (first folder is "unnamed")
  • unzip on Linux (Ubuntu) strips the leading slash to make the paths relative but gives warnings
This is what a release built with versions prior to 2.0.10 look like when testing:

Bash:
$ unzip -t release_built_with_2_0_7.zip
Archive:  release_built_with_2_0_7.zip
    testing: upload/                  OK
    testing: upload/src/              OK
    testing: upload/src/addons/       OK
    ... etc

Here's how it looks in XF 2.0.10:

Bash:
$ unzip -t release_built_with_2_0_10.zip
Archive:  release_built_with_2_0_10.zip
    testing: /upload/                 OK
    testing: /upload/src/             OK
    testing: /upload/src/addons/      OK
    ... etc

... note the leading slash in the path introduced in 2.0.10

I haven't had a chance to trace through the code yet to identify the source of the bug - will do when I get a chance.
 
Suggested fix:

In XF\Service\AddOn\ReleaseBuilder::build() line 407:

Change:
PHP:
$localName = substr($file->getPathname(), strlen($this->buildRoot));

to:
PHP:
$localName = substr($file->getPathname(), strlen($this->buildRoot . DIRECTORY_SEPARATOR));

... we need to strip the directory separator from the pathname as well, so increment the substring start point by the length of the directory separator.

This gives me correctly built release zip files.
 
Your fix is technically cleaner than mine, but honestly I'm not aware of any directory separator which is >1 character in length on a sane modern platform.

Yes, I figured that was a little paranoid - but you never know what happens with a DBCS!
 
Back
Top Bottom