]> git.mxchange.org Git - friendica-addons.git/commitdiff
[advancedcontentfilter] Fix PHP Warning: Invalid argument supplied for foreach
authorHypolite Petovan <mrpetovan@gmail.com>
Tue, 1 May 2018 12:39:15 +0000 (08:39 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Tue, 1 May 2018 12:40:26 +0000 (08:40 -0400)
advancedcontentfilter/advancedcontentfilter.php

index e34d577103f5f7d593dc42672e6a86905fa660a5..993c8b4c1da9d5d403419c2911142080b32e1f78 100644 (file)
@@ -118,21 +118,23 @@ function advancedcontentfilter_prepare_body_content_filter(App $a, &$hook_data)
                ));
        }
 
-       foreach($rules as $rule) {
-               try {
-                       $serializedParsedExpression = new ExpressionLanguage\SerializedParsedExpression(
-                               $rule['expression'],
-                               $rule['serialized']
-                       );
-
-                       $found = (bool) $expressionLanguage->evaluate($serializedParsedExpression, $vars);
-               } catch (Exception $e) {
-                       $found = false;
-               }
-
-               if ($found) {
-                       $hook_data['filter_reasons'][] = L10n::t('Filtered by rule: %s', $rule['name']);
-                       break;
+       if ($rules) {
+               foreach($rules as $rule) {
+                       try {
+                               $serializedParsedExpression = new ExpressionLanguage\SerializedParsedExpression(
+                                       $rule['expression'],
+                                       $rule['serialized']
+                               );
+
+                               $found = (bool) $expressionLanguage->evaluate($serializedParsedExpression, $vars);
+                       } catch (Exception $e) {
+                               $found = false;
+                       }
+
+                       if ($found) {
+                               $hook_data['filter_reasons'][] = L10n::t('Filtered by rule: %s', $rule['name']);
+                               break;
+                       }
                }
        }
 }