From beaddcba961cd187e6d3ce968b94610838d70b54 Mon Sep 17 00:00:00 2001 From: Troy Engel Date: Fri, 4 Dec 2015 13:45:10 -0600 Subject: Fix accidental use of emtpy array: [E_WARNING (2) plugins/af_readability/init.php:186 Invalid argument supplied for foreach()] --- plugins/af_readability/init.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 675e5c5d5..97acb4375 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -33,9 +33,11 @@ class Af_Readability extends Plugin { print_notice("Enable the plugin for specific feeds in the feed editor."); $enabled_feeds = $this->host->get($this, "enabled_feeds"); - if (!array($enabled_feeds)) $enabled_feeds = array(); - - $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); + if (!array($enabled_feeds)) { + $enabled_feeds = array(); + } else { + $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); + } $this->host->set($this, "enabled_feeds", $enabled_feeds); if (count($enabled_feeds) > 0) { @@ -183,12 +185,14 @@ class Af_Readability extends Plugin { private function filter_unknown_feeds($enabled_feeds) { $tmp = array(); - foreach ($enabled_feeds as $feed) { + if (!empty($enabled_feeds)) { + foreach ($enabled_feeds as $feed) { - $result = db_query("SELECT id FROM ttrss_feeds WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); + $result = db_query("SELECT id FROM ttrss_feeds WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); - if (db_num_rows($result) != 0) { - array_push($tmp, $feed); + if (db_num_rows($result) != 0) { + array_push($tmp, $feed); + } } } -- cgit v1.2.3 From 3e220fd13165eff5d2c3180f2a2c82672a3187a6 Mon Sep 17 00:00:00 2001 From: Troy Engel Date: Sat, 5 Dec 2015 14:49:54 -0600 Subject: Revert "Fix accidental use of emtpy array: [E_WARNING (2) plugins/af_readability/init.php:186 Invalid argument supplied for foreach()]" This reverts commit beaddcba961cd187e6d3ce968b94610838d70b54. --- plugins/af_readability/init.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 97acb4375..675e5c5d5 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -33,11 +33,9 @@ class Af_Readability extends Plugin { print_notice("Enable the plugin for specific feeds in the feed editor."); $enabled_feeds = $this->host->get($this, "enabled_feeds"); - if (!array($enabled_feeds)) { - $enabled_feeds = array(); - } else { - $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); - } + if (!array($enabled_feeds)) $enabled_feeds = array(); + + $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); $this->host->set($this, "enabled_feeds", $enabled_feeds); if (count($enabled_feeds) > 0) { @@ -185,14 +183,12 @@ class Af_Readability extends Plugin { private function filter_unknown_feeds($enabled_feeds) { $tmp = array(); - if (!empty($enabled_feeds)) { - foreach ($enabled_feeds as $feed) { + foreach ($enabled_feeds as $feed) { - $result = db_query("SELECT id FROM ttrss_feeds WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); + $result = db_query("SELECT id FROM ttrss_feeds WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); - if (db_num_rows($result) != 0) { - array_push($tmp, $feed); - } + if (db_num_rows($result) != 0) { + array_push($tmp, $feed); } } -- cgit v1.2.3 From 5d5f100f4f781f744ccf769ed3790680e76a0ff1 Mon Sep 17 00:00:00 2001 From: Troy Engel Date: Sat, 5 Dec 2015 15:03:01 -0600 Subject: Fix array checking method in 2 places, add array check in one location --- plugins/af_readability/init.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 675e5c5d5..1d7c638a6 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -33,7 +33,7 @@ class Af_Readability extends Plugin { print_notice("Enable the plugin for specific feeds in the feed editor."); $enabled_feeds = $this->host->get($this, "enabled_feeds"); - if (!array($enabled_feeds)) $enabled_feeds = array(); + if (!is_array($enabled_feeds)) $enabled_feeds = array(); $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); $this->host->set($this, "enabled_feeds", $enabled_feeds); @@ -60,7 +60,7 @@ class Af_Readability extends Plugin { print "
"; $enabled_feeds = $this->host->get($this, "enabled_feeds"); - if (!array($enabled_feeds)) $enabled_feeds = array(); + if (!is_array($enabled_feeds)) $enabled_feeds = array(); $key = array_search($feed_id, $enabled_feeds); $checked = $key !== FALSE ? "checked" : ""; @@ -169,6 +169,8 @@ class Af_Readability extends Plugin { function hook_article_filter($article) { $enabled_feeds = $this->host->get($this, "enabled_feeds"); + if (!is_array($enabled_feeds)) return $article; + $key = array_search($article["feed"]["id"], $enabled_feeds); if ($key === FALSE) return $article; -- cgit v1.2.3