It doesn't seem possible to set a redirect from function that uses the ArticleSaveComplete hook, because the Article object then resets it later on after the hook is run.
Is there a way around this? Can we add a feature to Article that overrides this?
I'm implementing a feature that does a check after the article has been saved. In this case, if there are missing images it'll redirect the user to a special page that will prompt the user for a few options, but right now the Article object is clearing the redirect.
Thanks Travis
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)
On 11/1/07, Travis Derouin travis@wikihow.com wrote:
It doesn't seem possible to set a redirect from function that uses the ArticleSaveComplete hook, because the Article object then resets it later on after the hook is run.
Is there a way around this? Can we add a feature to Article that overrides this?
I'm implementing a feature that does a check after the article has been saved. In this case, if there are missing images it'll redirect the user to a special page that will prompt the user for a few options, but right now the Article object is clearing the redirect.
Thanks Travis
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
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();
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
wikitech-l@lists.wikimedia.org