Skip to content

Commit

Permalink
Merge pull request #19355 from owncloud/cache_result_of_checkUpgrade
Browse files Browse the repository at this point in the history
[jenkins] Cache result of check upgrade
  • Loading branch information
DeepDiver1975 committed Sep 29, 2015
2 parents e45ce4a + fbe43e6 commit 90810cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public static function checkConfig() {
// Check if config is writable
$configFileWritable = is_writable($configFilePath);
if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled()
|| !$configFileWritable && \OCP\Util::needUpgrade()) {
|| !$configFileWritable && self::checkUpgrade(false)) {
if (self::$CLI) {
echo $l->t('Cannot write into "config" directory!')."\n";
echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n";
Expand Down Expand Up @@ -678,7 +678,7 @@ private static function registerLocalAddressBook() {
*/
public static function registerCacheHooks() {
//don't try to do this before we are properly setup
if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) {
if (\OC::$server->getSystemConfig()->getValue('installed', false) && !self::checkUpgrade(false)) {

// NOTE: This will be replaced to use OCP
$userSession = self::$server->getUserSession();
Expand Down Expand Up @@ -714,7 +714,7 @@ private static function registerEncryptionHooks() {
*/
public static function registerLogRotate() {
$systemConfig = \OC::$server->getSystemConfig();
if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !\OCP\Util::needUpgrade()) {
if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !self::checkUpgrade(false)) {
//don't try to do this before we are properly setup
//use custom logfile path if defined, otherwise use default of owncloud.log in data directory
\OCP\BackgroundJob::registerJob('OC\Log\Rotate', $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/owncloud.log'));
Expand Down Expand Up @@ -807,8 +807,7 @@ public static function handleRequest() {

// Load minimum set of apps
if (!self::checkUpgrade(false)
&& !$systemConfig->getValue('maintenance', false)
&& !\OCP\Util::needUpgrade()) {
&& !$systemConfig->getValue('maintenance', false)) {
// For logged-in users: Load everything
if(OC_User::isLoggedIn()) {
OC_App::loadApps();
Expand All @@ -821,7 +820,7 @@ public static function handleRequest() {

if (!self::$CLI and (!isset($_GET["logout"]) or ($_GET["logout"] !== 'true'))) {
try {
if (!$systemConfig->getValue('maintenance', false) && !\OCP\Util::needUpgrade()) {
if (!$systemConfig->getValue('maintenance', false) && !self::checkUpgrade(false)) {
OC_App::loadApps(array('filesystem', 'logging'));
OC_App::loadApps();
}
Expand Down
6 changes: 5 additions & 1 deletion lib/public/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ public static function isDefaultExpireDateEnforced() {
return \OC_Util::isDefaultExpireDateEnforced();
}

protected static $needUpgradeCache = null;

/**
* Checks whether the current version needs upgrade.
Expand All @@ -662,6 +663,9 @@ public static function isDefaultExpireDateEnforced() {
* @since 7.0.0
*/
public static function needUpgrade() {
return \OC_Util::needUpgrade(\OC::$server->getConfig());
if (!isset(self::$needUpgradeCache)) {
self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getConfig());
}
return self::$needUpgradeCache;
}
}
2 changes: 2 additions & 0 deletions tests/lib/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,13 @@ public function testNeedUpgradeCore() {

OC_Config::setValue('version', '7.0.0.0');
\OC::$server->getSession()->set('OC_Version', array(7, 0, 0, 1));
self::invokePrivate(new \OCP\Util, 'needUpgradeCache', array(null));

$this->assertTrue(\OCP\Util::needUpgrade());

OC_Config::setValue('version', $oldConfigVersion);
$oldSessionVersion = \OC::$server->getSession()->set('OC_Version', $oldSessionVersion);
self::invokePrivate(new \OCP\Util, 'needUpgradeCache', array(null));

$this->assertFalse(\OCP\Util::needUpgrade());
}
Expand Down

0 comments on commit 90810cc

Please sign in to comment.