[wp-hackers] warnings and errors when no plugins are activated
Adi Sieker
ml at sieker.info
Sun Nov 28 12:28:46 UTC 2004
Hi,
when there are no plugins activated. It's not possible to active
a plugin again PHP aborts execution with an error about [] not being
an allowed operator for string.
Attached is a diff that' fixes the problems.
Regards
Adi
--
Adi J. Sieker http://www.sieker.info/
Freelance developer http://www.sieker.info/wiki.php?id=Profil
-------------- next part --------------
Index: wp-settings.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-settings.php,v
retrieving revision 1.61
diff -U3 -r1.61 wp-settings.php
--- wp-settings.php 26 Oct 2004 04:03:34 -0000 1.61
+++ wp-settings.php 28 Nov 2004 12:23:15 -0000
@@ -88,7 +88,7 @@
require(ABSPATH . '/my-hacks.php');
}
-if ( get_settings('active_plugins') ) {
+if ( is_array(get_settings('active_plugins')) ) {
$current_plugins = get_settings('active_plugins');
foreach ($current_plugins as $plugin) {
if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
Index: wp-admin/plugins.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/plugins.php,v
retrieving revision 1.18
diff -U3 -r1.18 plugins.php
--- wp-admin/plugins.php 26 Nov 2004 02:29:45 -0000 1.18
+++ wp-admin/plugins.php 28 Nov 2004 12:23:15 -0000
@@ -6,6 +6,8 @@
if ('activate' == $_GET['action']) {
$current = get_settings('active_plugins');
+ if(!is_array($current))
+ $current = Array();
if (!in_array($_GET['plugin'], $current)) {
$current[] = trim( $_GET['plugin'] );
}
@@ -29,11 +31,13 @@
// If any plugins don't exist, axe 'em
$check_plugins = get_settings('active_plugins');
-foreach ($check_plugins as $check_plugin) {
- if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) {
- $current = get_settings('active_plugins');
- unset($current[$_GET['plugin']]);
- update_option('active_plugins', $current);
+if(is_array($check_plugins)) {
+ foreach ($check_plugins as $check_plugin) {
+ if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) {
+ $current = get_settings('active_plugins');
+ unset($current[$_GET['plugin']]);
+ update_option('active_plugins', $current);
+ }
}
}
?>
@@ -74,7 +78,7 @@
foreach($plugins as $plugin_file => $plugin_data) {
$style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
- if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
+ if (!empty($current_plugins) && is_array($current_plugins) && in_array($plugin_file, $current_plugins)) {
$action = __("<a href='plugins.php?action=deactivate&plugin=$plugin_file' title='Deactivate this plugin' class='delete'>Deactivate</a>");
$plugin = __("<strong>$plugin</strong>");
} else {
More information about the hackers
mailing list