diff options
author | 2022-08-06 22:46:28 +0200 | |
---|---|---|
committer | 2022-08-06 22:46:28 +0200 | |
commit | 2bbce8ebef8cf4f88392431aabe84a15482dc933 (patch) | |
tree | 1f5027ca69b1dfa2364bd9319e8536b86a41e928 /lib/error.php | |
parent | b042412416cc4ecc71c3f9c13239661a0dd588a6 (diff) | |
download | rss-bridge-2bbce8ebef8cf4f88392431aabe84a15482dc933.tar.gz rss-bridge-2bbce8ebef8cf4f88392431aabe84a15482dc933.tar.zst rss-bridge-2bbce8ebef8cf4f88392431aabe84a15482dc933.zip |
refactor: general code base refactor (#2950)
* refactor
* fix: bug in previous refactor
* chore: exclude phpcompat sniff due to bug in phpcompat
* fix: do not leak absolute paths
* refactor/fix: batch extensions checking, fix DOS issue
Diffstat (limited to 'lib/error.php')
-rw-r--r-- | lib/error.php | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/lib/error.php b/lib/error.php index 1a3d294d..f6322567 100644 --- a/lib/error.php +++ b/lib/error.php @@ -64,7 +64,7 @@ function logBridgeError($bridgeName, $code) $cache->purgeCache(86400); // 24 hours if ($report = $cache->loadData()) { - $report = json_decode($report, true); + $report = Json::decode($report); $report['time'] = time(); $report['count']++; } else { @@ -75,38 +75,7 @@ function logBridgeError($bridgeName, $code) ]; } - $cache->saveData(json_encode($report)); + $cache->saveData(Json::encode($report)); return $report['count']; } - -function create_sane_stacktrace(\Throwable $e): array -{ - $frames = array_reverse($e->getTrace()); - $frames[] = [ - 'file' => $e->getFile(), - 'line' => $e->getLine(), - ]; - $stackTrace = []; - foreach ($frames as $i => $frame) { - $file = $frame['file'] ?? '(no file)'; - $line = $frame['line'] ?? '(no line)'; - $stackTrace[] = sprintf( - '#%s %s:%s', - $i, - trim_path_prefix($file), - $line, - ); - } - return $stackTrace; -} - -/** - * Trim path prefix for privacy/security reasons - * - * Example: "/var/www/rss-bridge/index.php" => "index.php" - */ -function trim_path_prefix(string $filePath): string -{ - return mb_substr($filePath, mb_strlen(dirname(__DIR__)) + 1); -} |