Skip to content

Commit

Permalink
Read mtime of version.php only once
Browse files Browse the repository at this point in the history
- in most cases it would read again in \OC_Util::loadVersion anyway
- remove some unused use statements

Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz authored and backportbot-nextcloud[bot] committed Apr 21, 2023
1 parent 3ac8682 commit 429ed88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@

use OC\Encryption\HookManager;
use OC\EventDispatcher\SymfonyAdapter;
use OC\Files\Filesystem;
use OC\Share20\Hooks;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Group\Events\UserRemovedEvent;
Expand Down Expand Up @@ -115,6 +114,8 @@ class OC {

public static string $configDir;

public static int $VERSION_MTIME = 0;

/**
* requested app
*/
Expand Down Expand Up @@ -598,7 +599,8 @@ public static function init(): void {

// Add default composer PSR-4 autoloader
self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php';
self::$composerAutoloader->setApcuPrefix('composer_autoload_' . md5(OC::$SERVERROOT . '_' . filemtime(OC::$SERVERROOT . '/version.php')));
OC::$VERSION_MTIME = filemtime(OC::$SERVERROOT . '/version.php');
self::$composerAutoloader->setApcuPrefix('composer_autoload_' . md5(OC::$SERVERROOT . '_' . OC::$VERSION_MTIME));

try {
self::initPaths();
Expand Down
4 changes: 1 addition & 3 deletions lib/private/legacy/OC_Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
*/

use bantu\IniGetWrapper\IniGetWrapper;
use OC\AppFramework\Http\Request;
use OC\Files\SetupManager;
use OCP\Files\Template\ITemplateManager;
use OCP\IConfig;
Expand Down Expand Up @@ -327,10 +326,9 @@ private static function loadVersion() {
return;
}

$timestamp = filemtime(OC::$SERVERROOT . '/version.php');
require OC::$SERVERROOT . '/version.php';
/** @var int $timestamp */
self::$versionCache['OC_Version_Timestamp'] = $timestamp;
self::$versionCache['OC_Version_Timestamp'] = \OC::$VERSION_MTIME;
/** @var string $OC_Version */
self::$versionCache['OC_Version'] = $OC_Version;
/** @var string $OC_VersionString */
Expand Down

0 comments on commit 429ed88

Please sign in to comment.