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
parent 1efaba5c7c
commit 43f0fc93b7
4 changed files with 26 additions and 18 deletions

View file

@ -24,7 +24,13 @@ class FileCache extends CacheAbstract{
public function saveData($datas){ public function saveData($datas){
$this->isPrepareCache(); $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; return $this;
} }
@ -89,4 +95,4 @@ class FileCache extends CacheAbstract{
$stringToEncode = $_SERVER['REQUEST_URI'] . http_build_query($this->param); $stringToEncode = $_SERVER['REQUEST_URI'] . http_build_query($this->param);
return hash('sha1', $stringToEncode) . '.cache'; return hash('sha1', $stringToEncode) . '.cache';
} }
} }

View file

@ -1,5 +1,4 @@
<?php <?php
$time_start = microtime(true);
/* /*
TODO : TODO :
- manage SSL detection because if library isn't loaded, some bridge crash ! - manage SSL detection because if library isn't loaded, some bridge crash !
@ -14,7 +13,7 @@ TODO :
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
error_reporting(0); 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 // extensions check
if (!extension_loaded('openssl')) if (!extension_loaded('openssl'))
@ -98,14 +97,20 @@ try{
$bridge->setDatas($_REQUEST); $bridge->setDatas($_REQUEST);
$bridge->loadMetadatas(); $bridge->loadMetadatas();
// Data transformation // Data transformation
$format = Format::create($format); try {
$format $format = Format::create($format);
->setDatas($bridge->getDatas()) $format
->setExtraInfos(array( ->setDatas($bridge->getDatas())
'name' => $bridge->getName(), ->setExtraInfos(array(
'uri' => $bridge->getURI(), 'name' => $bridge->getName(),
)) 'uri' => $bridge->getURI(),
->display(); ))
->display();
} catch(Exception $e) {
echo "The brige has crashed. You should report this to the bridges maintainer";
}
die; die;
} }
break; break;
@ -273,10 +278,7 @@ $formats = Format::searchInformation();
?> ?>
<footer> <footer>
<?= $activeFoundBridgeCount; ?>/<?= count($whitelist_selection) ?> active bridges (<a href="?show_inactive=1">Show inactive</a>)<br /> <?= $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> </footer>
</body> </body>
</html> </html>
<?php
echo "Ran for ". (microtime(true) - $time_start);
?>

View file

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

View file

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