Merge pull request #6392 from owncloud/no-backgroundjobs-during-upgrade
dont try to register background jobs if we haven't upgraded yet
This commit is contained in:
commit
a84fe4790f
89
lib/base.php
89
lib/base.php
|
@ -131,8 +131,8 @@ class OC {
|
||||||
OC::$THIRDPARTYROOT = rtrim(dirname(OC::$SERVERROOT), '/');
|
OC::$THIRDPARTYROOT = rtrim(dirname(OC::$SERVERROOT), '/');
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('3rdparty directory not found! Please put the ownCloud 3rdparty'
|
throw new Exception('3rdparty directory not found! Please put the ownCloud 3rdparty'
|
||||||
.' folder in the ownCloud folder or the folder above.'
|
. ' folder in the ownCloud folder or the folder above.'
|
||||||
.' You can also configure the location in the config.php file.');
|
. ' You can also configure the location in the config.php file.');
|
||||||
}
|
}
|
||||||
// search the apps folder
|
// search the apps folder
|
||||||
$config_paths = OC_Config::getValue('apps_paths', array());
|
$config_paths = OC_Config::getValue('apps_paths', array());
|
||||||
|
@ -156,7 +156,7 @@ class OC {
|
||||||
|
|
||||||
if (empty(OC::$APPSROOTS)) {
|
if (empty(OC::$APPSROOTS)) {
|
||||||
throw new Exception('apps directory not found! Please put the ownCloud apps folder in the ownCloud folder'
|
throw new Exception('apps directory not found! Please put the ownCloud apps folder in the ownCloud folder'
|
||||||
.' or the folder above. You can also configure the location in the config.php file.');
|
. ' or the folder above. You can also configure the location in the config.php file.');
|
||||||
}
|
}
|
||||||
$paths = array();
|
$paths = array();
|
||||||
foreach (OC::$APPSROOTS as $path) {
|
foreach (OC::$APPSROOTS as $path) {
|
||||||
|
@ -176,7 +176,8 @@ class OC {
|
||||||
|
|
||||||
public static function checkConfig() {
|
public static function checkConfig() {
|
||||||
if (file_exists(OC::$SERVERROOT . "/config/config.php")
|
if (file_exists(OC::$SERVERROOT . "/config/config.php")
|
||||||
and !is_writable(OC::$SERVERROOT . "/config/config.php")) {
|
and !is_writable(OC::$SERVERROOT . "/config/config.php")
|
||||||
|
) {
|
||||||
$defaults = new OC_Defaults();
|
$defaults = new OC_Defaults();
|
||||||
if (self::$CLI) {
|
if (self::$CLI) {
|
||||||
echo "Can't write into config directory!\n";
|
echo "Can't write into config directory!\n";
|
||||||
|
@ -188,7 +189,7 @@ class OC {
|
||||||
OC_Template::printErrorPage(
|
OC_Template::printErrorPage(
|
||||||
"Can't write into config directory!",
|
"Can't write into config directory!",
|
||||||
'This can usually be fixed by '
|
'This can usually be fixed by '
|
||||||
.'<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">giving the webserver write access to the config directory</a>.'
|
. '<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">giving the webserver write access to the config directory</a>.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,31 +255,42 @@ class OC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checkUpgrade($showTemplate = true) {
|
/**
|
||||||
|
* check if the instance needs to preform an upgrade
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function needUpgrade() {
|
||||||
if (OC_Config::getValue('installed', false)) {
|
if (OC_Config::getValue('installed', false)) {
|
||||||
$installedVersion = OC_Config::getValue('version', '0.0.0');
|
$installedVersion = OC_Config::getValue('version', '0.0.0');
|
||||||
$currentVersion = implode('.', OC_Util::getVersion());
|
$currentVersion = implode('.', OC_Util::getVersion());
|
||||||
if (version_compare($currentVersion, $installedVersion, '>')) {
|
return version_compare($currentVersion, $installedVersion, '>');
|
||||||
if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
|
} else {
|
||||||
OC_Config::setValue('theme', '');
|
|
||||||
$minimizerCSS = new OC_Minimizer_CSS();
|
|
||||||
$minimizerCSS->clearCache();
|
|
||||||
$minimizerJS = new OC_Minimizer_JS();
|
|
||||||
$minimizerJS->clearCache();
|
|
||||||
OC_Util::addScript('config'); // needed for web root
|
|
||||||
OC_Util::addScript('update');
|
|
||||||
$tmpl = new OC_Template('', 'update.admin', 'guest');
|
|
||||||
$tmpl->assign('version', OC_Util::getVersionString());
|
|
||||||
$tmpl->printPage();
|
|
||||||
exit();
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function checkUpgrade($showTemplate = true) {
|
||||||
|
if (self::needUpgrade()) {
|
||||||
|
if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
|
||||||
|
OC_Config::setValue('theme', '');
|
||||||
|
$minimizerCSS = new OC_Minimizer_CSS();
|
||||||
|
$minimizerCSS->clearCache();
|
||||||
|
$minimizerJS = new OC_Minimizer_JS();
|
||||||
|
$minimizerJS->clearCache();
|
||||||
|
OC_Util::addScript('config'); // needed for web root
|
||||||
|
OC_Util::addScript('update');
|
||||||
|
$tmpl = new OC_Template('', 'update.admin', 'guest');
|
||||||
|
$tmpl->assign('version', OC_Util::getVersionString());
|
||||||
|
$tmpl->printPage();
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static function initTemplateEngine() {
|
public static function initTemplateEngine() {
|
||||||
// Add the stuff we need always
|
// Add the stuff we need always
|
||||||
OC_Util::addScript("jquery-1.10.0.min");
|
OC_Util::addScript("jquery-1.10.0.min");
|
||||||
|
@ -462,7 +474,7 @@ class OC {
|
||||||
// OC_Util::getInstanceId() for namespacing. See #5409.
|
// OC_Util::getInstanceId() for namespacing. See #5409.
|
||||||
try {
|
try {
|
||||||
self::$loader->setMemoryCache(\OC\Memcache\Factory::createLowLatency('Autoloader'));
|
self::$loader->setMemoryCache(\OC\Memcache\Factory::createLowLatency('Autoloader'));
|
||||||
} catch(\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OC_Util::isSetLocaleWorking();
|
OC_Util::isSetLocaleWorking();
|
||||||
|
@ -507,7 +519,7 @@ class OC {
|
||||||
if (count($errors) > 0) {
|
if (count($errors) > 0) {
|
||||||
if (self::$CLI) {
|
if (self::$CLI) {
|
||||||
foreach ($errors as $error) {
|
foreach ($errors as $error) {
|
||||||
echo $error['error']."\n";
|
echo $error['error'] . "\n";
|
||||||
echo $error['hint'] . "\n\n";
|
echo $error['hint'] . "\n\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -602,13 +614,9 @@ class OC {
|
||||||
* register hooks for the cache
|
* register hooks for the cache
|
||||||
*/
|
*/
|
||||||
public static function registerCacheHooks() {
|
public static function registerCacheHooks() {
|
||||||
if (OC_Config::getValue('installed', false)) { //don't try to do this before we are properly setup
|
if (OC_Config::getValue('installed', false) && !self::needUpgrade()) { //don't try to do this before we are properly setup
|
||||||
// register cache cleanup jobs
|
\OCP\BackgroundJob::registerJob('OC\Cache\FileGlobalGC');
|
||||||
try { //if this is executed before the upgrade to the new backgroundjob system is completed it will throw an exception
|
|
||||||
\OCP\BackgroundJob::registerJob('OC\Cache\FileGlobalGC');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
// NOTE: This will be replaced to use OCP
|
// NOTE: This will be replaced to use OCP
|
||||||
$userSession = \OC_User::getUserSession();
|
$userSession = \OC_User::getUserSession();
|
||||||
$userSession->listen('postLogin', '\OC\Cache\File', 'loginListener');
|
$userSession->listen('postLogin', '\OC\Cache\File', 'loginListener');
|
||||||
|
@ -619,14 +627,9 @@ class OC {
|
||||||
* register hooks for the cache
|
* register hooks for the cache
|
||||||
*/
|
*/
|
||||||
public static function registerLogRotate() {
|
public static function registerLogRotate() {
|
||||||
if (OC_Config::getValue('installed', false) && OC_Config::getValue('log_rotate_size', false)) {
|
if (OC_Config::getValue('installed', false) && OC_Config::getValue('log_rotate_size', false) && !self::needUpgrade()) {
|
||||||
//don't try to do this before we are properly setup
|
//don't try to do this before we are properly setup
|
||||||
// register cache cleanup jobs
|
\OCP\BackgroundJob::registerJob('OC\Log\Rotate', OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data') . '/owncloud.log');
|
||||||
try { //if this is executed before the upgrade to the new backgroundjob system is completed it will throw an exception
|
|
||||||
\OCP\BackgroundJob::registerJob('OC\Log\Rotate', OC_Config::getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +656,7 @@ class OC {
|
||||||
* register hooks for sharing
|
* register hooks for sharing
|
||||||
*/
|
*/
|
||||||
public static function registerShareHooks() {
|
public static function registerShareHooks() {
|
||||||
if(\OC_Config::getValue('installed')) {
|
if (\OC_Config::getValue('installed')) {
|
||||||
OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\Share', 'post_deleteUser');
|
OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\Share', 'post_deleteUser');
|
||||||
OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\Share', 'post_addToGroup');
|
OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\Share', 'post_addToGroup');
|
||||||
OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\Share', 'post_removeFromGroup');
|
OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\Share', 'post_removeFromGroup');
|
||||||
|
@ -676,7 +679,7 @@ class OC {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = OC_Request::getPathInfo();
|
$request = OC_Request::getPathInfo();
|
||||||
if(substr($request, -3) !== '.js') {// we need these files during the upgrade
|
if (substr($request, -3) !== '.js') { // we need these files during the upgrade
|
||||||
self::checkMaintenanceMode();
|
self::checkMaintenanceMode();
|
||||||
self::checkUpgrade();
|
self::checkUpgrade();
|
||||||
}
|
}
|
||||||
|
@ -794,12 +797,10 @@ class OC {
|
||||||
// auth possible via apache module?
|
// auth possible via apache module?
|
||||||
if (OC::tryApacheAuth()) {
|
if (OC::tryApacheAuth()) {
|
||||||
$error[] = 'apacheauthfailed';
|
$error[] = 'apacheauthfailed';
|
||||||
}
|
} // remember was checked after last login
|
||||||
// remember was checked after last login
|
|
||||||
elseif (OC::tryRememberLogin()) {
|
elseif (OC::tryRememberLogin()) {
|
||||||
$error[] = 'invalidcookie';
|
$error[] = 'invalidcookie';
|
||||||
}
|
} // logon via web form
|
||||||
// logon via web form
|
|
||||||
elseif (OC::tryFormLogin()) {
|
elseif (OC::tryFormLogin()) {
|
||||||
$error[] = 'invalidpassword';
|
$error[] = 'invalidpassword';
|
||||||
if ( OC_Config::getValue('log_authfailip', false) ) {
|
if ( OC_Config::getValue('log_authfailip', false) ) {
|
||||||
|
|
|
@ -45,6 +45,7 @@ use \OC\BackgroundJob\JobList;
|
||||||
class BackgroundJob {
|
class BackgroundJob {
|
||||||
/**
|
/**
|
||||||
* get the execution type of background jobs
|
* get the execution type of background jobs
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* This method returns the type how background jobs are executed. If the user
|
* This method returns the type how background jobs are executed. If the user
|
||||||
|
@ -56,6 +57,7 @@ class BackgroundJob {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets the background jobs execution type
|
* sets the background jobs execution type
|
||||||
|
*
|
||||||
* @param string $type execution type
|
* @param string $type execution type
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*
|
*
|
||||||
|
@ -83,8 +85,10 @@ class BackgroundJob {
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
public static function addRegularTask($klass, $method) {
|
public static function addRegularTask($klass, $method) {
|
||||||
self::registerJob('OC\BackgroundJob\Legacy\RegularJob', array($klass, $method));
|
if (!\OC::needUpgrade()) {
|
||||||
return true;
|
self::registerJob('OC\BackgroundJob\Legacy\RegularJob', array($klass, $method));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue