use wcf\system\session\ACPSessionFactory;
use wcf\system\session\SessionHandler;
use wcf\system\setup\Installer;
+use wcf\system\setup\SetupFileHandler;
use wcf\system\template\SetupTemplateEngine;
use wcf\util\DirectoryUtil;
use wcf\util\FileUtil;
$acpTemplateInserts = $fileInserts = [];
foreach (self::$installedFiles as $file) {
$match = [];
- if (preg_match('!/acp/templates/([^/]+)\.tpl$!', $file, $match)) {
+ if (preg_match('~^acp/templates/([^/]+)\.tpl$~', $file, $match)) {
// acp template
$acpTemplateInserts[] = $match[1];
}
else {
// regular file
- $fileInserts[] = preg_replace('/^'.preg_quote(WCF_DIR, '/').'/', '', $file);
+ $fileInserts[] = $file;
}
}
* Scans the given dir for installed files.
*
* @param string $dir
+ * @throws SystemException
*/
protected function getInstalledFiles($dir) {
- if ($files = glob($dir.'*')) {
- foreach ($files as $file) {
- if (is_dir($file)) {
- $this->getInstalledFiles(FileUtil::addTrailingSlash($file));
- }
- else {
- self::$installedFiles[] = FileUtil::unifyDirSeparator($file);
- }
- }
+ $logFile = $dir . 'files.log';
+ if (!file_exists($logFile)) {
+ throw new SystemException("Expected a valid file log at '".$logFile."'.");
}
+
+ self::$installedFiles = explode("\n", file_get_contents($logFile));
+
+ @unlink($logFile);
}
/**
* Installs the files of the tar archive.
*/
protected static function installFiles() {
- new Installer(self::$directories['wcf'], SETUP_FILE, null, 'install/files/');
+ $fileHandler = new SetupFileHandler();
+ new Installer(self::$directories['wcf'], SETUP_FILE, $fileHandler, 'install/files/');
+ $fileHandler->dumpToFile(self::$directories['wcf'] . 'files.log');
}
/**
--- /dev/null
+<?php
+namespace wcf\system\setup;
+
+/**
+ * Special file handler used during setup to log the deployed files.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Setup
+ */
+class SetupFileHandler implements IFileHandler {
+ /**
+ * list of installed files
+ * @var string[]
+ */
+ protected $files;
+
+ /**
+ * @inheritDoc
+ */
+ public function checkFiles(array $files) {
+ /* does nothing */
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function logFiles(array $files) {
+ $this->files = $files;
+ }
+
+ /**
+ * Writes the list of files to a log file.
+ *
+ * @param string $filename
+ */
+ public function dumpToFile($filename) {
+ file_put_contents($filename, implode("\n", $this->files));
+ }
+}