Cache get_plugins() list. Props DD32. fixes #7113

git-svn-id: https://develop.svn.wordpress.org/trunk@8068 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-06-10 16:57:33 +00:00
parent 70d87d4c0d
commit a5afa77fca
3 changed files with 14 additions and 17 deletions

View File

@ -32,11 +32,12 @@ function get_plugin_data( $plugin_file ) {
} }
function get_plugins($plugin_folder = '') { function get_plugins($plugin_folder = '') {
global $wp_plugins;
if ( isset( $wp_plugins ) ) { if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') )
return $wp_plugins; $cached_plugins = array();
}
if ( isset($cache_plugins[ $plugin_folder ]) )
return $cache_plugins[ $plugin_folder ];
$wp_plugins = array (); $wp_plugins = array ();
$plugin_root = WP_PLUGIN_DIR; $plugin_root = WP_PLUGIN_DIR;
@ -85,6 +86,9 @@ function get_plugins($plugin_folder = '') {
uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));
$cache_plugins[ $plugin_folder ] = $wp_plugins;
wp_cache_set('plugins', $cache_plugins, 'plugins');
return $wp_plugins; return $wp_plugins;
} }

View File

@ -83,15 +83,8 @@ if( !empty($action) ) {
$delete_result = delete_plugins($plugins); $delete_result = delete_plugins($plugins);
//HACK TIME! wp_cache_delete('plugins', 'plugins');
// Proper way needed, perhaps get_plugins() to convert to wp_cache_get() any reason why it hasnt allready?
// This clears the cached plugin list
global $wp_plugins;
$wp_plugins = null;
//TODO: Implement!.. STAT!
break; break;
default: default:
var_dump("Unknown Action $action"); var_dump("Unknown Action $action");

View File

@ -222,7 +222,7 @@ else
wp_cache_init(); wp_cache_init();
if ( function_exists('wp_cache_add_global_groups') ) { if ( function_exists('wp_cache_add_global_groups') ) {
wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta')); wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta'));
wp_cache_add_non_persistent_groups(array( 'comment', 'counts' )); wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
} }
require (ABSPATH . WPINC . '/plugin.php'); require (ABSPATH . WPINC . '/plugin.php');