From a4c385386a82798314f0cf1ddccd85551e2cf26a Mon Sep 17 00:00:00 2001 From: Mehmood Ahmad <31419912+mehmoodak@users.noreply.github.com> Date: Wed, 13 Sep 2023 01:50:35 +0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20fatal=20error=20while=20u?= =?UTF-8?q?pdating=20configmap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- integrations/integration-vip-config.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/integrations/integration-vip-config.php b/integrations/integration-vip-config.php index ef09d0bd1d..94b426e295 100644 --- a/integrations/integration-vip-config.php +++ b/integrations/integration-vip-config.php @@ -80,11 +80,23 @@ private function set_config( string $slug ): void { protected function get_vip_config_from_file( string $slug ) { $config_file_path = ABSPATH . 'config/integrations-config/' . $slug . '-config.php'; - if ( ! is_readable( $config_file_path ) ) { + /** + * Clear realpath cache to get new path else we can get cached path which can be non-existant + * because k8s configmaps updates the file via symlink instead of actually replacing the file and + * PHP cache can hold a reference to the old symlink. + * + * Did tried using `clearstatcache( true, $config_file_path )` but it was giving old symlink, + * `is_readable()` does return correct value (false) for this case but we prefer + * to get the config which `clearstatcache( true )` does return because it gives us new symlink. + */ + clearstatcache( true ); + $config_real_path = realpath( $config_file_path ); + + if ( ! is_readable( $config_real_path ) ) { return null; } - return require_once $config_file_path; + return require $config_real_path; } /**