From: Alexander Ebert Date: Tue, 24 Nov 2015 18:51:13 +0000 (+0100) Subject: Fixed WCFSetup / ACP X-Git-Tag: 3.0.0_Beta_1~2030^2~234^2~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=db8aa273d6eec8f364800681daf3e0a74cb2a624;p=GitHub%2FWoltLab%2FWCF.git Fixed WCFSetup / ACP --- diff --git a/wcfsetup/install.php b/wcfsetup/install.php index db3b11b607..de5a1789d3 100644 --- a/wcfsetup/install.php +++ b/wcfsetup/install.php @@ -158,7 +158,7 @@ class SystemException extends \Exception implements IPrintableException { /** * Loads the required classes automatically. */ -function __autoload($className) { +spl_autoload_register(function($className) { $namespaces = explode('\\', $className); if (count($namespaces) > 1) { // remove 'wcf' component @@ -170,7 +170,7 @@ function __autoload($className) { require_once($classPath); } } -} +}); /** * Escapes strings for execution in sql queries. @@ -577,15 +577,33 @@ class Tar { $i = 0; // Read the 512 bytes header + $longFilename = null; while (strlen($binaryData = $this->file->read(512)) != 0) { // read header $header = $this->readHeader($binaryData); if ($header === false) { continue; } - $this->contentList[$i] = $header; - $this->contentList[$i]['index'] = $i; - $i++; + + // fixes a bug that files with long names aren't correctly + // extracted + if ($longFilename !== null) { + $header['filename'] = $longFilename; + $longFilename = null; + } + if ($header['typeflag'] == 'L') { + $format = 'Z'.$header['size'].'filename'; + + $fileData = unpack($format, $this->file->read(512)); + $longFilename = $fileData['filename']; + $header['size'] = 0; + } + // don't include the @LongLink file in the content list + else { + $this->contentList[$i] = $header; + $this->contentList[$i]['index'] = $i; + $i++; + } $this->file->seek($this->file->tell() + (512 * ceil(($header['size'] / 512)))); } @@ -593,7 +611,7 @@ class Tar { /** * Unpacks file header for one file entry. - * + * * @param string $binaryData * @return array $fileheader */ @@ -618,14 +636,8 @@ class Tar { $checksum += ord(substr($binaryData, $i, 1)); } - // Extract the values - //$data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $binaryData); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { - $format = 'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor/Z155prefix'; - } - else { - $format = 'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix'; - } + // extract values + $format = 'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor/Z155prefix'; $data = unpack($format, $binaryData); diff --git a/wcfsetup/install/files/lib/system/WCFSetup.class.php b/wcfsetup/install/files/lib/system/WCFSetup.class.php index b53cef6a3a..9e0b2c8bf3 100644 --- a/wcfsetup/install/files/lib/system/WCFSetup.class.php +++ b/wcfsetup/install/files/lib/system/WCFSetup.class.php @@ -221,19 +221,15 @@ class WCFSetup extends WCF { * @return array */ protected static function getAvailableLanguages() { - $languages = $match = array(); - $tar = new Tar(SETUP_FILE); - foreach ($tar->getContentList() as $file) { - if (strpos($file['filename'], 'setup/lang/') === 0 && substr($file['filename'], -4) == '.xml') { - $xml = new XML(); - $xml->load(TMP_DIR.$file['filename']); - $languageCode = LanguageEditor::readLanguageCodeFromXML($xml); - $languageName = LanguageEditor::readLanguageNameFromXML($xml); - - $languages[$languageCode] = $languageName; - } + $languages = $match = []; + foreach (glob(TMP_DIR.'setup/lang/*.xml') as $file) { + $xml = new XML(); + $xml->load($file); + $languageCode = LanguageEditor::readLanguageCodeFromXML($xml); + $languageName = LanguageEditor::readLanguageNameFromXML($xml); + + $languages[$languageCode] = $languageName; } - $tar->close(); // sort languages by language name asort($languages); @@ -1163,7 +1159,7 @@ class WCFSetup extends WCF { } // login as admin - $factory = new ACPSessionFactory(); + $factory = WCF::getDIContainer()->make(ACPSessionFactory::class); $factory->load(); SessionHandler::getInstance()->changeUser($admin); diff --git a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php index dbdfef6f37..808bae8938 100644 --- a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php @@ -24,11 +24,6 @@ class LinkHandler extends SingletonFactory { */ protected $applicationHandler; - /** - * @var PageMenu - */ - protected $pageMenu; - /** * @var RequestHandler */ @@ -64,9 +59,8 @@ class LinkHandler extends SingletonFactory { * @param RequestHandler $requestHandler * @param RouteHandler $routeHandler */ - public function __construct(ApplicationHandler $applicationHandler, PageMenu $pageMenu, RequestHandler $requestHandler, RouteHandler $routeHandler) { + public function __construct(ApplicationHandler $applicationHandler, RequestHandler $requestHandler, RouteHandler $routeHandler) { $this->applicationHandler = $applicationHandler; - $this->pageMenu = $pageMenu; $this->requestHandler = $requestHandler; $this->routeHandler = $routeHandler; @@ -163,7 +157,8 @@ class LinkHandler extends SingletonFactory { $controller = 'Index'; } else { - return $this->pageMenu->getLandingPage()->getProcessor()->getLink(); + // loading the PageMenu object as a dependency in ACP requests breaks everything + return WCF::getDIContainer()->get(PageMenu::class)->getLandingPage()->getProcessor()->getLink(); } } diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php index 0e880d784b..59ad080c40 100644 --- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php @@ -49,11 +49,6 @@ class RequestHandler extends SingletonFactory { */ protected $isACPRequest = false; - /** - * @var PageMenu - */ - protected $pageMenu; - /** * @var RouteHandler */ @@ -66,10 +61,9 @@ class RequestHandler extends SingletonFactory { * @param ControllerMap $controllerMap * @param RouteHandler $routeHandler */ - public function __construct(ApplicationHandler $applicationHandler, ControllerMap $controllerMap, PageMenu $pageMenu, RouteHandler $routeHandler) { + public function __construct(ApplicationHandler $applicationHandler, ControllerMap $controllerMap, RouteHandler $routeHandler) { $this->applicationHandler = $applicationHandler; $this->controllerMap = $controllerMap; - $this->pageMenu = $pageMenu; $this->routeHandler = $routeHandler; parent::__construct(); @@ -273,7 +267,8 @@ class RequestHandler extends SingletonFactory { return; } - $landingPage = $this->pageMenu->getLandingPage(); + // loading the PageMenu object as a dependency in ACP requests breaks everything + $landingPage = WCF::getDIContainer()->get(PageMenu::class)->getLandingPage(); if ($landingPage === null) { return; } diff --git a/wcfsetup/install/files/lib/system/request/route/DynamicRequestRoute.class.php b/wcfsetup/install/files/lib/system/request/route/DynamicRequestRoute.class.php index 7b20a0113a..d9b2bfb698 100644 --- a/wcfsetup/install/files/lib/system/request/route/DynamicRequestRoute.class.php +++ b/wcfsetup/install/files/lib/system/request/route/DynamicRequestRoute.class.php @@ -5,6 +5,7 @@ use wcf\system\menu\page\PageMenu; use wcf\system\request\ControllerMap; use wcf\system\request\RequestHandler; use wcf\system\request\RouteHandler; +use wcf\system\WCF; /** * Dynamic route implementation to resolve HTTP requests, handling controllers using a distinct pattern. @@ -39,11 +40,6 @@ class DynamicRequestRoute implements IRequestRoute { */ protected $isACP = false; - /** - * @var PageMenu; - */ - protected $pageMenu; - /** * pattern for incoming requests * @var string @@ -83,14 +79,12 @@ class DynamicRequestRoute implements IRequestRoute { * * @param ApplicationHandler $applicationHandler * @param ControllerMap $controllerMap - * @param PageMenu $pageMenu * @param RequestHandler $requestHandler * @param RouteHandler $routeHandler */ - public function __construct(ApplicationHandler $applicationHandler, ControllerMap $controllerMap, PageMenu $pageMenu, RequestHandler $requestHandler, RouteHandler $routeHandler) { + public function __construct(ApplicationHandler $applicationHandler, ControllerMap $controllerMap, RequestHandler $requestHandler, RouteHandler $routeHandler) { $this->applicationHandler = $applicationHandler; $this->controllerMap = $controllerMap; - $this->pageMenu = $pageMenu; $this->requestHandler = $requestHandler; $this->routeHandler = $routeHandler; @@ -185,15 +179,16 @@ class DynamicRequestRoute implements IRequestRoute { if (count($components) == 1 && isset($components['controller'])) { $ignoreController = false; - if (!RequestHandler::getInstance()->isACPRequest()) { - $landingPage = PageMenu::getInstance()->getLandingPage(); + if (!$this->requestHandler->isACPRequest()) { + // loading the PageMenu object as a dependency in ACP requests breaks everything + $landingPage = WCF::getDIContainer()->get(PageMenu::class)->getLandingPage(); if ($this->primaryApplication === '') { - $primaryApplication = ApplicationHandler::getInstance()->getPrimaryApplication(); - $this->primaryApplication = ApplicationHandler::getInstance()->getAbbreviation($primaryApplication->packageID); + $primaryApplication = $this->applicationHandler->getPrimaryApplication(); + $this->primaryApplication = $this->applicationHandler->getAbbreviation($primaryApplication->packageID); } // check if this is the default controller - if (strcasecmp(RouteHandler::getInstance()->getDefaultController($application), $components['controller']) === 0) { + if (strcasecmp($this->routeHandler->getDefaultController($application), $components['controller']) === 0) { // check if this matches the primary application if ($this->primaryApplication === $application) { if (strcasecmp($landingPage->getController(), $components['controller']) === 0) {