Platonides wrote:
Jim Wilson wrote:
This might work (but it's a tad bit hackier than working through the Article object, which would be ideal):
global $wgOut; $redirectTarget = Title::newFromText('Special:SomePage'); $wgOut->header( 'Location: ' . $redirectTarget->getFullURL() ); die();
Disclaimer: I have not tested the above, so it may not work :/
-- Jim R. Wilson (jimbojw)
It will work, but it doesn't need to. You're setting a redirect target to the Output Object and then killing it. If WebResponse::header delayed the call to header() it wouldn't.
If dying, the right way would be using the php functions, not its mediawiki wrappers: header( 'Location: ' . $redirectTarget->getFullURL() ); die();
If you exit after an article save, various important update operations will be skipped. Instead, I would recommend:
$wgOut->disable(); header( 'Location: ' . $redirectTarget->getFullURL() );
Or better still, patch Article::doRedirect() to allow changing the redirect URL.
-- Tim Starling