Merge "Fix some JobQueue IDEA errors"
[lhc/web/wiklou.git] / includes / EditPage.php
index 5ebb44a..482fcc6 100644 (file)
@@ -1420,6 +1420,11 @@ class EditPage {
                        }
                }
 
+               // "wpExtraQueryRedirect" is a hidden input to modify
+               // after save URL and is not used by actual edit form
+               $request = RequestContext::getMain()->getRequest();
+               $extraQueryRedirect = $request->getVal( 'wpExtraQueryRedirect' );
+
                switch ( $status->value ) {
                        case self::AS_HOOK_ERROR_EXPECTED:
                        case self::AS_CONTENT_TOO_BIG:
@@ -1443,6 +1448,13 @@ class EditPage {
 
                        case self::AS_SUCCESS_NEW_ARTICLE:
                                $query = $resultDetails['redirect'] ? 'redirect=no' : '';
+                               if ( $extraQueryRedirect ) {
+                                       if ( $query === '' ) {
+                                               $query = $extraQueryRedirect;
+                                       } else {
+                                               $query = $query . '&' . $extraQueryRedirect;
+                                       }
+                               }
                                $anchor = isset( $resultDetails['sectionanchor'] ) ? $resultDetails['sectionanchor'] : '';
                                $wgOut->redirect( $this->mTitle->getFullURL( $query ) . $anchor );
                                return false;
@@ -1464,6 +1476,14 @@ class EditPage {
                                                $extraQuery = 'redirect=no&' . $extraQuery;
                                        }
                                }
+                               if ( $extraQueryRedirect ) {
+                                       if ( $extraQuery === '' ) {
+                                               $extraQuery = $extraQueryRedirect;
+                                       } else {
+                                               $extraQuery = $extraQuery . '&' . $extraQueryRedirect;
+                                       }
+                               }
+
                                $wgOut->redirect( $this->mTitle->getFullURL( $extraQuery ) . $sectionanchor );
                                return false;
 
@@ -2045,7 +2065,7 @@ class EditPage {
                if ( $changingContentModel ) {
                        $this->addContentModelChangeLogEntry(
                                $wgUser,
-                               $oldContentModel,
+                               $new ? false : $oldContentModel,
                                $this->contentModel,
                                $this->summary
                        );
@@ -2056,12 +2076,13 @@ class EditPage {
 
        /**
         * @param User $user
-        * @param string $oldModel
+        * @param string|false $oldModel false if the page is being newly created
         * @param string $newModel
         * @param string $reason
         */
        protected function addContentModelChangeLogEntry( User $user, $oldModel, $newModel, $reason ) {
-               $log = new ManualLogEntry( 'contentmodel', 'change' );
+               $new = $oldModel === false;
+               $log = new ManualLogEntry( 'contentmodel', $new ? 'new' : 'change' );
                $log->setPerformer( $user );
                $log->setTarget( $this->mTitle );
                $log->setComment( $reason );
@@ -2300,8 +2321,7 @@ class EditPage {
                # Show a warning message when someone creates/edits a user (talk) page but the user does not exist
                # Show log extract when the user is currently blocked
                if ( $namespace == NS_USER || $namespace == NS_USER_TALK ) {
-                       $parts = explode( '/', $this->mTitle->getText(), 2 );
-                       $username = $parts[0];
+                       $username = explode( '/', $this->mTitle->getText(), 2 )[0];
                        $user = User::newFromName( $username, false /* allow IP users*/ );
                        $ip = User::isIP( $username );
                        $block = Block::newFromTarget( $user, $user );
@@ -2520,7 +2540,7 @@ class EditPage {
                        Xml::openElement( 'div', [ 'id' => 'antispam-container', 'style' => 'display: none;' ] )
                        . Html::rawElement(
                                'label',
-                               [ 'for' => 'wpAntiSpam' ],
+                               [ 'for' => 'wpAntispam' ],
                                wfMessage( 'simpleantispam-label' )->parse()
                        )
                        . Xml::element(
@@ -2807,7 +2827,7 @@ class EditPage {
                } elseif ( $wgUser->isAnon() ) {
                        if ( $this->formtype != 'preview' ) {
                                $wgOut->wrapWikiMsg(
-                                       "<div id='mw-anon-edit-warning'>\n$1\n</div>",
+                                       "<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
                                        [ 'anoneditwarning',
                                                // Log-in link
                                                '{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}',