Correction of few bugs.

Warn if RSS-Bridge cannot write to disk.
Try/Catch the bridge RSS generation.

Signed-off-by: teromene <teromene@teromene.fr>
This commit is contained in:
teromene 2015-11-05 10:12:58 +00:00 committed by Mitsukarenai
parent 3cb652b812
commit 2e4e89aff8
4 changed files with 26 additions and 18 deletions

View file

@ -24,7 +24,13 @@ class FileCache extends CacheAbstract{
public function saveData($datas){
$this->isPrepareCache();
file_put_contents($this->getCacheFile(), json_encode($datas));
$writeStream = file_put_contents($this->getCacheFile(), json_encode($datas));
if(!$writeStream) {
throw new \Exception("Cannot write the cache... Do you have the right permissions ?");
}
return $this;
}
@ -89,4 +95,4 @@ class FileCache extends CacheAbstract{
$stringToEncode = $_SERVER['REQUEST_URI'] . http_build_query($this->param);
return hash('sha1', $stringToEncode) . '.cache';
}
}
}

View file

@ -1,5 +1,4 @@
<?php
$time_start = microtime(true);
/*
TODO :
- manage SSL detection because if library isn't loaded, some bridge crash !
@ -14,7 +13,7 @@ TODO :
date_default_timezone_set('UTC');
error_reporting(0);
ini_set('display_errors','1'); error_reporting(E_ALL); // For debugging only.
//ini_set('display_errors','1'); error_reporting(E_ALL); // For debugging only.
// extensions check
if (!extension_loaded('openssl'))
@ -116,14 +115,20 @@ try{
$bridge->setDatas($_REQUEST);
$bridge->loadMetadatas();
// Data transformation
$format = Format::create($format);
$format
->setDatas($bridge->getDatas())
->setExtraInfos(array(
'name' => $bridge->getName(),
'uri' => $bridge->getURI(),
))
->display();
try {
$format = Format::create($format);
$format
->setDatas($bridge->getDatas())
->setExtraInfos(array(
'name' => $bridge->getName(),
'uri' => $bridge->getURI(),
))
->display();
} catch(Exception $e) {
echo "The brige has crashed. You should report this to the bridges maintainer";
}
die;
}
break;
@ -291,10 +296,7 @@ $formats = Format::searchInformation();
?>
<footer>
<?= $activeFoundBridgeCount; ?>/<?= count($whitelist_selection) ?> active bridges (<a href="?show_inactive=1">Show inactive</a>)<br />
<a href="https://github.com/sebsauvage/rss-bridge">RSS-Bridge alpha 0.1 ~ Public Domain</a>
<a href="https://github.com/sebsauvage/rss-bridge">RSS-Bridge alpha 0.2 ~ Public Domain</a>
</footer>
</body>
</html>
<?php
echo "Ran for ". (microtime(true) - $time_start);
?>

View file

@ -58,4 +58,4 @@ class Http{
508 => 'Loop detected',
);
}
}
}

View file

@ -39,4 +39,4 @@ require_once $vendorLibSimpleHtmlDom;
))
->display();
*/
*/