Commit | Line | Data |
---|---|---|
11ade432 AE |
1 | <?php |
2 | namespace wcf\system\package; | |
3 | use wcf\system\WCF; | |
4 | ||
5 | /** | |
a17de04e | 6 | * Creates a logical node-based uninstallation tree. |
11ade432 AE |
7 | * |
8 | * @author Alexander Ebert | |
c839bd49 | 9 | * @copyright 2001-2018 WoltLab GmbH |
11ade432 | 10 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
e71525e4 | 11 | * @package WoltLabSuite\Core\System\Package |
11ade432 AE |
12 | */ |
13 | class PackageUninstallationNodeBuilder extends PackageInstallationNodeBuilder { | |
14 | /** | |
0fcfe5f6 | 15 | * @inheritDoc |
11ade432 AE |
16 | */ |
17 | public function buildNodes() { | |
e25413a0 AE |
18 | if (!empty($this->parentNode)) { |
19 | $this->node = $this->getToken(); | |
20 | } | |
21 | ||
11ade432 AE |
22 | // build pip nodes |
23 | $this->buildPluginNodes(); | |
24 | ||
25 | // remove package | |
26 | $this->buildPackageNode(); | |
27 | } | |
28 | ||
29 | /** | |
0fcfe5f6 | 30 | * @inheritDoc |
11ade432 AE |
31 | */ |
32 | protected function buildPluginNodes() { | |
e25413a0 AE |
33 | if (empty($this->node)) { |
34 | $this->node = $this->getToken(); | |
35 | } | |
11ade432 AE |
36 | |
37 | // fetch ordered pips | |
11ade432 | 38 | $sql = "SELECT pluginName, className, |
e7a80823 | 39 | CASE pluginName WHEN 'packageinstallationplugin' THEN 1 WHEN 'file' THEN 2 ELSE 0 END AS pluginOrder |
11ade432 | 40 | FROM wcf".WCF_N."_package_installation_plugin |
b6ae7d04 | 41 | ORDER BY pluginOrder, priority"; |
11ade432 AE |
42 | $statement = WCF::getDB()->prepareStatement($sql); |
43 | $statement->execute(); | |
069e3013 | 44 | $pips = $statement->fetchAll(\PDO::FETCH_ASSOC); |
11ade432 AE |
45 | |
46 | // insert pips | |
47 | $sql = "INSERT INTO wcf".WCF_N."_package_installation_node | |
e25413a0 AE |
48 | (queueID, processNo, sequenceNo, node, parentNode, nodeType, nodeData) |
49 | VALUES (?, ?, ?, ?, ?, ?, ?)"; | |
11ade432 AE |
50 | $statement = WCF::getDB()->prepareStatement($sql); |
51 | $sequenceNo = 0; | |
52 | ||
53 | foreach ($pips as $pip) { | |
058cbd6a | 54 | $statement->execute([ |
11ade432 AE |
55 | $this->installation->queue->queueID, |
56 | $this->installation->queue->processNo, | |
57 | $sequenceNo, | |
58 | $this->node, | |
e25413a0 | 59 | $this->parentNode, |
11ade432 | 60 | 'pip', |
058cbd6a | 61 | serialize([ |
11ade432 AE |
62 | 'pluginName' => $pip['pluginName'], |
63 | 'className' => $pip['className'] | |
058cbd6a MS |
64 | ]) |
65 | ]); | |
11ade432 AE |
66 | |
67 | $sequenceNo++; | |
68 | } | |
69 | } | |
70 | ||
71 | /** | |
0fcfe5f6 | 72 | * @inheritDoc |
11ade432 AE |
73 | */ |
74 | protected function buildPackageNode() { | |
75 | $this->parentNode = $this->node; | |
76 | $this->node = $this->getToken(); | |
77 | ||
78 | $sql = "INSERT INTO wcf".WCF_N."_package_installation_node | |
79 | (queueID, processNo, sequenceNo, node, parentNode, nodeType, nodeData) | |
80 | VALUES (?, ?, ?, ?, ?, ?, ?)"; | |
81 | $statement = WCF::getDB()->prepareStatement($sql); | |
058cbd6a | 82 | $statement->execute([ |
11ade432 AE |
83 | $this->installation->queue->queueID, |
84 | $this->installation->queue->processNo, | |
85 | 0, | |
86 | $this->node, | |
87 | $this->parentNode, | |
88 | 'package', | |
89 | 'a:0:{}' | |
058cbd6a | 90 | ]); |
11ade432 AE |
91 | } |
92 | } |