From 9bf26e4440b896b9c8cb46e9da53d0d823ec0e71 Mon Sep 17 00:00:00 2001 From: Carl Alexander Date: Sat, 25 Sep 2021 02:37:50 -0400 Subject: [PATCH] fix: use metadata to determine if the object cache drop-in is present --- src/Configuration/QueryMonitorConfiguration.php | 11 +++++++++-- stubs/object-cache.php | 13 ++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Configuration/QueryMonitorConfiguration.php b/src/Configuration/QueryMonitorConfiguration.php index 25f73f9..a324376 100644 --- a/src/Configuration/QueryMonitorConfiguration.php +++ b/src/Configuration/QueryMonitorConfiguration.php @@ -50,8 +50,15 @@ public function modify(Container $container) return true; }); - $container['query_monitor_display_object_cache_active'] = $container->service(function () { - return wp_using_ext_object_cache() && !is_plugin_active('object-cache-pro/redis-cache-pro.php') && !is_plugin_active('redis-cache-pro/redis-cache-pro.php'); + $container['query_monitor_display_object_cache_active'] = $container->service(function (Container $container) { + if (!wp_using_ext_object_cache()) { + return false; + } + + $dropInData = get_plugin_data(WP_CONTENT_DIR.'/object-cache.php', false, false); + $pluginData = get_plugin_data($container['plugin_dir_path'].'/stubs/object-cache.php', false, false); + + return isset($dropInData['PluginName'], $pluginData['PluginName']) && $dropInData['PluginName'] === $pluginData['PluginName']; }); $container['query_monitor_collectors'] = $container->service(function (Container $container) { $collectors = []; diff --git a/stubs/object-cache.php b/stubs/object-cache.php index f9770e2..0385399 100644 --- a/stubs/object-cache.php +++ b/stubs/object-cache.php @@ -2,13 +2,12 @@ declare(strict_types=1); -/* - * This file is part of Ymir WordPress plugin. - * - * (c) Carl Alexander - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. +/** + * Plugin Name: Ymir object cache drop-in + * Plugin URI: https://ymirapp.com + * Description: Connects your WordPress object-cache to the cache server managed by the Ymir platform. + * Author: Carl Alexander + * Author URI: https://ymirapp.com */ $objectCacheApiPaths = array_filter(array_map(function (string $filePath) {