Skip to content

Commit cb69fe4

Browse files
committed
chore: Use a better naming for init function
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent d5c7e5e commit cb69fe4

5 files changed

Lines changed: 14 additions & 9 deletions

File tree

index.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525

2626
\OC::handleRequests(static function () {
2727
try {
28-
\OC::resetStaticProperties();
29-
\OC::init();
28+
\OC::initForRequest();
3029
\OC::handleRequest();
3130
} catch (ServiceUnavailableException $ex) {
3231
Server::get(LoggerInterface::class)->error($ex->getMessage(), [

lib/OC.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,9 @@ private static function addSecurityHeaders(): void {
666666
}
667667
}
668668

669+
/*
670+
* Called only once at the beginning to setup things
671+
*/
669672
public static function boot(): void {
670673
// prevent any XML processing from loading external entities
671674
libxml_set_external_entity_loader(static function () {
@@ -726,7 +729,12 @@ public static function boot(): void {
726729
}
727730
}
728731

729-
public static function init(): void {
732+
/*
733+
* Called before each request served if the same worker serves several request
734+
*/
735+
public static function initForRequest(): void {
736+
self::resetStaticProperties();
737+
730738
// First handle PHP configuration and copy auth headers to the expected
731739
// $_SERVER variable before doing anything Server object related
732740
self::setRequiredIniValues();
@@ -1329,7 +1337,7 @@ protected static function tryAppAPILogin(OCP\IRequest $request): bool {
13291337
/**
13301338
* @internal
13311339
*/
1332-
public static function resetStaticProperties(): void {
1340+
private static function resetStaticProperties(): void {
13331341
// FIXME needed because these use a static var
13341342
\OC_Hook::clear();
13351343
\OC_Util::$styles = [];

lib/base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
require_once __DIR__ . '/OC.php';
1010

1111
\OC::boot();
12-
\OC::init();
12+
\OC::initForRequest();

ocs/v1.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
\OC::boot();
3232

3333
\OC::handleRequests(static function () {
34-
\OC::resetStaticProperties();
35-
\OC::init();
34+
\OC::initForRequest();
3635
$request = Server::get(IRequest::class);
3736

3837
if ((Util::needUpgrade() || Server::get(IConfig::class)->getSystemValueBool('maintenance')) && $request->getPathInfo() !== '/core/update') {

remote.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ function resolveService($service) {
103103

104104
\OC::handleRequests(static function () {
105105
try {
106-
\OC::resetStaticProperties();
107-
\OC::init();
106+
\OC::initForRequest();
108107

109108
// All resources served via the DAV endpoint should have the strictest possible
110109
// policy. Exempted from this is the SabreDAV browser plugin which overwrites

0 commit comments

Comments
 (0)