Check headers sent before sending PHP response

If the response contents has been sent before an error occurs, PHP
triggers the warning "Cannot modify header information - headers already sent"

This change ensure that the error message is echoed, while it's impossible
to change the HTTP status code and headers.
Merge branch '2.3' into 2.4

* 2.3:
  Check headers sent before sending PHP response
  Fixed ACE domain checks on UrlValidator (#10031)
  handle array root element