Skip to content

Commit

Permalink
fix: use metadata to determine if the object cache drop-in is present
Browse files Browse the repository at this point in the history
  • Loading branch information
carlalexander committed Sep 25, 2021
1 parent 0c9726e commit 9bf26e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/Configuration/QueryMonitorConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
13 changes: 6 additions & 7 deletions stubs/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

declare(strict_types=1);

/*
* This file is part of Ymir WordPress plugin.
*
* (c) Carl Alexander <[email protected]>
*
* 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) {
Expand Down

0 comments on commit 9bf26e4

Please sign in to comment.