Make WordPress Core

Opened 8 months ago

Closed 7 days ago

#44252 closed defect (bug) (invalid)

Missing return statement in function uninstall_plugin

Reported by: subrataemfluence Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: Plugins Keywords: has-patch 2nd-opinion close
Focuses: coding-standards Cc:


Function uninstall_plugin is missing a final return statement.

It returns true if a plugin's uninstall.php file has been found and included. But it should return false if the file is not present or not included.

Can we re-write like this?

function uninstall_plugin( $plugin ) {
   $file = plugin_basename( $plugin );

   $uninstallable_plugins = (array) get_option( 'uninstall_plugins' );

   do_action( 'pre_uninstall_plugin', $plugin, $uninstallable_plugins );

   if ( file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) )  
   {    ...
        return true;

   if ( isset( $uninstallable_plugins[ $file ] ) ) {
        return true; //this is missing too

   return false;

Attachments (1)

44252.diff (315 bytes) - added by subrataemfluence 8 months ago.

Download all attachments as: .zip

Change History (2)

#1 @afragen
7 days ago

  • Keywords close added
  • Resolution set to invalid
  • Status changed from new to closed

According to the docBlock the function returns true if the uninstall.php file is found and used.

Only in the first conditional does this happen. There is no mention of returning false only that other options using the supplied hooks are available for use.

Note: See TracTickets for help on using tickets.