Fixed core installation in a path other than current
authorAlexander Ebert <ebert@woltlab.com>
Thu, 6 Oct 2016 11:21:40 +0000 (13:21 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 6 Oct 2016 11:21:40 +0000 (13:21 +0200)
wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php

index 70630e0a2a8b188eb961ca5f410cc3c52875b3a6..c172cf67c2cc836443ce66b02dc3b9c1cc097a37 100644 (file)
@@ -4,9 +4,12 @@ use wcf\data\application\Application;
 use wcf\data\application\ApplicationAction;
 use wcf\data\application\ApplicationList;
 use wcf\system\cache\builder\ApplicationCacheBuilder;
+use wcf\system\exception\SystemException;
+use wcf\system\io\File;
 use wcf\system\request\RouteHandler;
 use wcf\system\Regex;
 use wcf\system\SingletonFactory;
+use wcf\util\FileUtil;
 
 /**
  * Handles multi-application environments.
@@ -92,12 +95,21 @@ class ApplicationHandler extends SingletonFactory {
                // work-around during WCFSetup
                if (!PACKAGE_ID) {
                        $host = str_replace(RouteHandler::getProtocol(), '', RouteHandler::getHost());
+                       $documentRoot = FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator(realpath($_SERVER['DOCUMENT_ROOT'])));
+                       
+                       // always use the core directory
+                       if (empty($_POST['directories']) || empty($_POST['directories']['wcf'])) {
+                               // within ACP
+                               $_POST['directories'] = ['wcf' => $documentRoot . FileUtil::removeLeadingSlash(RouteHandler::getPath(['acp']))];
+                       }
+                       
+                       $path = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator(FileUtil::getRelativePath($documentRoot, $_POST['directories']['wcf']))));
                        
                        return new Application(null, [
                                'domainName' => $host,
-                               'domainPath' => RouteHandler::getPath(['acp']),
+                               'domainPath' => $path,
                                'cookieDomain' => $host,
-                               'cookiePath' => RouteHandler::getPath(['acp'])
+                               'cookiePath' => $path
                        ]);
                }
                else if (isset($this->cache['application'][PACKAGE_ID])) {