Opened 16 years ago
Closed 14 years ago
#16562 closed defect (bug) (fixed)
sometimes deactivation of plugin deactivates another
| Reported by: | Ghost_ufa | Owned by: | nacin |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | General | Version: | 3.1 |
| Severity: | major | Keywords: | has-patch |
| Cc: | Focuses: |
Description
in some cases of plugin's mailfunctions serialized list of active plugins has gaps in index - ex. 14 15 17 18
Current WP realisation don't correct it and can't work correctly, and occures deactivation of incorrect plugin.
resolution:
file wp-admin/includes/plugin.php
function deactivate_plugins
is:
if ( $network_wide ) {
$do_network = true;
unset( $network_current[ $plugin ] );
} else {
$key = array_search( $plugin, $current );
if ( false !== $key ) {
$do_blog = true;
array_splice( $current, $key, 1 );
}
}
should be:
unset( $network_current[ $key ] );
instead of
array_splice( $current, $key, 1 );
And after loop, just before "if ( $do_blog )", add index renumbering like this:
$i=0; $new_current=array();
foreach ( (array) $current as $cur ) $new_current[$i++]=$cur;
$current=$new_current;
Attachments (2)
Change History (7)
#3
@
15 years ago
- Keywords has-patch added
Nice find.
For a little explanation what is going on, basically it's using a key value as a numerical offset:
- array_search() returns the key, not the offset of an array.
- array_splice() is using a numerical offset which must not be the numerical value of $key.
- array_splice() is used to remove a single element only, it just does what unset() is used for.
Trivial to patch.
In case running into that, its not obvious what was going on. Thanks for reporting this.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
can you post an example of a damaged option, or any explanation of how you've come across this?