From ef0329b09cb9980c5c9e7721e02ef247bb2e320e Mon Sep 17 00:00:00 2001 From: Glandos Date: Wed, 15 Apr 2015 21:55:24 +0200 Subject: [PATCH] Handle missing items in LeBonCoinBridge Ignore missing items instead of doing 500 errors. --- bridges/LeBonCoinBridge.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php index e895bc2c..e3cc2562 100755 --- a/bridges/LeBonCoinBridge.php +++ b/bridges/LeBonCoinBridge.php @@ -25,14 +25,20 @@ class LeBonCoinBridge extends BridgeAbstract{ $html = file_get_html($link) or $this->returnError('Could not request LeBonCoin.', 404); $list = $html->find('.list-lbc', 0); + if($list === NULL) { + return; + } $tags = $list->find('a'); foreach($tags as $element) { $item = new \Item(); $item->uri = $element->href; $title = $element->getAttribute('title'); + $content_image = $element->find('div.image', 0)->find('img', 0); - $content = 'thumbnail'; + if($content_image !== NULL) { + $content = 'thumbnail'; + } $date = $element->find('div.date', 0)->find('div', 0) . $element->find('div.date', 0)->find('div', 1) . '
'; $detailsList = $element->find('div.detail', 0);