[advancedcontentfilter] Clear rule cache anytime rules are changed in the database

- This was preventing updated rules from being applied immediately as the cached rules were still in effect
This commit is contained in:
Hypolite Petovan 2021-08-16 06:10:34 -04:00
parent b141416b51
commit 217643f67d

View File

@ -361,6 +361,8 @@ function advancedcontentfilter_post_rules(ServerRequestInterface $request)
$rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => DBA::lastInsertId()]); $rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => DBA::lastInsertId()]);
DI::cache()->delete('rules_' . local_user());
return json_encode(['message' => DI::l10n()->t('Rule successfully added'), 'rule' => $rule]); return json_encode(['message' => DI::l10n()->t('Rule successfully added'), 'rule' => $rule]);
} }
@ -390,6 +392,8 @@ function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, Res
throw new HTTPException\ServiceUnavailableException(DBA::errorMessage()); throw new HTTPException\ServiceUnavailableException(DBA::errorMessage());
} }
DI::cache()->delete('rules_' . local_user());
return json_encode(['message' => DI::l10n()->t('Rule successfully updated')]); return json_encode(['message' => DI::l10n()->t('Rule successfully updated')]);
} }
@ -411,6 +415,8 @@ function advancedcontentfilter_delete_rules_id(ServerRequestInterface $request,
throw new HTTPException\ServiceUnavailableException(DBA::errorMessage()); throw new HTTPException\ServiceUnavailableException(DBA::errorMessage());
} }
DI::cache()->delete('rules_' . local_user());
return json_encode(['message' => DI::l10n()->t('Rule successfully deleted')]); return json_encode(['message' => DI::l10n()->t('Rule successfully deleted')]);
} }