Skip to content

Commit

Permalink
Don't store version number in the session - refs #26663
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Feb 16, 2017
1 parent 840f05c commit 78e1a6b
Showing 1 changed file with 22 additions and 32 deletions.
54 changes: 22 additions & 32 deletions lib/private/legacy/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class OC_Util {
public static $headers = [];
private static $rootMounted = false;
private static $fsSetup = false;
private static $version;

protected static function getAppManager() {
return \OC::$server->getAppManager();
Expand Down Expand Up @@ -372,7 +373,7 @@ public static function tearDownFS() {
*/
public static function getVersion() {
OC_Util::loadVersion();
return \OC::$server->getSession()->get('OC_Version');
return self::$version['OC_Version'];
}

/**
Expand All @@ -382,7 +383,7 @@ public static function getVersion() {
*/
public static function getVersionString() {
OC_Util::loadVersion();
return \OC::$server->getSession()->get('OC_VersionString');
return self::$version['OC_VersionString'];
}

/**
Expand All @@ -406,7 +407,7 @@ public static function getEditionString() {
*/
public static function getChannel() {
OC_Util::loadVersion();
return \OC::$server->getSession()->get('OC_Channel');
return self::$version['OC_Channel'];
}

/**
Expand All @@ -415,41 +416,30 @@ public static function getChannel() {
*/
public static function getBuild() {
OC_Util::loadVersion();
return \OC::$server->getSession()->get('OC_Build');
return self::$version['OC_Build'];
}

/**
* @description load the version.php into the session as cache
*/
private static function loadVersion() {
$timestamp = filemtime(OC::$SERVERROOT . '/version.php');
if (!\OC::$server->getSession()->exists('OC_Version') or OC::$server->getSession()->get('OC_Version_Timestamp') != $timestamp) {
require OC::$SERVERROOT . '/version.php';
$session = \OC::$server->getSession();
/** @var $timestamp int */
$session->set('OC_Version_Timestamp', $timestamp);
/** @var $OC_Version string */
$session->set('OC_Version', $OC_Version);
/** @var $OC_VersionString string */
$session->set('OC_VersionString', $OC_VersionString);
/** @var $OC_Build string */
$session->set('OC_Build', $OC_Build);

// Allow overriding update channel

if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
$channel = \OC::$server->getAppConfig()->getValue('core', 'OC_Channel');
} else {
/** @var $OC_Channel string */
$channel = $OC_Channel;
}

if (!is_null($channel)) {
$session->set('OC_Channel', $channel);
} else {
/** @var $OC_Channel string */
$session->set('OC_Channel', $OC_Channel);
}
require __DIR__ . '/../../../version.php';
/** @var $OC_Version string */
/** @var $OC_VersionString string */
/** @var $OC_Build string */
/** @var $OC_Channel string */
self::$version = [
'OC_Version' => $OC_Version,
'OC_VersionString' => $OC_VersionString,
'OC_Build' => $OC_Build,
'OC_Channel' => $OC_Channel,
];

// Allow overriding update channel

if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
$channel = \OC::$server->getConfig()->getAppValue('core', 'OC_Channel', $OC_Channel);
self::$version['OC_Channel'] = $channel;
}
}

Expand Down

0 comments on commit 78e1a6b

Please sign in to comment.