From 8cd178076ff7ff3f8973b7119a2675a3ec133faa Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Sat, 13 Apr 2013 01:16:53 +0200 Subject: Fixed PHP warning if JSON configuration is unreadable or empty. Fixes #3 --- README.md | 2 +- init.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d794093..ed7365b 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ To test your XPath expressions, you can use these Chrome extensions: Some XPath expressions you could need (the `//` is automatically prepended and must be omitted in the FeedMod configuration): -##### HTML5
tag +##### HTML5 <article> tag ```html
…article…
diff --git a/init.php b/init.php index ddfde29..8922a40 100644 --- a/init.php +++ b/init.php @@ -52,6 +52,11 @@ class Af_Feedmod extends Plugin implements IHandler $owner_uid = $article['owner_uid']; $data = json_decode($json_conf, true); + if (!is_array($data)) { + // no valid JSON or no configuration at all + return $article; + } + foreach ($data as $urlpart=>$config) { if (strpos($article['link'], $urlpart) === false) continue; // skip this config if URL not matching if (strpos($article['plugin_data'], "feedmod,$owner_uid:") !== false) { -- cgit v1.3.1