[advancedcontentfilter] Fix PHP Warning: Invalid argument supplied for foreach

pull/596/head
Hypolite Petovan 2018-05-01 08:39:15 -04:00
parent b0dba96b0d
commit ea9ec0dadf
1 changed files with 15 additions and 13 deletions

View 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']
);
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;
}
}
}
}