EditPage: Add returntoquery parameter to anoneditwarning links
authorRoan Kattouw <roan.kattouw@gmail.com>
Thu, 15 Nov 2018 01:08:45 +0000 (17:08 -0800)
committerRoan Kattouw <roan.kattouw@gmail.com>
Thu, 15 Nov 2018 01:08:45 +0000 (17:08 -0800)
It's important to send people back not just to the page they were
editing, but to the actual edit action as well.

Bug: T208989
Change-Id: I010145840da1ac93927db846872eaf9843116bd7

includes/EditPage.php

index 373f6d9..1f17297 100644 (file)
@@ -3145,16 +3145,22 @@ ERROR;
                        );
                } elseif ( $user->isAnon() ) {
                        if ( $this->formtype != 'preview' ) {
+                               $returntoquery = array_diff_key(
+                                       $this->context->getRequest()->getValues(),
+                                       [ 'title' => true, 'returnto' => true, 'returntoquery' => true ]
+                               );
                                $out->wrapWikiMsg(
                                        "<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
                                        [ 'anoneditwarning',
                                                // Log-in link
                                                SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( [
-                                                       'returnto' => $this->getTitle()->getPrefixedDBkey()
+                                                       'returnto' => $this->getTitle()->getPrefixedDBkey(),
+                                                       'returntoquery' => wfArrayToCgi( $returntoquery ),
                                                ] ),
                                                // Sign-up link
                                                SpecialPage::getTitleFor( 'CreateAccount' )->getFullURL( [
-                                                       'returnto' => $this->getTitle()->getPrefixedDBkey()
+                                                       'returnto' => $this->getTitle()->getPrefixedDBkey(),
+                                                       'returntoquery' => wfArrayToCgi( $returntoquery ),
                                                ] )
                                        ]
                                );