From: Matthias Schmidt Date: Sun, 18 Aug 2019 11:30:13 +0000 (+0200) Subject: Log individual package installation steps X-Git-Tag: 5.2.0_Beta_1~16^2~1^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dc2c6fc43645d0bf4adcec1234ef9023dda53423;p=GitHub%2FWoltLab%2FWCF.git Log individual package installation steps See #2847 --- diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index 8ea75049bb..0022c45fe2 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -38,6 +38,7 @@ use wcf\system\user\storage\UserStorageHandler; use wcf\system\WCF; use wcf\util\FileUtil; use wcf\util\HeaderUtil; +use wcf\util\JSON; use wcf\util\StringUtil; /** @@ -132,6 +133,7 @@ class PackageInstallationDispatcher { $step = null; foreach ($nodes as $data) { $nodeData = unserialize($data['nodeData']); + $this->logInstallationStep($data); switch ($data['nodeType']) { case 'package': @@ -152,6 +154,7 @@ class PackageInstallationDispatcher { } if ($step->splitNode()) { + $this->logInstallationStep($data, 'split node'); $this->nodeBuilder->cloneNode($node, $data['sequenceNo']); break; } @@ -166,6 +169,8 @@ class PackageInstallationDispatcher { // perform post-install/update actions if ($node == '') { + $this->logInstallationStep([], 'start cleanup'); + // update "last update time" option $sql = "UPDATE wcf".WCF_N."_option SET optionValue = ? @@ -350,11 +355,46 @@ class PackageInstallationDispatcher { WHERE processNo = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([$this->queue->processNo]); + + $this->logInstallationStep([], 'finished cleanup'); } return $step; } + /** + * Logs an installation step. + * + * @param array $node data of the executed node + * @param string $log optional additional log text + */ + protected function logInstallationStep(array $node = [], $log = '') { + $time = TIME_NOW; + $logEntry = "[" . TIME_NOW . "]\n"; + if (!empty($node)) { + $logEntry .= 'sequenceNo: ' . $node['sequenceNo'] . "\n"; + $logEntry .= 'nodeType: ' . $node['nodeType'] . "\n"; + $logEntry .= "nodeData:\n"; + + $nodeData = unserialize($node['nodeData']); + foreach ($nodeData as $index => $value) { + $logEntry .= "\t" . $index . ': ' . (!is_object($value) && !is_array($value) ? $value : JSON::encode($value)) . "\n"; + } + } + + if ($log) { + $logEntry .= 'additional information: ' . $log . "\n"; + } + + $logEntry .= str_repeat('-', 30) . "\n\n"; + + file_put_contents( + WCF_DIR . 'log/' . date('Y-m-d', TIME_NOW) . '-update-' . $this->queue->queueID . '.txt', + $logEntry, + FILE_APPEND + ); + } + /** * Returns current package archive. *