Skip to content

Commit 02aeed1

Browse files
committed
Merge #20 log call stack in find methods
2 parents fffd062 + 7c0c2e1 commit 02aeed1

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

lib/Db/UserMapper.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,29 @@ public function getUser(string $uid): User {
5959
public function find(string $search, $limit = null, $offset = null): array {
6060
$qb = $this->db->getQueryBuilder();
6161

62+
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
63+
$stack = [];
64+
65+
foreach ($backtrace as $index => $trace) {
66+
$class = $trace['class'] ?? '';
67+
$type = $trace['type'] ?? '';
68+
$function = $trace['function'] ?? '';
69+
$file = $trace['file'] ?? 'unknown file';
70+
$line = $trace['line'] ?? 'unknown line';
71+
72+
$stack[] = sprintf(
73+
"#%d %s%s%s() called at [%s:%s]",
74+
$index,
75+
$class,
76+
$type,
77+
$function,
78+
$file,
79+
$line
80+
);
81+
}
82+
83+
$this->logger->debug("Find user by string: " . $search . " -- Call Stack:\n" . implode("\n", $stack));
84+
6285
$oidcSystemConfig = $this->config->getSystemValue('user_oidc', []);
6386
$matchEmails = !isset($oidcSystemConfig['user_search_match_emails']) || $oidcSystemConfig['user_search_match_emails'] === true;
6487
if ($matchEmails) {
@@ -91,6 +114,29 @@ public function find(string $search, $limit = null, $offset = null): array {
91114
public function findDisplayNames(string $search, $limit = null, $offset = null): array {
92115
$qb = $this->db->getQueryBuilder();
93116

117+
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
118+
$stack = [];
119+
120+
foreach ($backtrace as $index => $trace) {
121+
$class = $trace['class'] ?? '';
122+
$type = $trace['type'] ?? '';
123+
$function = $trace['function'] ?? '';
124+
$file = $trace['file'] ?? 'unknown file';
125+
$line = $trace['line'] ?? 'unknown line';
126+
127+
$stack[] = sprintf(
128+
"#%d %s%s%s() called at [%s:%s]",
129+
$index,
130+
$class,
131+
$type,
132+
$function,
133+
$file,
134+
$line
135+
);
136+
}
137+
138+
$this->logger->debug("Find user display names by string: " . $search . " -- Call Stack:\n" . implode("\n", $stack));
139+
94140
$oidcSystemConfig = $this->config->getSystemValue('user_oidc', []);
95141
$matchEmails = !isset($oidcSystemConfig['user_search_match_emails']) || $oidcSystemConfig['user_search_match_emails'] === true;
96142
if ($matchEmails) {

0 commit comments

Comments
 (0)