Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#27984 closed feature request (wontfix)

Log Plugin Activation Output in Debug.log if WP_DEBUG_LOG is enabled

Reported by: lordspace's profile lordspace Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Plugins Keywords:
Focuses: Cc:


I just found out that one of my plugins was producing some output but I couldn't find it in the logs.
I dug deeper and noticed that WordPress starts the output buffering and then loads the plugin file but it doesn't do anything with the output except for it checks for its size.

That's in /wp-admin/includes/plugin.php around line 601

This code allowed me to log the errors (installed it as an MU plugin).

add_action('activated_plugin', 'dbg_log_error', 0, 2);

function dbg_log_error($plugin, $network_wide) {
	if (ob_get_length() == 0) {
		return ;
	$buff = '';
	$buff .= "Plugin: $plugin\n";
	$buff .= sprintf("Network Wide: %s\n", $network_wide ? 'No' : 'Yes');
	$buff .= "Output:\n";
	$buff .= ob_get_contents() . "\n\n";
	file_put_contents(WP_CONTENT_DIR. '/plugin_activation_error.log', $buff, FILE_APPEND);

Change History (4)

#1 @johnbillion
9 years ago

One potential problem I see is that a plugin could be outputting a lot of data when it shouldn't, which could make your debug log incomprehensible.

On a related note, there's a plugin which shows the unexpected output on activation.

#2 @lordspace
9 years ago

Yep. Makes sense.
What if the message is truncated at the first 256 bytes?

#3 @helen
9 years ago

  • Version changed from trunk to 3.9

#4 @DrewAPicture
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

This seems to fall squarely in plugin territory. Thanks for the suggestion. Closing as wontfix.

Note: See TracTickets for help on using tickets.