Skip to content

Commit e468036

Browse files
authored
Merge pull request #1214 from nextcloud/backport/1205/stable4.7
[stable4.7] perf: Avoid calliget Server::get in StorageWrapper callback
2 parents f6c61dd + ff35a4b commit e468036

1 file changed

Lines changed: 25 additions & 29 deletions

File tree

lib/AppInfo/Application.php

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace OCA\TermsOfService\AppInfo;
99

10-
use Exception;
1110
use OC\Files\Filesystem;
1211
use OCA\DAV\Events\SabrePluginAddEvent;
1312
use OCA\Registration\Events\PassedFormEvent;
@@ -120,38 +119,35 @@ public function registerFrontend(IRequest $request, IAppConfig $appConfig, IUser
120119
}
121120

122121
public function addStorageWrapper(): void {
122+
$request = \OCP\Server::get(IRequest::class);
123+
$checker = \OCP\Server::get(Checker::class);
124+
123125
Filesystem::addStorageWrapper(
124-
'terms_of_service', $this->addStorageWrapperCallback(...), -10
126+
'terms_of_service', function (string $mountPoint, IStorage $storage) use ($request, $checker): IStorage {
127+
/** @psalm-suppress UndefinedClass */
128+
if (!\OC::$CLI) {
129+
try {
130+
return new StorageWrapper(
131+
[
132+
'storage' => $storage,
133+
'mountPoint' => $mountPoint,
134+
'request' => $request,
135+
'checker' => $checker,
136+
]
137+
);
138+
} catch (ContainerExceptionInterface $e) {
139+
\OCP\Server::get(LoggerInterface::class)->error(
140+
$e->getMessage(),
141+
['exception' => $e]
142+
);
143+
}
144+
}
145+
146+
return $storage;
147+
}, -10
125148
);
126149
}
127150

128-
/**
129-
* @return StorageWrapper|IStorage
130-
* @throws Exception
131-
*/
132-
public function addStorageWrapperCallback(string $mountPoint, IStorage $storage): IStorage {
133-
/** @psalm-suppress UndefinedClass */
134-
if (!\OC::$CLI) {
135-
try {
136-
return new StorageWrapper(
137-
[
138-
'storage' => $storage,
139-
'mountPoint' => $mountPoint,
140-
'request' => \OCP\Server::get(IRequest::class),
141-
'checker' => \OCP\Server::get(Checker::class),
142-
]
143-
);
144-
} catch (ContainerExceptionInterface $e) {
145-
\OCP\Server::get(LoggerInterface::class)->error(
146-
$e->getMessage(),
147-
['exception' => $e]
148-
);
149-
}
150-
}
151-
152-
return $storage;
153-
}
154-
155151
public function registerNotifier(IManager $notificationManager): void {
156152
$notificationManager->registerNotifierService(Notifier::class);
157153
}

0 commit comments

Comments
 (0)