Make WordPress Core

Opened 7 years ago

Last modified 6 years ago

#43098 new defect (bug)

Defining WP_UNINSTALL_PLUGIN also when the uninstall handler is registered via register_uninstall_hook()

Reported by: svovaf's profile svovaf Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords:
Focuses: administration Cc:

Description

At the moment, there's no way to "know" that the context execution is uninstallation until the uninstall hook is executed:

do_action( "uninstall_{$file}" );

I'd like to move the definition of WP_UNINSTALL_PLUGIN to be set for both uninstall handlers (the uninstall.php and the register_uninstall_hook() hook).

The fix is super simple, just moving define('WP_UNINSTALL_PLUGIN', $file); in /wp-admin/includes/plugin.php outside the if statement.

It's needed when a plugin need to execute some code prior to the register_uninstall_hook() execution that is later used within the callback.

I couldn't think of any intentional reason why it shouldn't be defined for both uninstallation methods.

Change History (4)

#2 in reply to: ↑ 1 @svovaf
7 years ago

Replying to manchumahara:

seems method2 clearly gives the instruction https://developer.wordpress.org/plugins/the-basics/uninstall-methods/

I understand that it's currently not defined when using method number 2, that's why I have opened this ticket. I suggest to define it for both cases so the plugin can identify the uninstallation context.

#3 in reply to: ↑ 1 @Andy Schmidt
7 years ago

Replying to manchumahara:

Yet, it would be helpful for method 1 to know that it's running in the "uninstall" context - especially since it would allow to control WHICH code outside of functions actually SHOULD execute during uninstall.

Probably not a "bug", but an unnecessary limitation.

#4 @pento
6 years ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.