[wp-trac] [WordPress Trac] #52725: WP5.7-RC2-50494 Warning: Cannot modify header information

WordPress Trac noreply at wordpress.org
Fri Mar 5 15:38:52 UTC 2021


#52725: WP5.7-RC2-50494 Warning: Cannot modify header information
----------------------------+-----------------------------
 Reporter:  mitfi           |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  General         |    Version:  trunk
 Severity:  normal          |   Keywords:  dev-feedback
  Focuses:  administration  |
----------------------------+-----------------------------
 Dear WordPress Development Team,

 only in WP5.7 ( and NOT in WP5.6.2), I receive the following warnings:

 Warning: Cannot modify header information - headers already sent by
 (output started at /.../wp-admin/includes/template.php:2526) in /.../wp-
 includes/pluggable.php on line 1329

 Warning: Cannot modify header information - headers already sent by
 (output started at /.../wp-admin/includes/template.php:2526) in /.../wp-
 includes/pluggable.php on line 1332

 Background:
 In my plugin, I define the following submenu entries:

 function add_emergency_management_menu_items()
 {
   $mfem_admin_page = add_submenu_page(
                        'users.php', // related menu
                        'Emergency Management', // page title
                        'EM - Emergency Management', // submenu title
                        'manage_options', // required capability (or role)
                        'mfem-emergency-management', // page slug
                        'mfem_emergency_management_main' // callback
 function, the main plugin function
                      );
   $mfem_title = __('Reset SALTs & Sessions','emergency-management');
   add_submenu_page(
     'users.php', // related menu
     $mfem_title, // page title
     'EM - '.$mfem_title, // submenu title
     'manage_options', // required capability (or role)
     'mfem-warning-saltsform-handler-pre', // page slug (here, we do not
 have a page but just a function...)
     'mfem_warning_saltsform_handler_pre' // callback function (pre to call
 mfem_warning_saltsform_handler)
   );

   add_action( 'load-'.$mfem_admin_page, 'mfem_add_help' ); // Add the help
 tabs callback function...
 }
 add_action('admin_menu','add_emergency_management_menu_items');


 Any call to mfem-emergency-management (to the related main admin page) and
 further calls from there to other functions with redirects back to
 "admin.php?page=mfem-emergency-management" are working fine.

 However, a call to mfem-warning-saltsform-handler-pre, with some activity
 done there (regardless whether I do a screen output or not) and a redirect
 to "admin.php?page=mfem-emergency-management", will fail with the above
 warning as soon as the redirect is executed.

 This behavior is not to be observed with WP5.6.2.

 Thanks for looking into that.

 Best regards

 Michael

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52725>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list