AjaxResponse: Fix broken logic for extracting HTTP status codes
authorBryan Davis <bd808@wikimedia.org>
Thu, 11 Jun 2015 15:13:00 +0000 (09:13 -0600)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 11 Jun 2015 15:42:02 +0000 (16:42 +0100)
commit7b6890654a3ef994eb12acd2f37e93d964878288
tree67d6e33f3b61bf3d1647cc07c55377dcc7e8b57d
parent17aa37bd3a79ab9d96327f15031e3db755b7799e
AjaxResponse: Fix broken logic for extracting HTTP status codes

Follows-up 6584cef207 (r16266; 2006; MediaWiki 1.8.0).
This regex was just trimming whitespace from the start of the string. It
matched whitespace, then a match group for a first sequence of digits. The
replacement is just the digits match. This is essentially `ltrim()`. It didn't
account for the content after the match.

> echo preg_replace( '/^ *(\d+)/', '\1', '200 OK' );
> "200 OK"

This was causing:
> Warning: Unknown HTTP status code 200 OK in libs/HttpStatus.php:100
> Warning: Unknown HTTP status code 304 Not Modified OK in libs/HttpStatus.php:100

It defaults to HTTP 200. So presumbaly the impact was low. Though it may've caused
304 responses to have been broken (content body missing).

Bug: T102028
Change-Id: Iafff9982bbbee893c13f891901dde88f998db7a6
includes/AjaxResponse.php