mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-06-30 09:04:37 +02:00
feat: add a proper feed item uid when the bridge errors out (#3237)
* refactor: move function to class * fix: use the computed bridge name as cache key * refactor: extract method * fix: set a feed item uid on errors * docs * fix: remove year from uid
This commit is contained in:
parent
c97e1923ae
commit
7f1b32f390
2 changed files with 57 additions and 67 deletions
|
@ -45,37 +45,3 @@ function returnServerError($message)
|
|||
{
|
||||
returnError($message, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores bridge-specific errors in a cache file.
|
||||
*
|
||||
* @param string $bridgeName The name of the bridge that failed.
|
||||
* @param int $code The error code
|
||||
*
|
||||
* @return int The total number the same error has appeared
|
||||
*/
|
||||
function logBridgeError($bridgeName, $code)
|
||||
{
|
||||
$cacheFactory = new CacheFactory();
|
||||
|
||||
$cache = $cacheFactory->create();
|
||||
$cache->setScope('error_reporting');
|
||||
$cache->setkey($bridgeName . '_' . $code);
|
||||
$cache->purgeCache(86400); // 24 hours
|
||||
|
||||
if ($report = $cache->loadData()) {
|
||||
$report = Json::decode($report);
|
||||
$report['time'] = time();
|
||||
$report['count']++;
|
||||
} else {
|
||||
$report = [
|
||||
'error' => $code,
|
||||
'time' => time(),
|
||||
'count' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
$cache->saveData(Json::encode($report));
|
||||
|
||||
return $report['count'];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue