From: Hypolite Petovan Date: Mon, 16 Aug 2021 10:10:34 +0000 (-0400) Subject: [advancedcontentfilter] Clear rule cache anytime rules are changed in the database X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=217643f67dcef43281e14c07a107516e4f135202;p=friendica-addons.git [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 --- diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index f5a341fe..57c87ffd 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -361,6 +361,8 @@ function advancedcontentfilter_post_rules(ServerRequestInterface $request) $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]); } @@ -390,6 +392,8 @@ function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, Res throw new HTTPException\ServiceUnavailableException(DBA::errorMessage()); } + DI::cache()->delete('rules_' . local_user()); + 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()); } + DI::cache()->delete('rules_' . local_user()); + return json_encode(['message' => DI::l10n()->t('Rule successfully deleted')]); }