Mailing List Archive

Custom redirect after page save in extension
Hi everyone,

I would like to force a redirect to another page after the successful
saving of pages in a certain namespace. I was able to do that in the
most ugly way possible via a "ArticleUpdateBeforeRedirect" hook:

public static function onArticleUpdateBeforeRedirect(
$article,
&$sectionanchor,
&$extraq)
{
if ($article->getTitle()->getNamespace() == NS_DESCRIPTION) {
$extraq = "title=" . $article->getTitle()->getDBKey();
}
}

What I would really like is to overwrite the "Location" header but that
seems to be set after this hook is called.

Any ideas?

Cheers,
Sebastian

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: Custom redirect after page save in extension [ In reply to ]
I think I found a solution myself by doing a redirect on the page itself:

public static function onInitializeArticleMaybeRedirect(
$title,
$request,
&$ignoreRedirect,
&$target,
$article )
{
global $wgArticlePath;

if ($title->getNamespace() == NS_DESCRIPTION) {
$target = str_replace('$1', $title->getDBKey(), $wgArticlePath);
}
}

Is this ok or also too hacky?

On 11.11.20 10:54, Sebastian Trueg wrote:
> Hi everyone,
>
> I would like to force a redirect to another page after the successful
> saving of pages in a certain namespace. I was able to do that in the
> most ugly way possible via a "ArticleUpdateBeforeRedirect" hook:
>
> public static function onArticleUpdateBeforeRedirect(
> $article,
> &$sectionanchor,
> &$extraq)
> {
> if ($article->getTitle()->getNamespace() == NS_DESCRIPTION) {
> $extraq = "title=" . $article->getTitle()->getDBKey();
> }
> }
>
> What I would really like is to overwrite the "Location" header but that
> seems to be set after this hook is called.
>
> Any ideas?
>
> Cheers,
> Sebastian
>
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>

--
Sebastian Trueg
Managing Director
TrueGeeX UG (haftungsbeschränkt)
trueg@truegeex.de
http://www.linkedin.com/in/trueg
Mobile: 0049 1762 3244 664

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l