From b2a2fbdf6ec792e285fb80a77d636d8d79db036c Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Fri, 15 Dec 2017 19:34:35 +0100 Subject: [PATCH] as discussed with @fichtner, add invalidateCache() to acl and menu system --- src/etc/rc.configure_firmware | 4 ++-- .../mvc/app/models/OPNsense/Base/Menu/MenuSystem.php | 10 ++++++++++ src/opnsense/mvc/app/models/OPNsense/Core/ACL.php | 10 ++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/etc/rc.configure_firmware b/src/etc/rc.configure_firmware index 01ae32f8b..48fbf98d0 100755 --- a/src/etc/rc.configure_firmware +++ b/src/etc/rc.configure_firmware @@ -47,5 +47,5 @@ system_firmware_configure(true); system_login_configure(true); /* flush cache */ -(new OPNsense\Core\ACL())->persist(); -(new OPNsense\Base\Menu\MenuSystem())->persist(); +(new OPNsense\Core\ACL())->invalidateCache(); +(new OPNsense\Base\Menu\MenuSystem())->invalidateCache(); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuSystem.php b/src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuSystem.php index a58ab7060..472c0b933 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuSystem.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuSystem.php @@ -94,6 +94,16 @@ class MenuSystem return $node->append($id, $properties); } + /** + * invalidate cache, removes cache file from disk if available, which forces the next request to persist() again + */ + public function invalidateCache() + { + if (file_exists($this->menuCacheFilename)) { + unlink($this->menuCacheFilename); + } + } + /** * Load and persist Menu configuration to disk. * @param bool $nowait when the cache is locked, skip waiting for it to become available. diff --git a/src/opnsense/mvc/app/models/OPNsense/Core/ACL.php b/src/opnsense/mvc/app/models/OPNsense/Core/ACL.php index 8e91e3714..5aea77830 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Core/ACL.php +++ b/src/opnsense/mvc/app/models/OPNsense/Core/ACL.php @@ -304,6 +304,16 @@ class ACL return false; } + /** + * invalidate cache, removes cache file from disk if available, which forces the next request to persist() again + */ + public function invalidateCache() + { + if (file_exists($this->aclCacheFilename)) { + unlink($this->aclCacheFilename); + } + } + /** * check if pluggable ACL's are expired * @return bool is expired