Log a warning when headers were already sent and we can't
[lhc/web/wiklou.git] / includes / WebResponse.php
index 90b76e3..f5fb47f 100644 (file)
@@ -39,7 +39,14 @@ class WebResponse {
         * @param null|int $http_response_code Forces the HTTP response code to the specified value.
         */
        public function header( $string, $replace = true, $http_response_code = null ) {
-               header( $string, $replace, $http_response_code );
+               if ( headers_sent() ) {
+                       MWDebug::warning( 'Headers already sent, should send headers earlier than ' . wfGetCaller() );
+               }
+               if ( $http_response_code ) {
+                       header( $string, $replace, $http_response_code );
+               } else {
+                       header( $string, $replace );
+               }
        }
 
        /**