From 54c812bf7d5c1915f11eca61b1d48e1db88e342b Mon Sep 17 00:00:00 2001 From: plegall Date: Tue, 28 Apr 2026 16:40:57 +0200 Subject: [PATCH] fixes #2553 force opcache to reload files extracted from zip during plugin update --- admin/include/plugins.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/admin/include/plugins.class.php b/admin/include/plugins.class.php index dd2cf95c5..cc7e95095 100644 --- a/admin/include/plugins.class.php +++ b/admin/include/plugins.class.php @@ -702,6 +702,23 @@ DELETE FROM '. PLUGINS_TABLE .' PCLZIP_OPT_REMOVE_PATH, $root, PCLZIP_OPT_REPLACE_NEWER)) { + // opcache may certainly have loaded the maintain.class.php of the previous + // version of the plugin. We're going to need it right after the zip extract + // to perform an update action. We need to make sure the PHP files of the + // new version of the plugin are reload. Thus we need to remove old files + // from opcache. + if (function_exists('opcache_invalidate')) + { + foreach ($result as $file) + { + if (!preg_match('{/language/}', $file['filename']) and preg_match('/\.php$/', $file['filename'])) + { + opcache_invalidate($file['filename'], true); + $logger->debug(__FUNCTION__.' extracted file = '.$file['filename'].', opcache_invalidate performed'); + } + } + } + foreach ($result as $file) { if ($file['stored_filename'] == $main_filepath)