Skip to content

Commit

Permalink
Merge #20 log call stack in find methods
Browse files Browse the repository at this point in the history
  • Loading branch information
memurats committed Feb 4, 2025
2 parents 04ef4d8 + 7c0c2e1 commit 5ff9725
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions lib/Db/UserMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 5ff9725

Please sign in to comment.