From ea9ec0dadf4d352b1187eec43d82e7545b336151 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 1 May 2018 08:39:15 -0400 Subject: [PATCH 1/2] [advancedcontentfilter] Fix PHP Warning: Invalid argument supplied for foreach --- .../advancedcontentfilter.php | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index e34d5771..993c8b4c 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -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'] - ); + 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; - } + $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 ($found) { + $hook_data['filter_reasons'][] = L10n::t('Filtered by rule: %s', $rule['name']); + break; + } } } } From 37c4455c0621496ff1030568fbef60e682d15dd6 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 1 May 2018 08:39:45 -0400 Subject: [PATCH 2/2] [advancedcontentfilter] Fix unknown function "current_theme" --- advancedcontentfilter/advancedcontentfilter.php | 1 + advancedcontentfilter/templates/settings.tpl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index 993c8b4c..47ace1c2 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -201,6 +201,7 @@ function advancedcontentfilter_content(App $a) } else { $t = get_markup_template('settings.tpl', 'addon/advancedcontentfilter/'); return replace_macros($t, [ + '$current_theme' => $a->getCurrentTheme(), '$backtosettings' => L10n::t('Back to Addon Settings'), '$title' => L10n::t('Advanced Content Filter'), '$add_a_rule' => L10n::t('Add a Rule'), diff --git a/advancedcontentfilter/templates/settings.tpl b/advancedcontentfilter/templates/settings.tpl index b29c275b..813dc919 100644 --- a/advancedcontentfilter/templates/settings.tpl +++ b/advancedcontentfilter/templates/settings.tpl @@ -48,7 +48,7 @@