Page MenuHomePhabricator

Internal use of API (FauxRequest) results in HTTP headers being set
Closed, InvalidPublic

Description

Author: openbip

Description:
Discussion can be found here: http://toolserver.org/~mwbot/logs/%23mediawiki/20100119.txt (search for "openbip")

I'm creating new tags using the MediaWiki API internally (http://www.mediawiki.org/wiki/API:Calling_internally) via FauxRequest.

Some of these tags create new wiki pages automatically. When save (or preview) a page with one of these tags, instead of seeing the updated page (or the preview of the updated page), my browser redirects to one of the newly-created pages.

Thus, it seems that using the MediaWiki API, even internally, results in HTTP headers being set.


Version: 1.15.x
Severity: normal

Details

Reference
bz22179

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:50 PM
bzimport set Reference to bz22179.
bzimport added a subscriber: Unknown Object (MLST).

For what it's worth, the header() calls in the API seem to be suppressed by using FauxRequest, so I'm not sure it's within the API itself. It would be nice if all calls to header() use the wrapper WebResponse::header() so we can handle this "send headers or not" condition in one place.

openbip wrote:

Some more information:

I'm testing with Page1, which contains a tag that creates Page2, edits Page2, and then adds a new section to Page2.

When viewing Page1, instead of seeing Page1, I see Page2. But some more information on that:

  1. It is the /last/ API-result that is showing up in my browser. i.e. in the above example, my browser (Firefox and Chrome) is specifically going to the new section I added. i.e. The address bar shows: http://...../mediawiki-1.15.1/index.php/Page2#NewSection
  2. In my tag implementation, I tried printing out headers_list() after each API call. In each case I got:

Array
(

[0] => X-Powered-By: PHP/5.3.1

)

I'm not 100% sure it's a redirect yet ... but since the URL in the browser is changing I assume it's a redirect.

(In reply to comment #1)

For what it's worth, the header() calls in the API seem to be suppressed by
using FauxRequest, so I'm not sure it's within the API itself. It would be nice
if all calls to header() use the wrapper WebResponse::header() so we can handle
this "send headers or not" condition in one place.

r89528

(In reply to comment #0)

Discussion can be found here:
http://toolserver.org/~mwbot/logs/%23mediawiki/20100119.txt (search for
"openbip")

I'm creating new tags using the MediaWiki API internally
(http://www.mediawiki.org/wiki/API:Calling_internally) via FauxRequest.

Some of these tags create new wiki pages automatically. When save (or preview)
a page with one of these tags, instead of seeing the updated page (or the
preview of the updated page), my browser redirects to one of the newly-created
pages.

Thus, it seems that using the MediaWiki API, even internally, results in HTTP
headers being set.

Do you have something I can test this on? Else, can you see what occurs on trunk as of r89528?

Thanks!

I do wonder if we'll need to header_remove( "X-Powered-By" ) or something...

Anomie claimed this task.
Anomie subscribed.

I think the right answer here is "Don't do that".