@@ -33,111 +33,111 @@ |
||
33 | 33 | use OCP\ILogger; |
34 | 34 | |
35 | 35 | class SetupController { |
36 | - /** @var Setup */ |
|
37 | - protected $setupHelper; |
|
38 | - /** @var string */ |
|
39 | - private $autoConfigFile; |
|
40 | - |
|
41 | - /** |
|
42 | - * @param Setup $setupHelper |
|
43 | - */ |
|
44 | - function __construct(Setup $setupHelper) { |
|
45 | - $this->autoConfigFile = \OC::$configDir.'autoconfig.php'; |
|
46 | - $this->setupHelper = $setupHelper; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @param $post |
|
51 | - */ |
|
52 | - public function run($post) { |
|
53 | - // Check for autosetup: |
|
54 | - $post = $this->loadAutoConfig($post); |
|
55 | - $opts = $this->setupHelper->getSystemInfo(); |
|
56 | - |
|
57 | - // convert 'abcpassword' to 'abcpass' |
|
58 | - if (isset($post['adminpassword'])) { |
|
59 | - $post['adminpass'] = $post['adminpassword']; |
|
60 | - } |
|
61 | - if (isset($post['dbpassword'])) { |
|
62 | - $post['dbpass'] = $post['dbpassword']; |
|
63 | - } |
|
64 | - |
|
65 | - if (!is_file(\OC::$configDir.'/CAN_INSTALL')) { |
|
66 | - $this->displaySetupForbidden(); |
|
67 | - return; |
|
68 | - } |
|
69 | - |
|
70 | - if(isset($post['install']) AND $post['install']=='true') { |
|
71 | - // We have to launch the installation process : |
|
72 | - $e = $this->setupHelper->install($post); |
|
73 | - $errors = array('errors' => $e); |
|
74 | - |
|
75 | - if(count($e) > 0) { |
|
76 | - $options = array_merge($opts, $post, $errors); |
|
77 | - $this->display($options); |
|
78 | - } else { |
|
79 | - $this->finishSetup(); |
|
80 | - } |
|
81 | - } else { |
|
82 | - $options = array_merge($opts, $post); |
|
83 | - $this->display($options); |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - private function displaySetupForbidden() { |
|
88 | - \OC_Template::printGuestPage('', 'installation_forbidden'); |
|
89 | - } |
|
90 | - |
|
91 | - public function display($post) { |
|
92 | - $defaults = array( |
|
93 | - 'adminlogin' => '', |
|
94 | - 'adminpass' => '', |
|
95 | - 'dbuser' => '', |
|
96 | - 'dbpass' => '', |
|
97 | - 'dbname' => '', |
|
98 | - 'dbtablespace' => '', |
|
99 | - 'dbhost' => 'localhost', |
|
100 | - 'dbtype' => '', |
|
101 | - ); |
|
102 | - $parameters = array_merge($defaults, $post); |
|
103 | - |
|
104 | - \OC_Util::addScript('setup'); |
|
105 | - \OC_Template::printGuestPage('', 'installation', $parameters); |
|
106 | - } |
|
107 | - |
|
108 | - public function finishSetup() { |
|
109 | - if( file_exists( $this->autoConfigFile )) { |
|
110 | - unlink($this->autoConfigFile); |
|
111 | - } |
|
112 | - \OC::$server->getIntegrityCodeChecker()->runInstanceVerification(); |
|
113 | - |
|
114 | - if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) { |
|
115 | - if (!unlink(\OC::$configDir.'/CAN_INSTALL')) { |
|
116 | - \OC_Template::printGuestPage('', 'installation_incomplete'); |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - \OC_Util::redirectToDefaultPage(); |
|
121 | - } |
|
122 | - |
|
123 | - public function loadAutoConfig($post) { |
|
124 | - if( file_exists($this->autoConfigFile)) { |
|
125 | - \OCP\Util::writeLog('core', 'Autoconfig file found, setting up Nextcloud…', ILogger::INFO); |
|
126 | - $AUTOCONFIG = array(); |
|
127 | - include $this->autoConfigFile; |
|
128 | - $post = array_merge ($post, $AUTOCONFIG); |
|
129 | - } |
|
130 | - |
|
131 | - $dbIsSet = isset($post['dbtype']); |
|
132 | - $directoryIsSet = isset($post['directory']); |
|
133 | - $adminAccountIsSet = isset($post['adminlogin']); |
|
134 | - |
|
135 | - if ($dbIsSet AND $directoryIsSet AND $adminAccountIsSet) { |
|
136 | - $post['install'] = 'true'; |
|
137 | - } |
|
138 | - $post['dbIsSet'] = $dbIsSet; |
|
139 | - $post['directoryIsSet'] = $directoryIsSet; |
|
140 | - |
|
141 | - return $post; |
|
142 | - } |
|
36 | + /** @var Setup */ |
|
37 | + protected $setupHelper; |
|
38 | + /** @var string */ |
|
39 | + private $autoConfigFile; |
|
40 | + |
|
41 | + /** |
|
42 | + * @param Setup $setupHelper |
|
43 | + */ |
|
44 | + function __construct(Setup $setupHelper) { |
|
45 | + $this->autoConfigFile = \OC::$configDir.'autoconfig.php'; |
|
46 | + $this->setupHelper = $setupHelper; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @param $post |
|
51 | + */ |
|
52 | + public function run($post) { |
|
53 | + // Check for autosetup: |
|
54 | + $post = $this->loadAutoConfig($post); |
|
55 | + $opts = $this->setupHelper->getSystemInfo(); |
|
56 | + |
|
57 | + // convert 'abcpassword' to 'abcpass' |
|
58 | + if (isset($post['adminpassword'])) { |
|
59 | + $post['adminpass'] = $post['adminpassword']; |
|
60 | + } |
|
61 | + if (isset($post['dbpassword'])) { |
|
62 | + $post['dbpass'] = $post['dbpassword']; |
|
63 | + } |
|
64 | + |
|
65 | + if (!is_file(\OC::$configDir.'/CAN_INSTALL')) { |
|
66 | + $this->displaySetupForbidden(); |
|
67 | + return; |
|
68 | + } |
|
69 | + |
|
70 | + if(isset($post['install']) AND $post['install']=='true') { |
|
71 | + // We have to launch the installation process : |
|
72 | + $e = $this->setupHelper->install($post); |
|
73 | + $errors = array('errors' => $e); |
|
74 | + |
|
75 | + if(count($e) > 0) { |
|
76 | + $options = array_merge($opts, $post, $errors); |
|
77 | + $this->display($options); |
|
78 | + } else { |
|
79 | + $this->finishSetup(); |
|
80 | + } |
|
81 | + } else { |
|
82 | + $options = array_merge($opts, $post); |
|
83 | + $this->display($options); |
|
84 | + } |
|
85 | + } |
|
86 | + |
|
87 | + private function displaySetupForbidden() { |
|
88 | + \OC_Template::printGuestPage('', 'installation_forbidden'); |
|
89 | + } |
|
90 | + |
|
91 | + public function display($post) { |
|
92 | + $defaults = array( |
|
93 | + 'adminlogin' => '', |
|
94 | + 'adminpass' => '', |
|
95 | + 'dbuser' => '', |
|
96 | + 'dbpass' => '', |
|
97 | + 'dbname' => '', |
|
98 | + 'dbtablespace' => '', |
|
99 | + 'dbhost' => 'localhost', |
|
100 | + 'dbtype' => '', |
|
101 | + ); |
|
102 | + $parameters = array_merge($defaults, $post); |
|
103 | + |
|
104 | + \OC_Util::addScript('setup'); |
|
105 | + \OC_Template::printGuestPage('', 'installation', $parameters); |
|
106 | + } |
|
107 | + |
|
108 | + public function finishSetup() { |
|
109 | + if( file_exists( $this->autoConfigFile )) { |
|
110 | + unlink($this->autoConfigFile); |
|
111 | + } |
|
112 | + \OC::$server->getIntegrityCodeChecker()->runInstanceVerification(); |
|
113 | + |
|
114 | + if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) { |
|
115 | + if (!unlink(\OC::$configDir.'/CAN_INSTALL')) { |
|
116 | + \OC_Template::printGuestPage('', 'installation_incomplete'); |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + \OC_Util::redirectToDefaultPage(); |
|
121 | + } |
|
122 | + |
|
123 | + public function loadAutoConfig($post) { |
|
124 | + if( file_exists($this->autoConfigFile)) { |
|
125 | + \OCP\Util::writeLog('core', 'Autoconfig file found, setting up Nextcloud…', ILogger::INFO); |
|
126 | + $AUTOCONFIG = array(); |
|
127 | + include $this->autoConfigFile; |
|
128 | + $post = array_merge ($post, $AUTOCONFIG); |
|
129 | + } |
|
130 | + |
|
131 | + $dbIsSet = isset($post['dbtype']); |
|
132 | + $directoryIsSet = isset($post['directory']); |
|
133 | + $adminAccountIsSet = isset($post['adminlogin']); |
|
134 | + |
|
135 | + if ($dbIsSet AND $directoryIsSet AND $adminAccountIsSet) { |
|
136 | + $post['install'] = 'true'; |
|
137 | + } |
|
138 | + $post['dbIsSet'] = $dbIsSet; |
|
139 | + $post['directoryIsSet'] = $directoryIsSet; |
|
140 | + |
|
141 | + return $post; |
|
142 | + } |
|
143 | 143 | } |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | - if(isset($post['install']) AND $post['install']=='true') { |
|
70 | + if (isset($post['install']) AND $post['install'] == 'true') { |
|
71 | 71 | // We have to launch the installation process : |
72 | 72 | $e = $this->setupHelper->install($post); |
73 | 73 | $errors = array('errors' => $e); |
74 | 74 | |
75 | - if(count($e) > 0) { |
|
75 | + if (count($e) > 0) { |
|
76 | 76 | $options = array_merge($opts, $post, $errors); |
77 | 77 | $this->display($options); |
78 | 78 | } else { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | public function finishSetup() { |
109 | - if( file_exists( $this->autoConfigFile )) { |
|
109 | + if (file_exists($this->autoConfigFile)) { |
|
110 | 110 | unlink($this->autoConfigFile); |
111 | 111 | } |
112 | 112 | \OC::$server->getIntegrityCodeChecker()->runInstanceVerification(); |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | public function loadAutoConfig($post) { |
124 | - if( file_exists($this->autoConfigFile)) { |
|
124 | + if (file_exists($this->autoConfigFile)) { |
|
125 | 125 | \OCP\Util::writeLog('core', 'Autoconfig file found, setting up Nextcloud…', ILogger::INFO); |
126 | 126 | $AUTOCONFIG = array(); |
127 | 127 | include $this->autoConfigFile; |
128 | - $post = array_merge ($post, $AUTOCONFIG); |
|
128 | + $post = array_merge($post, $AUTOCONFIG); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | $dbIsSet = isset($post['dbtype']); |
@@ -54,570 +54,570 @@ |
||
54 | 54 | */ |
55 | 55 | class Updater extends BasicEmitter { |
56 | 56 | |
57 | - /** @var ILogger $log */ |
|
58 | - private $log; |
|
59 | - |
|
60 | - /** @var IConfig */ |
|
61 | - private $config; |
|
62 | - |
|
63 | - /** @var Checker */ |
|
64 | - private $checker; |
|
65 | - |
|
66 | - /** @var Installer */ |
|
67 | - private $installer; |
|
68 | - |
|
69 | - private $logLevelNames = [ |
|
70 | - 0 => 'Debug', |
|
71 | - 1 => 'Info', |
|
72 | - 2 => 'Warning', |
|
73 | - 3 => 'Error', |
|
74 | - 4 => 'Fatal', |
|
75 | - ]; |
|
76 | - |
|
77 | - /** |
|
78 | - * @param IConfig $config |
|
79 | - * @param Checker $checker |
|
80 | - * @param ILogger $log |
|
81 | - * @param Installer $installer |
|
82 | - */ |
|
83 | - public function __construct(IConfig $config, |
|
84 | - Checker $checker, |
|
85 | - ILogger $log = null, |
|
86 | - Installer $installer) { |
|
87 | - $this->log = $log; |
|
88 | - $this->config = $config; |
|
89 | - $this->checker = $checker; |
|
90 | - $this->installer = $installer; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * runs the update actions in maintenance mode, does not upgrade the source files |
|
95 | - * except the main .htaccess file |
|
96 | - * |
|
97 | - * @return bool true if the operation succeeded, false otherwise |
|
98 | - */ |
|
99 | - public function upgrade() { |
|
100 | - $this->emitRepairEvents(); |
|
101 | - $this->logAllEvents(); |
|
102 | - |
|
103 | - $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN); |
|
104 | - $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); |
|
105 | - $this->config->setSystemValue('loglevel', ILogger::DEBUG); |
|
106 | - |
|
107 | - $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); |
|
108 | - |
|
109 | - if(!$wasMaintenanceModeEnabled) { |
|
110 | - $this->config->setSystemValue('maintenance', true); |
|
111 | - $this->emit('\OC\Updater', 'maintenanceEnabled'); |
|
112 | - } |
|
113 | - |
|
114 | - // Clear CAN_INSTALL file if not on git |
|
115 | - if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) { |
|
116 | - if (!unlink(\OC::$configDir . '/CAN_INSTALL')) { |
|
117 | - $this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.'); |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - $installedVersion = $this->config->getSystemValue('version', '0.0.0'); |
|
122 | - $currentVersion = implode('.', \OCP\Util::getVersion()); |
|
123 | - |
|
124 | - $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core')); |
|
125 | - |
|
126 | - $success = true; |
|
127 | - try { |
|
128 | - $this->doUpgrade($currentVersion, $installedVersion); |
|
129 | - } catch (HintException $exception) { |
|
130 | - $this->log->logException($exception, ['app' => 'core']); |
|
131 | - $this->emit('\OC\Updater', 'failure', array($exception->getMessage() . ': ' .$exception->getHint())); |
|
132 | - $success = false; |
|
133 | - } catch (\Exception $exception) { |
|
134 | - $this->log->logException($exception, ['app' => 'core']); |
|
135 | - $this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage())); |
|
136 | - $success = false; |
|
137 | - } |
|
138 | - |
|
139 | - $this->emit('\OC\Updater', 'updateEnd', array($success)); |
|
140 | - |
|
141 | - if(!$wasMaintenanceModeEnabled && $success) { |
|
142 | - $this->config->setSystemValue('maintenance', false); |
|
143 | - $this->emit('\OC\Updater', 'maintenanceDisabled'); |
|
144 | - } else { |
|
145 | - $this->emit('\OC\Updater', 'maintenanceActive'); |
|
146 | - } |
|
147 | - |
|
148 | - $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); |
|
149 | - $this->config->setSystemValue('loglevel', $logLevel); |
|
150 | - $this->config->setSystemValue('installed', true); |
|
151 | - |
|
152 | - return $success; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Return version from which this version is allowed to upgrade from |
|
157 | - * |
|
158 | - * @return array allowed previous versions per vendor |
|
159 | - */ |
|
160 | - private function getAllowedPreviousVersions() { |
|
161 | - // this should really be a JSON file |
|
162 | - require \OC::$SERVERROOT . '/version.php'; |
|
163 | - /** @var array $OC_VersionCanBeUpgradedFrom */ |
|
164 | - return $OC_VersionCanBeUpgradedFrom; |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * Return vendor from which this version was published |
|
169 | - * |
|
170 | - * @return string Get the vendor |
|
171 | - */ |
|
172 | - private function getVendor() { |
|
173 | - // this should really be a JSON file |
|
174 | - require \OC::$SERVERROOT . '/version.php'; |
|
175 | - /** @var string $vendor */ |
|
176 | - return (string) $vendor; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Whether an upgrade to a specified version is possible |
|
181 | - * @param string $oldVersion |
|
182 | - * @param string $newVersion |
|
183 | - * @param array $allowedPreviousVersions |
|
184 | - * @return bool |
|
185 | - */ |
|
186 | - public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) { |
|
187 | - $version = explode('.', $oldVersion); |
|
188 | - $majorMinor = $version[0] . '.' . $version[1]; |
|
189 | - |
|
190 | - $currentVendor = $this->config->getAppValue('core', 'vendor', ''); |
|
191 | - |
|
192 | - // Vendor was not set correctly on install, so we have to white-list known versions |
|
193 | - if ($currentVendor === '' && isset($allowedPreviousVersions['owncloud'][$oldVersion])) { |
|
194 | - $currentVendor = 'owncloud'; |
|
195 | - } |
|
196 | - |
|
197 | - if ($currentVendor === 'nextcloud') { |
|
198 | - return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) |
|
199 | - && (version_compare($oldVersion, $newVersion, '<=') || |
|
200 | - $this->config->getSystemValue('debug', false)); |
|
201 | - } |
|
202 | - |
|
203 | - // Check if the instance can be migrated |
|
204 | - return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) || |
|
205 | - isset($allowedPreviousVersions[$currentVendor][$oldVersion]); |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * runs the update actions in maintenance mode, does not upgrade the source files |
|
210 | - * except the main .htaccess file |
|
211 | - * |
|
212 | - * @param string $currentVersion current version to upgrade to |
|
213 | - * @param string $installedVersion previous version from which to upgrade from |
|
214 | - * |
|
215 | - * @throws \Exception |
|
216 | - */ |
|
217 | - private function doUpgrade($currentVersion, $installedVersion) { |
|
218 | - // Stop update if the update is over several major versions |
|
219 | - $allowedPreviousVersions = $this->getAllowedPreviousVersions(); |
|
220 | - if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) { |
|
221 | - throw new \Exception('Updates between multiple major versions and downgrades are unsupported.'); |
|
222 | - } |
|
223 | - |
|
224 | - // Update .htaccess files |
|
225 | - try { |
|
226 | - Setup::updateHtaccess(); |
|
227 | - Setup::protectDataDirectory(); |
|
228 | - } catch (\Exception $e) { |
|
229 | - throw new \Exception($e->getMessage()); |
|
230 | - } |
|
231 | - |
|
232 | - // create empty file in data dir, so we can later find |
|
233 | - // out that this is indeed an ownCloud data directory |
|
234 | - // (in case it didn't exist before) |
|
235 | - file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); |
|
236 | - |
|
237 | - // pre-upgrade repairs |
|
238 | - $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher()); |
|
239 | - $repair->run(); |
|
240 | - |
|
241 | - $this->doCoreUpgrade(); |
|
242 | - |
|
243 | - try { |
|
244 | - // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378 |
|
245 | - Setup::installBackgroundJobs(); |
|
246 | - } catch (\Exception $e) { |
|
247 | - throw new \Exception($e->getMessage()); |
|
248 | - } |
|
249 | - |
|
250 | - // update all shipped apps |
|
251 | - $this->checkAppsRequirements(); |
|
252 | - $this->doAppUpgrade(); |
|
253 | - |
|
254 | - // Update the appfetchers version so it downloads the correct list from the appstore |
|
255 | - \OC::$server->getAppFetcher()->setVersion($currentVersion); |
|
256 | - |
|
257 | - // upgrade appstore apps |
|
258 | - $this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps()); |
|
259 | - $this->upgradeAppStoreApps(\OC_App::$autoDisabledApps, true); |
|
260 | - |
|
261 | - // install new shipped apps on upgrade |
|
262 | - OC_App::loadApps(['authentication']); |
|
263 | - $errors = Installer::installShippedApps(true); |
|
264 | - foreach ($errors as $appId => $exception) { |
|
265 | - /** @var \Exception $exception */ |
|
266 | - $this->log->logException($exception, ['app' => $appId]); |
|
267 | - $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]); |
|
268 | - } |
|
269 | - |
|
270 | - // post-upgrade repairs |
|
271 | - $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher()); |
|
272 | - $repair->run(); |
|
273 | - |
|
274 | - //Invalidate update feed |
|
275 | - $this->config->setAppValue('core', 'lastupdatedat', 0); |
|
276 | - |
|
277 | - // Check for code integrity if not disabled |
|
278 | - if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) { |
|
279 | - $this->emit('\OC\Updater', 'startCheckCodeIntegrity'); |
|
280 | - $this->checker->runInstanceVerification(); |
|
281 | - $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity'); |
|
282 | - } |
|
283 | - |
|
284 | - // only set the final version if everything went well |
|
285 | - $this->config->setSystemValue('version', implode('.', Util::getVersion())); |
|
286 | - $this->config->setAppValue('core', 'vendor', $this->getVendor()); |
|
287 | - } |
|
288 | - |
|
289 | - protected function doCoreUpgrade() { |
|
290 | - $this->emit('\OC\Updater', 'dbUpgradeBefore'); |
|
291 | - |
|
292 | - // execute core migrations |
|
293 | - $ms = new MigrationService('core', \OC::$server->getDatabaseConnection()); |
|
294 | - $ms->migrate(); |
|
295 | - |
|
296 | - $this->emit('\OC\Updater', 'dbUpgrade'); |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * @param string $version the oc version to check app compatibility with |
|
301 | - */ |
|
302 | - protected function checkAppUpgrade($version) { |
|
303 | - $apps = \OC_App::getEnabledApps(); |
|
304 | - $this->emit('\OC\Updater', 'appUpgradeCheckBefore'); |
|
305 | - |
|
306 | - $appManager = \OC::$server->getAppManager(); |
|
307 | - foreach ($apps as $appId) { |
|
308 | - $info = \OC_App::getAppInfo($appId); |
|
309 | - $compatible = \OC_App::isAppCompatible($version, $info); |
|
310 | - $isShipped = $appManager->isShipped($appId); |
|
311 | - |
|
312 | - if ($compatible && $isShipped && \OC_App::shouldUpgrade($appId)) { |
|
313 | - /** |
|
314 | - * FIXME: The preupdate check is performed before the database migration, otherwise database changes |
|
315 | - * are not possible anymore within it. - Consider this when touching the code. |
|
316 | - * @link https://github.com/owncloud/core/issues/10980 |
|
317 | - * @see \OC_App::updateApp |
|
318 | - */ |
|
319 | - if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) { |
|
320 | - $this->includePreUpdate($appId); |
|
321 | - } |
|
322 | - if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) { |
|
323 | - $this->emit('\OC\Updater', 'appSimulateUpdate', array($appId)); |
|
324 | - \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml'); |
|
325 | - } |
|
326 | - } |
|
327 | - } |
|
328 | - |
|
329 | - $this->emit('\OC\Updater', 'appUpgradeCheck'); |
|
330 | - } |
|
331 | - |
|
332 | - /** |
|
333 | - * Includes the pre-update file. Done here to prevent namespace mixups. |
|
334 | - * @param string $appId |
|
335 | - */ |
|
336 | - private function includePreUpdate($appId) { |
|
337 | - include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php'; |
|
338 | - } |
|
339 | - |
|
340 | - /** |
|
341 | - * upgrades all apps within a major ownCloud upgrade. Also loads "priority" |
|
342 | - * (types authentication, filesystem, logging, in that order) afterwards. |
|
343 | - * |
|
344 | - * @throws NeedsUpdateException |
|
345 | - */ |
|
346 | - protected function doAppUpgrade() { |
|
347 | - $apps = \OC_App::getEnabledApps(); |
|
348 | - $priorityTypes = array('authentication', 'filesystem', 'logging'); |
|
349 | - $pseudoOtherType = 'other'; |
|
350 | - $stacks = array($pseudoOtherType => array()); |
|
351 | - |
|
352 | - foreach ($apps as $appId) { |
|
353 | - $priorityType = false; |
|
354 | - foreach ($priorityTypes as $type) { |
|
355 | - if(!isset($stacks[$type])) { |
|
356 | - $stacks[$type] = array(); |
|
357 | - } |
|
358 | - if (\OC_App::isType($appId, [$type])) { |
|
359 | - $stacks[$type][] = $appId; |
|
360 | - $priorityType = true; |
|
361 | - break; |
|
362 | - } |
|
363 | - } |
|
364 | - if (!$priorityType) { |
|
365 | - $stacks[$pseudoOtherType][] = $appId; |
|
366 | - } |
|
367 | - } |
|
368 | - foreach ($stacks as $type => $stack) { |
|
369 | - foreach ($stack as $appId) { |
|
370 | - if (\OC_App::shouldUpgrade($appId)) { |
|
371 | - $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]); |
|
372 | - \OC_App::updateApp($appId); |
|
373 | - $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]); |
|
374 | - } |
|
375 | - if($type !== $pseudoOtherType) { |
|
376 | - // load authentication, filesystem and logging apps after |
|
377 | - // upgrading them. Other apps my need to rely on modifying |
|
378 | - // user and/or filesystem aspects. |
|
379 | - \OC_App::loadApp($appId); |
|
380 | - } |
|
381 | - } |
|
382 | - } |
|
383 | - } |
|
384 | - |
|
385 | - /** |
|
386 | - * check if the current enabled apps are compatible with the current |
|
387 | - * ownCloud version. disable them if not. |
|
388 | - * This is important if you upgrade ownCloud and have non ported 3rd |
|
389 | - * party apps installed. |
|
390 | - * |
|
391 | - * @return array |
|
392 | - * @throws \Exception |
|
393 | - */ |
|
394 | - private function checkAppsRequirements() { |
|
395 | - $isCoreUpgrade = $this->isCodeUpgrade(); |
|
396 | - $apps = OC_App::getEnabledApps(); |
|
397 | - $version = implode('.', Util::getVersion()); |
|
398 | - $disabledApps = []; |
|
399 | - $appManager = \OC::$server->getAppManager(); |
|
400 | - foreach ($apps as $app) { |
|
401 | - // check if the app is compatible with this version of ownCloud |
|
402 | - $info = OC_App::getAppInfo($app); |
|
403 | - if($info === null || !OC_App::isAppCompatible($version, $info)) { |
|
404 | - if ($appManager->isShipped($app)) { |
|
405 | - throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update'); |
|
406 | - } |
|
407 | - \OC::$server->getAppManager()->disableApp($app); |
|
408 | - $this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app)); |
|
409 | - } |
|
410 | - // no need to disable any app in case this is a non-core upgrade |
|
411 | - if (!$isCoreUpgrade) { |
|
412 | - continue; |
|
413 | - } |
|
414 | - // shipped apps will remain enabled |
|
415 | - if ($appManager->isShipped($app)) { |
|
416 | - continue; |
|
417 | - } |
|
418 | - // authentication and session apps will remain enabled as well |
|
419 | - if (OC_App::isType($app, ['session', 'authentication'])) { |
|
420 | - continue; |
|
421 | - } |
|
422 | - } |
|
423 | - return $disabledApps; |
|
424 | - } |
|
425 | - |
|
426 | - /** |
|
427 | - * @return bool |
|
428 | - */ |
|
429 | - private function isCodeUpgrade() { |
|
430 | - $installedVersion = $this->config->getSystemValue('version', '0.0.0'); |
|
431 | - $currentVersion = implode('.', Util::getVersion()); |
|
432 | - if (version_compare($currentVersion, $installedVersion, '>')) { |
|
433 | - return true; |
|
434 | - } |
|
435 | - return false; |
|
436 | - } |
|
437 | - |
|
438 | - /** |
|
439 | - * @param array $disabledApps |
|
440 | - * @param bool $reenable |
|
441 | - * @throws \Exception |
|
442 | - */ |
|
443 | - private function upgradeAppStoreApps(array $disabledApps, $reenable = false) { |
|
444 | - foreach($disabledApps as $app) { |
|
445 | - try { |
|
446 | - $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]); |
|
447 | - if ($this->installer->isUpdateAvailable($app)) { |
|
448 | - $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]); |
|
449 | - $this->installer->updateAppstoreApp($app); |
|
450 | - } |
|
451 | - $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]); |
|
452 | - |
|
453 | - if ($reenable) { |
|
454 | - $ocApp = new \OC_App(); |
|
455 | - $ocApp->enable($app); |
|
456 | - } |
|
457 | - } catch (\Exception $ex) { |
|
458 | - $this->log->logException($ex, ['app' => 'core']); |
|
459 | - } |
|
460 | - } |
|
461 | - } |
|
462 | - |
|
463 | - /** |
|
464 | - * Forward messages emitted by the repair routine |
|
465 | - */ |
|
466 | - private function emitRepairEvents() { |
|
467 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
468 | - $dispatcher->addListener('\OC\Repair::warning', function ($event) { |
|
469 | - if ($event instanceof GenericEvent) { |
|
470 | - $this->emit('\OC\Updater', 'repairWarning', $event->getArguments()); |
|
471 | - } |
|
472 | - }); |
|
473 | - $dispatcher->addListener('\OC\Repair::error', function ($event) { |
|
474 | - if ($event instanceof GenericEvent) { |
|
475 | - $this->emit('\OC\Updater', 'repairError', $event->getArguments()); |
|
476 | - } |
|
477 | - }); |
|
478 | - $dispatcher->addListener('\OC\Repair::info', function ($event) { |
|
479 | - if ($event instanceof GenericEvent) { |
|
480 | - $this->emit('\OC\Updater', 'repairInfo', $event->getArguments()); |
|
481 | - } |
|
482 | - }); |
|
483 | - $dispatcher->addListener('\OC\Repair::step', function ($event) { |
|
484 | - if ($event instanceof GenericEvent) { |
|
485 | - $this->emit('\OC\Updater', 'repairStep', $event->getArguments()); |
|
486 | - } |
|
487 | - }); |
|
488 | - } |
|
489 | - |
|
490 | - private function logAllEvents() { |
|
491 | - $log = $this->log; |
|
492 | - |
|
493 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
494 | - $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($log) { |
|
495 | - if (!$event instanceof GenericEvent) { |
|
496 | - return; |
|
497 | - } |
|
498 | - $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']); |
|
499 | - }); |
|
500 | - $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($log) { |
|
501 | - if (!$event instanceof GenericEvent) { |
|
502 | - return; |
|
503 | - } |
|
504 | - $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']); |
|
505 | - }); |
|
506 | - |
|
507 | - $repairListener = function($event) use ($log) { |
|
508 | - if (!$event instanceof GenericEvent) { |
|
509 | - return; |
|
510 | - } |
|
511 | - switch ($event->getSubject()) { |
|
512 | - case '\OC\Repair::startProgress': |
|
513 | - $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']); |
|
514 | - break; |
|
515 | - case '\OC\Repair::advance': |
|
516 | - $desc = $event->getArgument(1); |
|
517 | - if (empty($desc)) { |
|
518 | - $desc = ''; |
|
519 | - } |
|
520 | - $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']); |
|
521 | - |
|
522 | - break; |
|
523 | - case '\OC\Repair::finishProgress': |
|
524 | - $log->info('\OC\Repair::finishProgress', ['app' => 'updater']); |
|
525 | - break; |
|
526 | - case '\OC\Repair::step': |
|
527 | - $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']); |
|
528 | - break; |
|
529 | - case '\OC\Repair::info': |
|
530 | - $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']); |
|
531 | - break; |
|
532 | - case '\OC\Repair::warning': |
|
533 | - $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']); |
|
534 | - break; |
|
535 | - case '\OC\Repair::error': |
|
536 | - $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']); |
|
537 | - break; |
|
538 | - } |
|
539 | - }; |
|
540 | - |
|
541 | - $dispatcher->addListener('\OC\Repair::startProgress', $repairListener); |
|
542 | - $dispatcher->addListener('\OC\Repair::advance', $repairListener); |
|
543 | - $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener); |
|
544 | - $dispatcher->addListener('\OC\Repair::step', $repairListener); |
|
545 | - $dispatcher->addListener('\OC\Repair::info', $repairListener); |
|
546 | - $dispatcher->addListener('\OC\Repair::warning', $repairListener); |
|
547 | - $dispatcher->addListener('\OC\Repair::error', $repairListener); |
|
548 | - |
|
549 | - |
|
550 | - $this->listen('\OC\Updater', 'maintenanceEnabled', function () use($log) { |
|
551 | - $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']); |
|
552 | - }); |
|
553 | - $this->listen('\OC\Updater', 'maintenanceDisabled', function () use($log) { |
|
554 | - $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']); |
|
555 | - }); |
|
556 | - $this->listen('\OC\Updater', 'maintenanceActive', function () use($log) { |
|
557 | - $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']); |
|
558 | - }); |
|
559 | - $this->listen('\OC\Updater', 'updateEnd', function ($success) use($log) { |
|
560 | - if ($success) { |
|
561 | - $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']); |
|
562 | - } else { |
|
563 | - $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']); |
|
564 | - } |
|
565 | - }); |
|
566 | - $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use($log) { |
|
567 | - $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']); |
|
568 | - }); |
|
569 | - $this->listen('\OC\Updater', 'dbUpgrade', function () use($log) { |
|
570 | - $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']); |
|
571 | - }); |
|
572 | - $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($log) { |
|
573 | - $log->info('\OC\Updater::dbSimulateUpgradeBefore: Checking whether the database schema can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
|
574 | - }); |
|
575 | - $this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($log) { |
|
576 | - $log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']); |
|
577 | - }); |
|
578 | - $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($log) { |
|
579 | - $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']); |
|
580 | - }); |
|
581 | - $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($log) { |
|
582 | - $log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']); |
|
583 | - }); |
|
584 | - $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($log) { |
|
585 | - $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']); |
|
586 | - }); |
|
587 | - $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($log) { |
|
588 | - $log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']); |
|
589 | - }); |
|
590 | - $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) { |
|
591 | - $log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']); |
|
592 | - }); |
|
593 | - $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) { |
|
594 | - $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
|
595 | - }); |
|
596 | - $this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) { |
|
597 | - $log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']); |
|
598 | - }); |
|
599 | - $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) { |
|
600 | - $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']); |
|
601 | - }); |
|
602 | - $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) { |
|
603 | - $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']); |
|
604 | - }); |
|
605 | - $this->listen('\OC\Updater', 'failure', function ($message) use($log) { |
|
606 | - $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']); |
|
607 | - }); |
|
608 | - $this->listen('\OC\Updater', 'setDebugLogLevel', function () use($log) { |
|
609 | - $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']); |
|
610 | - }); |
|
611 | - $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($log) { |
|
612 | - $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']); |
|
613 | - }); |
|
614 | - $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($log) { |
|
615 | - $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']); |
|
616 | - }); |
|
617 | - $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($log) { |
|
618 | - $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']); |
|
619 | - }); |
|
620 | - |
|
621 | - } |
|
57 | + /** @var ILogger $log */ |
|
58 | + private $log; |
|
59 | + |
|
60 | + /** @var IConfig */ |
|
61 | + private $config; |
|
62 | + |
|
63 | + /** @var Checker */ |
|
64 | + private $checker; |
|
65 | + |
|
66 | + /** @var Installer */ |
|
67 | + private $installer; |
|
68 | + |
|
69 | + private $logLevelNames = [ |
|
70 | + 0 => 'Debug', |
|
71 | + 1 => 'Info', |
|
72 | + 2 => 'Warning', |
|
73 | + 3 => 'Error', |
|
74 | + 4 => 'Fatal', |
|
75 | + ]; |
|
76 | + |
|
77 | + /** |
|
78 | + * @param IConfig $config |
|
79 | + * @param Checker $checker |
|
80 | + * @param ILogger $log |
|
81 | + * @param Installer $installer |
|
82 | + */ |
|
83 | + public function __construct(IConfig $config, |
|
84 | + Checker $checker, |
|
85 | + ILogger $log = null, |
|
86 | + Installer $installer) { |
|
87 | + $this->log = $log; |
|
88 | + $this->config = $config; |
|
89 | + $this->checker = $checker; |
|
90 | + $this->installer = $installer; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * runs the update actions in maintenance mode, does not upgrade the source files |
|
95 | + * except the main .htaccess file |
|
96 | + * |
|
97 | + * @return bool true if the operation succeeded, false otherwise |
|
98 | + */ |
|
99 | + public function upgrade() { |
|
100 | + $this->emitRepairEvents(); |
|
101 | + $this->logAllEvents(); |
|
102 | + |
|
103 | + $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN); |
|
104 | + $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); |
|
105 | + $this->config->setSystemValue('loglevel', ILogger::DEBUG); |
|
106 | + |
|
107 | + $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); |
|
108 | + |
|
109 | + if(!$wasMaintenanceModeEnabled) { |
|
110 | + $this->config->setSystemValue('maintenance', true); |
|
111 | + $this->emit('\OC\Updater', 'maintenanceEnabled'); |
|
112 | + } |
|
113 | + |
|
114 | + // Clear CAN_INSTALL file if not on git |
|
115 | + if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) { |
|
116 | + if (!unlink(\OC::$configDir . '/CAN_INSTALL')) { |
|
117 | + $this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.'); |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + $installedVersion = $this->config->getSystemValue('version', '0.0.0'); |
|
122 | + $currentVersion = implode('.', \OCP\Util::getVersion()); |
|
123 | + |
|
124 | + $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core')); |
|
125 | + |
|
126 | + $success = true; |
|
127 | + try { |
|
128 | + $this->doUpgrade($currentVersion, $installedVersion); |
|
129 | + } catch (HintException $exception) { |
|
130 | + $this->log->logException($exception, ['app' => 'core']); |
|
131 | + $this->emit('\OC\Updater', 'failure', array($exception->getMessage() . ': ' .$exception->getHint())); |
|
132 | + $success = false; |
|
133 | + } catch (\Exception $exception) { |
|
134 | + $this->log->logException($exception, ['app' => 'core']); |
|
135 | + $this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage())); |
|
136 | + $success = false; |
|
137 | + } |
|
138 | + |
|
139 | + $this->emit('\OC\Updater', 'updateEnd', array($success)); |
|
140 | + |
|
141 | + if(!$wasMaintenanceModeEnabled && $success) { |
|
142 | + $this->config->setSystemValue('maintenance', false); |
|
143 | + $this->emit('\OC\Updater', 'maintenanceDisabled'); |
|
144 | + } else { |
|
145 | + $this->emit('\OC\Updater', 'maintenanceActive'); |
|
146 | + } |
|
147 | + |
|
148 | + $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); |
|
149 | + $this->config->setSystemValue('loglevel', $logLevel); |
|
150 | + $this->config->setSystemValue('installed', true); |
|
151 | + |
|
152 | + return $success; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Return version from which this version is allowed to upgrade from |
|
157 | + * |
|
158 | + * @return array allowed previous versions per vendor |
|
159 | + */ |
|
160 | + private function getAllowedPreviousVersions() { |
|
161 | + // this should really be a JSON file |
|
162 | + require \OC::$SERVERROOT . '/version.php'; |
|
163 | + /** @var array $OC_VersionCanBeUpgradedFrom */ |
|
164 | + return $OC_VersionCanBeUpgradedFrom; |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * Return vendor from which this version was published |
|
169 | + * |
|
170 | + * @return string Get the vendor |
|
171 | + */ |
|
172 | + private function getVendor() { |
|
173 | + // this should really be a JSON file |
|
174 | + require \OC::$SERVERROOT . '/version.php'; |
|
175 | + /** @var string $vendor */ |
|
176 | + return (string) $vendor; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Whether an upgrade to a specified version is possible |
|
181 | + * @param string $oldVersion |
|
182 | + * @param string $newVersion |
|
183 | + * @param array $allowedPreviousVersions |
|
184 | + * @return bool |
|
185 | + */ |
|
186 | + public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) { |
|
187 | + $version = explode('.', $oldVersion); |
|
188 | + $majorMinor = $version[0] . '.' . $version[1]; |
|
189 | + |
|
190 | + $currentVendor = $this->config->getAppValue('core', 'vendor', ''); |
|
191 | + |
|
192 | + // Vendor was not set correctly on install, so we have to white-list known versions |
|
193 | + if ($currentVendor === '' && isset($allowedPreviousVersions['owncloud'][$oldVersion])) { |
|
194 | + $currentVendor = 'owncloud'; |
|
195 | + } |
|
196 | + |
|
197 | + if ($currentVendor === 'nextcloud') { |
|
198 | + return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) |
|
199 | + && (version_compare($oldVersion, $newVersion, '<=') || |
|
200 | + $this->config->getSystemValue('debug', false)); |
|
201 | + } |
|
202 | + |
|
203 | + // Check if the instance can be migrated |
|
204 | + return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) || |
|
205 | + isset($allowedPreviousVersions[$currentVendor][$oldVersion]); |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * runs the update actions in maintenance mode, does not upgrade the source files |
|
210 | + * except the main .htaccess file |
|
211 | + * |
|
212 | + * @param string $currentVersion current version to upgrade to |
|
213 | + * @param string $installedVersion previous version from which to upgrade from |
|
214 | + * |
|
215 | + * @throws \Exception |
|
216 | + */ |
|
217 | + private function doUpgrade($currentVersion, $installedVersion) { |
|
218 | + // Stop update if the update is over several major versions |
|
219 | + $allowedPreviousVersions = $this->getAllowedPreviousVersions(); |
|
220 | + if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) { |
|
221 | + throw new \Exception('Updates between multiple major versions and downgrades are unsupported.'); |
|
222 | + } |
|
223 | + |
|
224 | + // Update .htaccess files |
|
225 | + try { |
|
226 | + Setup::updateHtaccess(); |
|
227 | + Setup::protectDataDirectory(); |
|
228 | + } catch (\Exception $e) { |
|
229 | + throw new \Exception($e->getMessage()); |
|
230 | + } |
|
231 | + |
|
232 | + // create empty file in data dir, so we can later find |
|
233 | + // out that this is indeed an ownCloud data directory |
|
234 | + // (in case it didn't exist before) |
|
235 | + file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); |
|
236 | + |
|
237 | + // pre-upgrade repairs |
|
238 | + $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher()); |
|
239 | + $repair->run(); |
|
240 | + |
|
241 | + $this->doCoreUpgrade(); |
|
242 | + |
|
243 | + try { |
|
244 | + // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378 |
|
245 | + Setup::installBackgroundJobs(); |
|
246 | + } catch (\Exception $e) { |
|
247 | + throw new \Exception($e->getMessage()); |
|
248 | + } |
|
249 | + |
|
250 | + // update all shipped apps |
|
251 | + $this->checkAppsRequirements(); |
|
252 | + $this->doAppUpgrade(); |
|
253 | + |
|
254 | + // Update the appfetchers version so it downloads the correct list from the appstore |
|
255 | + \OC::$server->getAppFetcher()->setVersion($currentVersion); |
|
256 | + |
|
257 | + // upgrade appstore apps |
|
258 | + $this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps()); |
|
259 | + $this->upgradeAppStoreApps(\OC_App::$autoDisabledApps, true); |
|
260 | + |
|
261 | + // install new shipped apps on upgrade |
|
262 | + OC_App::loadApps(['authentication']); |
|
263 | + $errors = Installer::installShippedApps(true); |
|
264 | + foreach ($errors as $appId => $exception) { |
|
265 | + /** @var \Exception $exception */ |
|
266 | + $this->log->logException($exception, ['app' => $appId]); |
|
267 | + $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]); |
|
268 | + } |
|
269 | + |
|
270 | + // post-upgrade repairs |
|
271 | + $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher()); |
|
272 | + $repair->run(); |
|
273 | + |
|
274 | + //Invalidate update feed |
|
275 | + $this->config->setAppValue('core', 'lastupdatedat', 0); |
|
276 | + |
|
277 | + // Check for code integrity if not disabled |
|
278 | + if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) { |
|
279 | + $this->emit('\OC\Updater', 'startCheckCodeIntegrity'); |
|
280 | + $this->checker->runInstanceVerification(); |
|
281 | + $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity'); |
|
282 | + } |
|
283 | + |
|
284 | + // only set the final version if everything went well |
|
285 | + $this->config->setSystemValue('version', implode('.', Util::getVersion())); |
|
286 | + $this->config->setAppValue('core', 'vendor', $this->getVendor()); |
|
287 | + } |
|
288 | + |
|
289 | + protected function doCoreUpgrade() { |
|
290 | + $this->emit('\OC\Updater', 'dbUpgradeBefore'); |
|
291 | + |
|
292 | + // execute core migrations |
|
293 | + $ms = new MigrationService('core', \OC::$server->getDatabaseConnection()); |
|
294 | + $ms->migrate(); |
|
295 | + |
|
296 | + $this->emit('\OC\Updater', 'dbUpgrade'); |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * @param string $version the oc version to check app compatibility with |
|
301 | + */ |
|
302 | + protected function checkAppUpgrade($version) { |
|
303 | + $apps = \OC_App::getEnabledApps(); |
|
304 | + $this->emit('\OC\Updater', 'appUpgradeCheckBefore'); |
|
305 | + |
|
306 | + $appManager = \OC::$server->getAppManager(); |
|
307 | + foreach ($apps as $appId) { |
|
308 | + $info = \OC_App::getAppInfo($appId); |
|
309 | + $compatible = \OC_App::isAppCompatible($version, $info); |
|
310 | + $isShipped = $appManager->isShipped($appId); |
|
311 | + |
|
312 | + if ($compatible && $isShipped && \OC_App::shouldUpgrade($appId)) { |
|
313 | + /** |
|
314 | + * FIXME: The preupdate check is performed before the database migration, otherwise database changes |
|
315 | + * are not possible anymore within it. - Consider this when touching the code. |
|
316 | + * @link https://github.com/owncloud/core/issues/10980 |
|
317 | + * @see \OC_App::updateApp |
|
318 | + */ |
|
319 | + if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) { |
|
320 | + $this->includePreUpdate($appId); |
|
321 | + } |
|
322 | + if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) { |
|
323 | + $this->emit('\OC\Updater', 'appSimulateUpdate', array($appId)); |
|
324 | + \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml'); |
|
325 | + } |
|
326 | + } |
|
327 | + } |
|
328 | + |
|
329 | + $this->emit('\OC\Updater', 'appUpgradeCheck'); |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * Includes the pre-update file. Done here to prevent namespace mixups. |
|
334 | + * @param string $appId |
|
335 | + */ |
|
336 | + private function includePreUpdate($appId) { |
|
337 | + include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php'; |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * upgrades all apps within a major ownCloud upgrade. Also loads "priority" |
|
342 | + * (types authentication, filesystem, logging, in that order) afterwards. |
|
343 | + * |
|
344 | + * @throws NeedsUpdateException |
|
345 | + */ |
|
346 | + protected function doAppUpgrade() { |
|
347 | + $apps = \OC_App::getEnabledApps(); |
|
348 | + $priorityTypes = array('authentication', 'filesystem', 'logging'); |
|
349 | + $pseudoOtherType = 'other'; |
|
350 | + $stacks = array($pseudoOtherType => array()); |
|
351 | + |
|
352 | + foreach ($apps as $appId) { |
|
353 | + $priorityType = false; |
|
354 | + foreach ($priorityTypes as $type) { |
|
355 | + if(!isset($stacks[$type])) { |
|
356 | + $stacks[$type] = array(); |
|
357 | + } |
|
358 | + if (\OC_App::isType($appId, [$type])) { |
|
359 | + $stacks[$type][] = $appId; |
|
360 | + $priorityType = true; |
|
361 | + break; |
|
362 | + } |
|
363 | + } |
|
364 | + if (!$priorityType) { |
|
365 | + $stacks[$pseudoOtherType][] = $appId; |
|
366 | + } |
|
367 | + } |
|
368 | + foreach ($stacks as $type => $stack) { |
|
369 | + foreach ($stack as $appId) { |
|
370 | + if (\OC_App::shouldUpgrade($appId)) { |
|
371 | + $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]); |
|
372 | + \OC_App::updateApp($appId); |
|
373 | + $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]); |
|
374 | + } |
|
375 | + if($type !== $pseudoOtherType) { |
|
376 | + // load authentication, filesystem and logging apps after |
|
377 | + // upgrading them. Other apps my need to rely on modifying |
|
378 | + // user and/or filesystem aspects. |
|
379 | + \OC_App::loadApp($appId); |
|
380 | + } |
|
381 | + } |
|
382 | + } |
|
383 | + } |
|
384 | + |
|
385 | + /** |
|
386 | + * check if the current enabled apps are compatible with the current |
|
387 | + * ownCloud version. disable them if not. |
|
388 | + * This is important if you upgrade ownCloud and have non ported 3rd |
|
389 | + * party apps installed. |
|
390 | + * |
|
391 | + * @return array |
|
392 | + * @throws \Exception |
|
393 | + */ |
|
394 | + private function checkAppsRequirements() { |
|
395 | + $isCoreUpgrade = $this->isCodeUpgrade(); |
|
396 | + $apps = OC_App::getEnabledApps(); |
|
397 | + $version = implode('.', Util::getVersion()); |
|
398 | + $disabledApps = []; |
|
399 | + $appManager = \OC::$server->getAppManager(); |
|
400 | + foreach ($apps as $app) { |
|
401 | + // check if the app is compatible with this version of ownCloud |
|
402 | + $info = OC_App::getAppInfo($app); |
|
403 | + if($info === null || !OC_App::isAppCompatible($version, $info)) { |
|
404 | + if ($appManager->isShipped($app)) { |
|
405 | + throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update'); |
|
406 | + } |
|
407 | + \OC::$server->getAppManager()->disableApp($app); |
|
408 | + $this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app)); |
|
409 | + } |
|
410 | + // no need to disable any app in case this is a non-core upgrade |
|
411 | + if (!$isCoreUpgrade) { |
|
412 | + continue; |
|
413 | + } |
|
414 | + // shipped apps will remain enabled |
|
415 | + if ($appManager->isShipped($app)) { |
|
416 | + continue; |
|
417 | + } |
|
418 | + // authentication and session apps will remain enabled as well |
|
419 | + if (OC_App::isType($app, ['session', 'authentication'])) { |
|
420 | + continue; |
|
421 | + } |
|
422 | + } |
|
423 | + return $disabledApps; |
|
424 | + } |
|
425 | + |
|
426 | + /** |
|
427 | + * @return bool |
|
428 | + */ |
|
429 | + private function isCodeUpgrade() { |
|
430 | + $installedVersion = $this->config->getSystemValue('version', '0.0.0'); |
|
431 | + $currentVersion = implode('.', Util::getVersion()); |
|
432 | + if (version_compare($currentVersion, $installedVersion, '>')) { |
|
433 | + return true; |
|
434 | + } |
|
435 | + return false; |
|
436 | + } |
|
437 | + |
|
438 | + /** |
|
439 | + * @param array $disabledApps |
|
440 | + * @param bool $reenable |
|
441 | + * @throws \Exception |
|
442 | + */ |
|
443 | + private function upgradeAppStoreApps(array $disabledApps, $reenable = false) { |
|
444 | + foreach($disabledApps as $app) { |
|
445 | + try { |
|
446 | + $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]); |
|
447 | + if ($this->installer->isUpdateAvailable($app)) { |
|
448 | + $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]); |
|
449 | + $this->installer->updateAppstoreApp($app); |
|
450 | + } |
|
451 | + $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]); |
|
452 | + |
|
453 | + if ($reenable) { |
|
454 | + $ocApp = new \OC_App(); |
|
455 | + $ocApp->enable($app); |
|
456 | + } |
|
457 | + } catch (\Exception $ex) { |
|
458 | + $this->log->logException($ex, ['app' => 'core']); |
|
459 | + } |
|
460 | + } |
|
461 | + } |
|
462 | + |
|
463 | + /** |
|
464 | + * Forward messages emitted by the repair routine |
|
465 | + */ |
|
466 | + private function emitRepairEvents() { |
|
467 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
468 | + $dispatcher->addListener('\OC\Repair::warning', function ($event) { |
|
469 | + if ($event instanceof GenericEvent) { |
|
470 | + $this->emit('\OC\Updater', 'repairWarning', $event->getArguments()); |
|
471 | + } |
|
472 | + }); |
|
473 | + $dispatcher->addListener('\OC\Repair::error', function ($event) { |
|
474 | + if ($event instanceof GenericEvent) { |
|
475 | + $this->emit('\OC\Updater', 'repairError', $event->getArguments()); |
|
476 | + } |
|
477 | + }); |
|
478 | + $dispatcher->addListener('\OC\Repair::info', function ($event) { |
|
479 | + if ($event instanceof GenericEvent) { |
|
480 | + $this->emit('\OC\Updater', 'repairInfo', $event->getArguments()); |
|
481 | + } |
|
482 | + }); |
|
483 | + $dispatcher->addListener('\OC\Repair::step', function ($event) { |
|
484 | + if ($event instanceof GenericEvent) { |
|
485 | + $this->emit('\OC\Updater', 'repairStep', $event->getArguments()); |
|
486 | + } |
|
487 | + }); |
|
488 | + } |
|
489 | + |
|
490 | + private function logAllEvents() { |
|
491 | + $log = $this->log; |
|
492 | + |
|
493 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
494 | + $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($log) { |
|
495 | + if (!$event instanceof GenericEvent) { |
|
496 | + return; |
|
497 | + } |
|
498 | + $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']); |
|
499 | + }); |
|
500 | + $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($log) { |
|
501 | + if (!$event instanceof GenericEvent) { |
|
502 | + return; |
|
503 | + } |
|
504 | + $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']); |
|
505 | + }); |
|
506 | + |
|
507 | + $repairListener = function($event) use ($log) { |
|
508 | + if (!$event instanceof GenericEvent) { |
|
509 | + return; |
|
510 | + } |
|
511 | + switch ($event->getSubject()) { |
|
512 | + case '\OC\Repair::startProgress': |
|
513 | + $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']); |
|
514 | + break; |
|
515 | + case '\OC\Repair::advance': |
|
516 | + $desc = $event->getArgument(1); |
|
517 | + if (empty($desc)) { |
|
518 | + $desc = ''; |
|
519 | + } |
|
520 | + $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']); |
|
521 | + |
|
522 | + break; |
|
523 | + case '\OC\Repair::finishProgress': |
|
524 | + $log->info('\OC\Repair::finishProgress', ['app' => 'updater']); |
|
525 | + break; |
|
526 | + case '\OC\Repair::step': |
|
527 | + $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']); |
|
528 | + break; |
|
529 | + case '\OC\Repair::info': |
|
530 | + $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']); |
|
531 | + break; |
|
532 | + case '\OC\Repair::warning': |
|
533 | + $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']); |
|
534 | + break; |
|
535 | + case '\OC\Repair::error': |
|
536 | + $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']); |
|
537 | + break; |
|
538 | + } |
|
539 | + }; |
|
540 | + |
|
541 | + $dispatcher->addListener('\OC\Repair::startProgress', $repairListener); |
|
542 | + $dispatcher->addListener('\OC\Repair::advance', $repairListener); |
|
543 | + $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener); |
|
544 | + $dispatcher->addListener('\OC\Repair::step', $repairListener); |
|
545 | + $dispatcher->addListener('\OC\Repair::info', $repairListener); |
|
546 | + $dispatcher->addListener('\OC\Repair::warning', $repairListener); |
|
547 | + $dispatcher->addListener('\OC\Repair::error', $repairListener); |
|
548 | + |
|
549 | + |
|
550 | + $this->listen('\OC\Updater', 'maintenanceEnabled', function () use($log) { |
|
551 | + $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']); |
|
552 | + }); |
|
553 | + $this->listen('\OC\Updater', 'maintenanceDisabled', function () use($log) { |
|
554 | + $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']); |
|
555 | + }); |
|
556 | + $this->listen('\OC\Updater', 'maintenanceActive', function () use($log) { |
|
557 | + $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']); |
|
558 | + }); |
|
559 | + $this->listen('\OC\Updater', 'updateEnd', function ($success) use($log) { |
|
560 | + if ($success) { |
|
561 | + $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']); |
|
562 | + } else { |
|
563 | + $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']); |
|
564 | + } |
|
565 | + }); |
|
566 | + $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use($log) { |
|
567 | + $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']); |
|
568 | + }); |
|
569 | + $this->listen('\OC\Updater', 'dbUpgrade', function () use($log) { |
|
570 | + $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']); |
|
571 | + }); |
|
572 | + $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($log) { |
|
573 | + $log->info('\OC\Updater::dbSimulateUpgradeBefore: Checking whether the database schema can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
|
574 | + }); |
|
575 | + $this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($log) { |
|
576 | + $log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']); |
|
577 | + }); |
|
578 | + $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($log) { |
|
579 | + $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']); |
|
580 | + }); |
|
581 | + $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($log) { |
|
582 | + $log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']); |
|
583 | + }); |
|
584 | + $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($log) { |
|
585 | + $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']); |
|
586 | + }); |
|
587 | + $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($log) { |
|
588 | + $log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']); |
|
589 | + }); |
|
590 | + $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) { |
|
591 | + $log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']); |
|
592 | + }); |
|
593 | + $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) { |
|
594 | + $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
|
595 | + }); |
|
596 | + $this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) { |
|
597 | + $log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']); |
|
598 | + }); |
|
599 | + $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) { |
|
600 | + $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']); |
|
601 | + }); |
|
602 | + $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) { |
|
603 | + $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']); |
|
604 | + }); |
|
605 | + $this->listen('\OC\Updater', 'failure', function ($message) use($log) { |
|
606 | + $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']); |
|
607 | + }); |
|
608 | + $this->listen('\OC\Updater', 'setDebugLogLevel', function () use($log) { |
|
609 | + $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']); |
|
610 | + }); |
|
611 | + $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($log) { |
|
612 | + $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']); |
|
613 | + }); |
|
614 | + $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($log) { |
|
615 | + $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']); |
|
616 | + }); |
|
617 | + $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($log) { |
|
618 | + $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']); |
|
619 | + }); |
|
620 | + |
|
621 | + } |
|
622 | 622 | |
623 | 623 | } |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | $this->logAllEvents(); |
102 | 102 | |
103 | 103 | $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN); |
104 | - $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); |
|
104 | + $this->emit('\OC\Updater', 'setDebugLogLevel', [$logLevel, $this->logLevelNames[$logLevel]]); |
|
105 | 105 | $this->config->setSystemValue('loglevel', ILogger::DEBUG); |
106 | 106 | |
107 | 107 | $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); |
108 | 108 | |
109 | - if(!$wasMaintenanceModeEnabled) { |
|
109 | + if (!$wasMaintenanceModeEnabled) { |
|
110 | 110 | $this->config->setSystemValue('maintenance', true); |
111 | 111 | $this->emit('\OC\Updater', 'maintenanceEnabled'); |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Clear CAN_INSTALL file if not on git |
115 | 115 | if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) { |
116 | - if (!unlink(\OC::$configDir . '/CAN_INSTALL')) { |
|
116 | + if (!unlink(\OC::$configDir.'/CAN_INSTALL')) { |
|
117 | 117 | $this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.'); |
118 | 118 | } |
119 | 119 | } |
@@ -121,31 +121,31 @@ discard block |
||
121 | 121 | $installedVersion = $this->config->getSystemValue('version', '0.0.0'); |
122 | 122 | $currentVersion = implode('.', \OCP\Util::getVersion()); |
123 | 123 | |
124 | - $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core')); |
|
124 | + $this->log->debug('starting upgrade from '.$installedVersion.' to '.$currentVersion, array('app' => 'core')); |
|
125 | 125 | |
126 | 126 | $success = true; |
127 | 127 | try { |
128 | 128 | $this->doUpgrade($currentVersion, $installedVersion); |
129 | 129 | } catch (HintException $exception) { |
130 | 130 | $this->log->logException($exception, ['app' => 'core']); |
131 | - $this->emit('\OC\Updater', 'failure', array($exception->getMessage() . ': ' .$exception->getHint())); |
|
131 | + $this->emit('\OC\Updater', 'failure', array($exception->getMessage().': '.$exception->getHint())); |
|
132 | 132 | $success = false; |
133 | 133 | } catch (\Exception $exception) { |
134 | 134 | $this->log->logException($exception, ['app' => 'core']); |
135 | - $this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage())); |
|
135 | + $this->emit('\OC\Updater', 'failure', array(get_class($exception).': '.$exception->getMessage())); |
|
136 | 136 | $success = false; |
137 | 137 | } |
138 | 138 | |
139 | 139 | $this->emit('\OC\Updater', 'updateEnd', array($success)); |
140 | 140 | |
141 | - if(!$wasMaintenanceModeEnabled && $success) { |
|
141 | + if (!$wasMaintenanceModeEnabled && $success) { |
|
142 | 142 | $this->config->setSystemValue('maintenance', false); |
143 | 143 | $this->emit('\OC\Updater', 'maintenanceDisabled'); |
144 | 144 | } else { |
145 | 145 | $this->emit('\OC\Updater', 'maintenanceActive'); |
146 | 146 | } |
147 | 147 | |
148 | - $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); |
|
148 | + $this->emit('\OC\Updater', 'resetLogLevel', [$logLevel, $this->logLevelNames[$logLevel]]); |
|
149 | 149 | $this->config->setSystemValue('loglevel', $logLevel); |
150 | 150 | $this->config->setSystemValue('installed', true); |
151 | 151 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | private function getAllowedPreviousVersions() { |
161 | 161 | // this should really be a JSON file |
162 | - require \OC::$SERVERROOT . '/version.php'; |
|
162 | + require \OC::$SERVERROOT.'/version.php'; |
|
163 | 163 | /** @var array $OC_VersionCanBeUpgradedFrom */ |
164 | 164 | return $OC_VersionCanBeUpgradedFrom; |
165 | 165 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | private function getVendor() { |
173 | 173 | // this should really be a JSON file |
174 | - require \OC::$SERVERROOT . '/version.php'; |
|
174 | + require \OC::$SERVERROOT.'/version.php'; |
|
175 | 175 | /** @var string $vendor */ |
176 | 176 | return (string) $vendor; |
177 | 177 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) { |
187 | 187 | $version = explode('.', $oldVersion); |
188 | - $majorMinor = $version[0] . '.' . $version[1]; |
|
188 | + $majorMinor = $version[0].'.'.$version[1]; |
|
189 | 189 | |
190 | 190 | $currentVendor = $this->config->getAppValue('core', 'vendor', ''); |
191 | 191 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | // create empty file in data dir, so we can later find |
233 | 233 | // out that this is indeed an ownCloud data directory |
234 | 234 | // (in case it didn't exist before) |
235 | - file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); |
|
235 | + file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/.ocdata', ''); |
|
236 | 236 | |
237 | 237 | // pre-upgrade repairs |
238 | 238 | $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher()); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | foreach ($errors as $appId => $exception) { |
265 | 265 | /** @var \Exception $exception */ |
266 | 266 | $this->log->logException($exception, ['app' => $appId]); |
267 | - $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]); |
|
267 | + $this->emit('\OC\Updater', 'failure', [$appId.': '.$exception->getMessage()]); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | // post-upgrade repairs |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $this->config->setAppValue('core', 'lastupdatedat', 0); |
276 | 276 | |
277 | 277 | // Check for code integrity if not disabled |
278 | - if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) { |
|
278 | + if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) { |
|
279 | 279 | $this->emit('\OC\Updater', 'startCheckCodeIntegrity'); |
280 | 280 | $this->checker->runInstanceVerification(); |
281 | 281 | $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity'); |
@@ -316,12 +316,12 @@ discard block |
||
316 | 316 | * @link https://github.com/owncloud/core/issues/10980 |
317 | 317 | * @see \OC_App::updateApp |
318 | 318 | */ |
319 | - if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) { |
|
319 | + if (file_exists(\OC_App::getAppPath($appId).'/appinfo/preupdate.php')) { |
|
320 | 320 | $this->includePreUpdate($appId); |
321 | 321 | } |
322 | - if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) { |
|
322 | + if (file_exists(\OC_App::getAppPath($appId).'/appinfo/database.xml')) { |
|
323 | 323 | $this->emit('\OC\Updater', 'appSimulateUpdate', array($appId)); |
324 | - \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml'); |
|
324 | + \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId).'/appinfo/database.xml'); |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param string $appId |
335 | 335 | */ |
336 | 336 | private function includePreUpdate($appId) { |
337 | - include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php'; |
|
337 | + include \OC_App::getAppPath($appId).'/appinfo/preupdate.php'; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | foreach ($apps as $appId) { |
353 | 353 | $priorityType = false; |
354 | 354 | foreach ($priorityTypes as $type) { |
355 | - if(!isset($stacks[$type])) { |
|
355 | + if (!isset($stacks[$type])) { |
|
356 | 356 | $stacks[$type] = array(); |
357 | 357 | } |
358 | 358 | if (\OC_App::isType($appId, [$type])) { |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | \OC_App::updateApp($appId); |
373 | 373 | $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]); |
374 | 374 | } |
375 | - if($type !== $pseudoOtherType) { |
|
375 | + if ($type !== $pseudoOtherType) { |
|
376 | 376 | // load authentication, filesystem and logging apps after |
377 | 377 | // upgrading them. Other apps my need to rely on modifying |
378 | 378 | // user and/or filesystem aspects. |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | foreach ($apps as $app) { |
401 | 401 | // check if the app is compatible with this version of ownCloud |
402 | 402 | $info = OC_App::getAppInfo($app); |
403 | - if($info === null || !OC_App::isAppCompatible($version, $info)) { |
|
403 | + if ($info === null || !OC_App::isAppCompatible($version, $info)) { |
|
404 | 404 | if ($appManager->isShipped($app)) { |
405 | - throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update'); |
|
405 | + throw new \UnexpectedValueException('The files of the app "'.$app.'" were not correctly replaced before running the update'); |
|
406 | 406 | } |
407 | 407 | \OC::$server->getAppManager()->disableApp($app); |
408 | 408 | $this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app)); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @throws \Exception |
442 | 442 | */ |
443 | 443 | private function upgradeAppStoreApps(array $disabledApps, $reenable = false) { |
444 | - foreach($disabledApps as $app) { |
|
444 | + foreach ($disabledApps as $app) { |
|
445 | 445 | try { |
446 | 446 | $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]); |
447 | 447 | if ($this->installer->isUpdateAvailable($app)) { |
@@ -465,22 +465,22 @@ discard block |
||
465 | 465 | */ |
466 | 466 | private function emitRepairEvents() { |
467 | 467 | $dispatcher = \OC::$server->getEventDispatcher(); |
468 | - $dispatcher->addListener('\OC\Repair::warning', function ($event) { |
|
468 | + $dispatcher->addListener('\OC\Repair::warning', function($event) { |
|
469 | 469 | if ($event instanceof GenericEvent) { |
470 | 470 | $this->emit('\OC\Updater', 'repairWarning', $event->getArguments()); |
471 | 471 | } |
472 | 472 | }); |
473 | - $dispatcher->addListener('\OC\Repair::error', function ($event) { |
|
473 | + $dispatcher->addListener('\OC\Repair::error', function($event) { |
|
474 | 474 | if ($event instanceof GenericEvent) { |
475 | 475 | $this->emit('\OC\Updater', 'repairError', $event->getArguments()); |
476 | 476 | } |
477 | 477 | }); |
478 | - $dispatcher->addListener('\OC\Repair::info', function ($event) { |
|
478 | + $dispatcher->addListener('\OC\Repair::info', function($event) { |
|
479 | 479 | if ($event instanceof GenericEvent) { |
480 | 480 | $this->emit('\OC\Updater', 'repairInfo', $event->getArguments()); |
481 | 481 | } |
482 | 482 | }); |
483 | - $dispatcher->addListener('\OC\Repair::step', function ($event) { |
|
483 | + $dispatcher->addListener('\OC\Repair::step', function($event) { |
|
484 | 484 | if ($event instanceof GenericEvent) { |
485 | 485 | $this->emit('\OC\Updater', 'repairStep', $event->getArguments()); |
486 | 486 | } |
@@ -495,13 +495,13 @@ discard block |
||
495 | 495 | if (!$event instanceof GenericEvent) { |
496 | 496 | return; |
497 | 497 | } |
498 | - $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']); |
|
498 | + $log->info('\OC\DB\Migrator::executeSql: '.$event->getSubject().' ('.$event->getArgument(0).' of '.$event->getArgument(1).')', ['app' => 'updater']); |
|
499 | 499 | }); |
500 | 500 | $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($log) { |
501 | 501 | if (!$event instanceof GenericEvent) { |
502 | 502 | return; |
503 | 503 | } |
504 | - $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']); |
|
504 | + $log->info('\OC\DB\Migrator::checkTable: '.$event->getSubject().' ('.$event->getArgument(0).' of '.$event->getArgument(1).')', ['app' => 'updater']); |
|
505 | 505 | }); |
506 | 506 | |
507 | 507 | $repairListener = function($event) use ($log) { |
@@ -510,30 +510,30 @@ discard block |
||
510 | 510 | } |
511 | 511 | switch ($event->getSubject()) { |
512 | 512 | case '\OC\Repair::startProgress': |
513 | - $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']); |
|
513 | + $log->info('\OC\Repair::startProgress: Starting ... '.$event->getArgument(1).' ('.$event->getArgument(0).')', ['app' => 'updater']); |
|
514 | 514 | break; |
515 | 515 | case '\OC\Repair::advance': |
516 | 516 | $desc = $event->getArgument(1); |
517 | 517 | if (empty($desc)) { |
518 | 518 | $desc = ''; |
519 | 519 | } |
520 | - $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']); |
|
520 | + $log->info('\OC\Repair::advance: '.$desc.' ('.$event->getArgument(0).')', ['app' => 'updater']); |
|
521 | 521 | |
522 | 522 | break; |
523 | 523 | case '\OC\Repair::finishProgress': |
524 | 524 | $log->info('\OC\Repair::finishProgress', ['app' => 'updater']); |
525 | 525 | break; |
526 | 526 | case '\OC\Repair::step': |
527 | - $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']); |
|
527 | + $log->info('\OC\Repair::step: Repair step: '.$event->getArgument(0), ['app' => 'updater']); |
|
528 | 528 | break; |
529 | 529 | case '\OC\Repair::info': |
530 | - $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']); |
|
530 | + $log->info('\OC\Repair::info: Repair info: '.$event->getArgument(0), ['app' => 'updater']); |
|
531 | 531 | break; |
532 | 532 | case '\OC\Repair::warning': |
533 | - $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']); |
|
533 | + $log->warning('\OC\Repair::warning: Repair warning: '.$event->getArgument(0), ['app' => 'updater']); |
|
534 | 534 | break; |
535 | 535 | case '\OC\Repair::error': |
536 | - $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']); |
|
536 | + $log->error('\OC\Repair::error: Repair error: '.$event->getArgument(0), ['app' => 'updater']); |
|
537 | 537 | break; |
538 | 538 | } |
539 | 539 | }; |
@@ -547,74 +547,74 @@ discard block |
||
547 | 547 | $dispatcher->addListener('\OC\Repair::error', $repairListener); |
548 | 548 | |
549 | 549 | |
550 | - $this->listen('\OC\Updater', 'maintenanceEnabled', function () use($log) { |
|
550 | + $this->listen('\OC\Updater', 'maintenanceEnabled', function() use($log) { |
|
551 | 551 | $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']); |
552 | 552 | }); |
553 | - $this->listen('\OC\Updater', 'maintenanceDisabled', function () use($log) { |
|
553 | + $this->listen('\OC\Updater', 'maintenanceDisabled', function() use($log) { |
|
554 | 554 | $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']); |
555 | 555 | }); |
556 | - $this->listen('\OC\Updater', 'maintenanceActive', function () use($log) { |
|
556 | + $this->listen('\OC\Updater', 'maintenanceActive', function() use($log) { |
|
557 | 557 | $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']); |
558 | 558 | }); |
559 | - $this->listen('\OC\Updater', 'updateEnd', function ($success) use($log) { |
|
559 | + $this->listen('\OC\Updater', 'updateEnd', function($success) use($log) { |
|
560 | 560 | if ($success) { |
561 | 561 | $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']); |
562 | 562 | } else { |
563 | 563 | $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']); |
564 | 564 | } |
565 | 565 | }); |
566 | - $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use($log) { |
|
566 | + $this->listen('\OC\Updater', 'dbUpgradeBefore', function() use($log) { |
|
567 | 567 | $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']); |
568 | 568 | }); |
569 | - $this->listen('\OC\Updater', 'dbUpgrade', function () use($log) { |
|
569 | + $this->listen('\OC\Updater', 'dbUpgrade', function() use($log) { |
|
570 | 570 | $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']); |
571 | 571 | }); |
572 | - $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($log) { |
|
572 | + $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function() use($log) { |
|
573 | 573 | $log->info('\OC\Updater::dbSimulateUpgradeBefore: Checking whether the database schema can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
574 | 574 | }); |
575 | - $this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($log) { |
|
575 | + $this->listen('\OC\Updater', 'dbSimulateUpgrade', function() use($log) { |
|
576 | 576 | $log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']); |
577 | 577 | }); |
578 | - $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($log) { |
|
579 | - $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']); |
|
578 | + $this->listen('\OC\Updater', 'incompatibleAppDisabled', function($app) use($log) { |
|
579 | + $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: '.$app, ['app' => 'updater']); |
|
580 | 580 | }); |
581 | - $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($log) { |
|
582 | - $log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']); |
|
581 | + $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function($app) use($log) { |
|
582 | + $log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "'.$app.'" in appstore', ['app' => 'updater']); |
|
583 | 583 | }); |
584 | - $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($log) { |
|
585 | - $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']); |
|
584 | + $this->listen('\OC\Updater', 'upgradeAppStoreApp', function($app) use($log) { |
|
585 | + $log->info('\OC\Updater::upgradeAppStoreApp: Update app "'.$app.'" from appstore', ['app' => 'updater']); |
|
586 | 586 | }); |
587 | - $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($log) { |
|
588 | - $log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']); |
|
587 | + $this->listen('\OC\Updater', 'checkAppStoreApp', function($app) use($log) { |
|
588 | + $log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "'.$app.'" in appstore', ['app' => 'updater']); |
|
589 | 589 | }); |
590 | - $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) { |
|
590 | + $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function() use ($log) { |
|
591 | 591 | $log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']); |
592 | 592 | }); |
593 | - $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) { |
|
594 | - $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
|
593 | + $this->listen('\OC\Updater', 'appSimulateUpdate', function($app) use ($log) { |
|
594 | + $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <'.$app.'> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
|
595 | 595 | }); |
596 | - $this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) { |
|
596 | + $this->listen('\OC\Updater', 'appUpgradeCheck', function() use ($log) { |
|
597 | 597 | $log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']); |
598 | 598 | }); |
599 | - $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) { |
|
600 | - $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']); |
|
599 | + $this->listen('\OC\Updater', 'appUpgradeStarted', function($app) use ($log) { |
|
600 | + $log->info('\OC\Updater::appUpgradeStarted: Updating <'.$app.'> ...', ['app' => 'updater']); |
|
601 | 601 | }); |
602 | - $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) { |
|
603 | - $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']); |
|
602 | + $this->listen('\OC\Updater', 'appUpgrade', function($app, $version) use ($log) { |
|
603 | + $log->info('\OC\Updater::appUpgrade: Updated <'.$app.'> to '.$version, ['app' => 'updater']); |
|
604 | 604 | }); |
605 | - $this->listen('\OC\Updater', 'failure', function ($message) use($log) { |
|
606 | - $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']); |
|
605 | + $this->listen('\OC\Updater', 'failure', function($message) use($log) { |
|
606 | + $log->error('\OC\Updater::failure: '.$message, ['app' => 'updater']); |
|
607 | 607 | }); |
608 | - $this->listen('\OC\Updater', 'setDebugLogLevel', function () use($log) { |
|
608 | + $this->listen('\OC\Updater', 'setDebugLogLevel', function() use($log) { |
|
609 | 609 | $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']); |
610 | 610 | }); |
611 | - $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($log) { |
|
612 | - $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']); |
|
611 | + $this->listen('\OC\Updater', 'resetLogLevel', function($logLevel, $logLevelName) use($log) { |
|
612 | + $log->info('\OC\Updater::resetLogLevel: Reset log level to '.$logLevelName.'('.$logLevel.')', ['app' => 'updater']); |
|
613 | 613 | }); |
614 | - $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($log) { |
|
614 | + $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function() use($log) { |
|
615 | 615 | $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']); |
616 | 616 | }); |
617 | - $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($log) { |
|
617 | + $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function() use($log) { |
|
618 | 618 | $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']); |
619 | 619 | }); |
620 | 620 |