All new plugins generating 311 chars of unexpected output?

Basically it goes like this (relevant steps only):

  1. plugins.php page calls activate_plugin() function.
  2. Function starts output buffering.
  3. Includes plugin file.
  4. Fires activate_plugin action.
  5. Fires 'activate_' . trim( $plugin ) action.
  6. Fires activated_plugin action.
  7. If buffer is not empty it creates WP_Error object and returns it.
  8. plugins.php page checks for error and displays error message.

So output happens somewhere between steps 2 and 7. If it comes up for multiple plugins then steps 3 and 5 are safe to exclude, they are plugin-specific.

So it is likely something in either activate_plugin or activated_plugin. Also actual unwanted output is passed in WP_Errorobject but not used (only its length).

I’d try to dump hooks first, will take bit of extra code in core a bit to get to that output in WP_Error object.