Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(autoloader): no apcu no side effects #40349

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@

public static string $configDir;

public static int $VERSION_MTIME = 0;

/**
* requested app
*/
Expand Down Expand Up @@ -203,7 +201,7 @@
// slash which is required by URL generation.
if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] === \OC::$WEBROOT &&
substr($_SERVER['REQUEST_URI'], -1) !== '/') {
header('Location: '.\OC::$WEBROOT.'/');

Check failure on line 204 in lib/base.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHeader

lib/base.php:204:12: TaintedHeader: Detected tainted header (see https://psalm.dev/256)
exit();
}
}
Expand Down Expand Up @@ -285,7 +283,7 @@
throw new Exception('Not installed');
} else {
$url = OC::$WEBROOT . '/index.php';
header('Location: ' . $url);

Check failure on line 286 in lib/base.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHeader

lib/base.php:286:12: TaintedHeader: Detected tainted header (see https://psalm.dev/256)
}
exit();
}
Expand Down Expand Up @@ -610,10 +608,9 @@

self::$CLI = (php_sapi_name() == 'cli');

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

try {
self::initPaths();
Expand Down
3 changes: 2 additions & 1 deletion lib/private/legacy/OC_Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,10 @@ private static function loadVersion() {
return;
}

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