Do not abort with an exception when a default app can not be enabled
This commit is contained in:
parent
86581f6626
commit
444343dc2b
|
@ -526,8 +526,12 @@ class OC_Installer{
|
||||||
* Installs shipped apps
|
* Installs shipped apps
|
||||||
*
|
*
|
||||||
* This function installs all apps found in the 'apps' directory that should be enabled by default;
|
* This function installs all apps found in the 'apps' directory that should be enabled by default;
|
||||||
|
* @param bool $softErrors When updating we ignore errors and simply log them, better to have a
|
||||||
|
* working ownCloud at the end instead of an aborted update.
|
||||||
|
* @return array Array of error messages (appid => Exception)
|
||||||
*/
|
*/
|
||||||
public static function installShippedApps() {
|
public static function installShippedApps($softErrors = false) {
|
||||||
|
$errors = [];
|
||||||
foreach(OC::$APPSROOTS as $app_dir) {
|
foreach(OC::$APPSROOTS as $app_dir) {
|
||||||
if($dir = opendir( $app_dir['path'] )) {
|
if($dir = opendir( $app_dir['path'] )) {
|
||||||
while( false !== ( $filename = readdir( $dir ))) {
|
while( false !== ( $filename = readdir( $dir ))) {
|
||||||
|
@ -538,7 +542,16 @@ class OC_Installer{
|
||||||
$enabled = isset($info['default_enable']);
|
$enabled = isset($info['default_enable']);
|
||||||
if (($enabled || in_array($filename, \OC::$server->getAppManager()->getAlwaysEnabledApps()))
|
if (($enabled || in_array($filename, \OC::$server->getAppManager()->getAlwaysEnabledApps()))
|
||||||
&& \OC::$server->getConfig()->getAppValue($filename, 'enabled') !== 'no') {
|
&& \OC::$server->getConfig()->getAppValue($filename, 'enabled') !== 'no') {
|
||||||
OC_Installer::installShippedApp($filename);
|
if ($softErrors) {
|
||||||
|
try {
|
||||||
|
OC_Installer::installShippedApp($filename);
|
||||||
|
} catch (\Doctrine\DBAL\Exception\TableExistsException $e) {
|
||||||
|
$errors[$filename] = $e;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
OC_Installer::installShippedApp($filename);
|
||||||
|
}
|
||||||
\OC::$server->getConfig()->setAppValue($filename, 'enabled', 'yes');
|
\OC::$server->getConfig()->setAppValue($filename, 'enabled', 'yes');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,6 +561,8 @@ class OC_Installer{
|
||||||
closedir( $dir );
|
closedir( $dir );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -333,7 +333,12 @@ class Updater extends BasicEmitter {
|
||||||
|
|
||||||
// install new shipped apps on upgrade
|
// install new shipped apps on upgrade
|
||||||
OC_App::loadApps('authentication');
|
OC_App::loadApps('authentication');
|
||||||
OC_Installer::installShippedApps();
|
$errors = OC_Installer::installShippedApps(true);
|
||||||
|
foreach ($errors as $appId => $exception) {
|
||||||
|
/** @var \Exception $exception */
|
||||||
|
$this->log->logException($exception, ['app' => $appId]);
|
||||||
|
$this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
|
||||||
|
}
|
||||||
|
|
||||||
// post-upgrade repairs
|
// post-upgrade repairs
|
||||||
$repair = new Repair(Repair::getRepairSteps());
|
$repair = new Repair(Repair::getRepairSteps());
|
||||||
|
|
Loading…
Reference in New Issue