From: Tim Düsterhus Date: Tue, 2 Aug 2016 16:58:13 +0000 (+0200) Subject: Fix calculation of paths during WCFSetup X-Git-Tag: 3.0.0_Beta_1~821 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=89ff24b4ac52c37ab3c4205277e335c061a6a887;p=GitHub%2FWoltLab%2FWCF.git Fix calculation of paths during WCFSetup --- diff --git a/wcfsetup/install/files/lib/system/WCFSetup.class.php b/wcfsetup/install/files/lib/system/WCFSetup.class.php index 6ebde3c0ee..9787bdc052 100644 --- a/wcfsetup/install/files/lib/system/WCFSetup.class.php +++ b/wcfsetup/install/files/lib/system/WCFSetup.class.php @@ -512,7 +512,7 @@ class WCFSetup extends WCF { } else { // resolve path relative to document root - $relativePath = str_replace(FileUtil::unifyDirSeparator($_SERVER['DOCUMENT_ROOT']), '', FileUtil::unifyDirSeparator(INSTALL_SCRIPT_DIR)); + $relativePath = FileUtil::getRelativePath($_SERVER['DOCUMENT_ROOT'], INSTALL_SCRIPT_DIR); foreach ($packages as $application => $packageData) { self::$directories[$application] = $relativePath . ($application === 'wcf' ? '' : $packageData['directory'] . '/'); } @@ -834,7 +834,7 @@ class WCFSetup extends WCF { } else { // regular file - $fileInserts[] = str_replace(WCF_DIR, '', $file); + $fileInserts[] = preg_replace('/^'.preg_quote(WCF_DIR, '/').'/', '', $file); } } diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index 62dfd3336a..8dfbbdb181 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -794,8 +794,19 @@ class PackageInstallationDispatcher { $wcfDomainPath = $row['domainPath']; } - $documentRoot = str_replace($wcfDomainPath, '', FileUtil::unifyDirSeparator(WCF_DIR)); - $domainPath = str_replace($documentRoot, '', $packageDir); + $documentRoot = ''; + + // strip longest common suffix + $a = strrev(FileUtil::unifyDirSeparator($wcfDomainPath)); + $b = strrev($documentRoot = FileUtil::unifyDirSeparator(WCF_DIR)); + for ($i = 0, $max = min(strlen($a), strlen($b)); $i < $max; $i++) { + if ($a{$i} !== $b{$i}) { + $documentRoot = substr(strrev($b), 0, -$i); + break; + } + } + + $domainPath = FileUtil::addLeadingSlash(FileUtil::getRelativePath($documentRoot, $packageDir)); // update application path $application = new Application($this->getPackage()->packageID);