perf(dav): Avoid getting DB Connection inside callback

Fetch it once outside instead and pass it to the callback.

Signed-off-by: Carl Schwan <carlschwan@kde.org>
This commit is contained in:
Carl Schwan 2026-01-13 11:47:11 +01:00 committed by Andy Scherzinger
parent c1e362b167
commit f9fa9fb625

View file

@ -150,12 +150,13 @@ class Server extends \Sabre\DAV\Server {
string $pluginName,
string $eventName,
): callable {
$connection = \OCP\Server::get(Connection::class);
return function (PropFind $propFind, INode $node) use (
$callBack,
$pluginName,
$eventName,
$connection,
): bool {
$connection = \OCP\Server::get(Connection::class);
$queriesBefore = $connection->getStats()['executed'];
$result = $callBack($propFind, $node);
$queriesAfter = $connection->getStats()['executed'];