Skip to content

Commit

Permalink
➖ REMOVE: disabling of warning message and file_get_contents conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmoodak committed Sep 22, 2023
1 parent 265b8e5 commit 017e6dc
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions integrations/integration-vip-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,17 @@ protected function get_vip_config_from_file( string $slug ) {
$config_file_name = $slug . '-config.php';
$config_file_path = $config_file_directory . '/' . $config_file_name;

/**
* Temporarily disable warnings by clearing the E_WARNING bit.
*
* Reading config file via `file_get_contents()` even with `@` operator generate warnings on PHP 8+.
*/
$current_error_reporting = error_reporting(); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting
error_reporting( $current_error_reporting & ~E_WARNING ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting

/**
* Clear cache to always read data from latest config file.
*
* Kubernetes ConfigMap updates the file via symlink instead of actually replacing the file and
* PHP cache can hold a reference to the old symlink that can cause fatal if we use require
* on it.
*/
if ( false === file_get_contents( $config_file_path ) ) {
clearstatcache( true, $config_file_directory . '/' . $config_file_name );
// Clears cache for files created by k8s ConfigMap.
clearstatcache( true, $config_file_directory . '/..data' );
clearstatcache( true, $config_file_directory . '/..data/' . $config_file_name );
}

// Restore the original error reporting.
error_reporting( $current_error_reporting ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting
clearstatcache( true, $config_file_directory . '/' . $config_file_name );
// Clears cache for files created by k8s ConfigMap.
clearstatcache( true, $config_file_directory . '/..data' );
clearstatcache( true, $config_file_directory . '/..data/' . $config_file_name );

if ( ! is_readable( $config_file_path ) ) {
return null;
Expand Down

0 comments on commit 017e6dc

Please sign in to comment.