Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions lib/OC.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ class OC {
* @psalm-suppress ImpureStaticProperty
*/
public static string $SERVERROOT = '';
/**
* the current request path relative to the Nextcloud root (e.g. files/index.php)
* @psalm-suppress ImpureStaticProperty
*/
private static string $SUBURI = '';
/**
* the Nextcloud root path for http requests (e.g. /nextcloud)
* @psalm-suppress ImpureStaticProperty
Expand All @@ -74,6 +69,11 @@ class OC {
*/
public static string $configDir;

/**
* the current request path relative to the Nextcloud root (e.g. files/index.php)
* @psalm-suppress ImpureStaticProperty
*/
private static string $SUBURI = '';
/**
* requested app
* @psalm-suppress ImpureStaticProperty
Expand Down Expand Up @@ -107,12 +107,12 @@ class OC {
* @psalm-suppress ImpureStaticProperty
*/
private static bool $oneTimeChecksDone = false;

/**
* @throws \RuntimeException when the 3rdparty directory is missing or
* the app path list is empty or contains an invalid path
* @psalm-suppress ImpureStaticProperty
*/
public static function initPaths(): void {
private static bool $firstRequest = true;

private static function initSubUri(): string {
OC::$SUBURI = str_replace('\\', '/', substr(realpath($_SERVER['SCRIPT_FILENAME'] ?? ''), strlen(OC::$SERVERROOT)));
/**
* FIXME: The following lines are required because we can't yet instantiate
Expand Down Expand Up @@ -143,6 +143,15 @@ public static function initPaths(): void {
OC::$SUBURI = OC::$SUBURI . 'index.php';
}
}
return $scriptName;
}

/**
* @throws \RuntimeException when the 3rdparty directory is missing or
* the app path list is empty or contains an invalid path
*/
public static function initPaths(): void {
$scriptName = self::initSubUri();

if (OC::$CLI) {
OC::$WEBROOT = self::$config->getValue('overwritewebroot', '');
Expand Down Expand Up @@ -763,7 +772,12 @@ private static function oneTimeChecks(): void {
* Called before each request served if the same worker serves several request
*/
public static function initForRequest(): void {
self::resetStaticProperties();
if (self::$firstRequest) {
self::$firstRequest = false;
} else {
self::resetStaticProperties();
self::initSubUri();
}

// First handle PHP configuration and copy auth headers to the expected
// $_SERVER variable before doing anything Server object related
Expand Down Expand Up @@ -1359,6 +1373,8 @@ protected static function tryAppAPILogin(OCP\IRequest $request): bool {
*/
private static function resetStaticProperties(): void {
// FIXME needed because these use a static var
self::$SUBURI = '';
self::$REQUESTEDAPP = '';
\OC_Hook::clear();
\OC_Util::$styles = [];
\OC_Util::$headers = [];
Expand Down
Loading