From 7c0c2e1d308a9d412998fd61e23b56ff44536850 Mon Sep 17 00:00:00 2001 From: memurats Date: Wed, 15 Jan 2025 10:55:58 +0100 Subject: [PATCH] log call stack in find methods --- lib/Db/UserMapper.php | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/lib/Db/UserMapper.php b/lib/Db/UserMapper.php index 0fa8dfa8..0b91419c 100644 --- a/lib/Db/UserMapper.php +++ b/lib/Db/UserMapper.php @@ -59,6 +59,29 @@ public function getUser(string $uid): User { public function find(string $search, $limit = null, $offset = null): array { $qb = $this->db->getQueryBuilder(); + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + $stack = []; + + foreach ($backtrace as $index => $trace) { + $class = $trace['class'] ?? ''; + $type = $trace['type'] ?? ''; + $function = $trace['function'] ?? ''; + $file = $trace['file'] ?? 'unknown file'; + $line = $trace['line'] ?? 'unknown line'; + + $stack[] = sprintf( + "#%d %s%s%s() called at [%s:%s]", + $index, + $class, + $type, + $function, + $file, + $line + ); + } + + $this->logger->debug("Find user by string: " . $search . " -- Call Stack:\n" . implode("\n", $stack)); + $oidcSystemConfig = $this->config->getSystemValue('user_oidc', []); $matchEmails = !isset($oidcSystemConfig['user_search_match_emails']) || $oidcSystemConfig['user_search_match_emails'] === true; if ($matchEmails) { @@ -91,6 +114,29 @@ public function find(string $search, $limit = null, $offset = null): array { public function findDisplayNames(string $search, $limit = null, $offset = null): array { $qb = $this->db->getQueryBuilder(); + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + $stack = []; + + foreach ($backtrace as $index => $trace) { + $class = $trace['class'] ?? ''; + $type = $trace['type'] ?? ''; + $function = $trace['function'] ?? ''; + $file = $trace['file'] ?? 'unknown file'; + $line = $trace['line'] ?? 'unknown line'; + + $stack[] = sprintf( + "#%d %s%s%s() called at [%s:%s]", + $index, + $class, + $type, + $function, + $file, + $line + ); + } + + $this->logger->debug("Find user display names by string: " . $search . " -- Call Stack:\n" . implode("\n", $stack)); + $oidcSystemConfig = $this->config->getSystemValue('user_oidc', []); $matchEmails = !isset($oidcSystemConfig['user_search_match_emails']) || $oidcSystemConfig['user_search_match_emails'] === true; if ($matchEmails) {