Avoid key conflict errors in User::addToDatabase
[lhc/web/wiklou.git] / includes / EditPage.php
index 1035ad4..98e0ec4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Page edition user interface.
+ * User interface for page editing.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -797,9 +797,13 @@ class EditPage {
                                // suhosin.request.max_value_length (d'oh)
                                $this->incompleteForm = true;
                        } else {
-                               // edittime should be one of our last fields; if it's missing,
-                               // the submission probably broke somewhere in the middle.
-                               $this->incompleteForm = is_null( $this->edittime );
+                               // If we receive the last parameter of the request, we can fairly
+                               // claim the POST request has not been truncated.
+
+                               // TODO: softened the check for cutover.  Once we determine
+                               // that it is safe, we should complete the transition by
+                               // removing the "edittime" clause.
+                               $this->incompleteForm = ( !$request->getVal( 'wpUltimateParam' ) && is_null( $this->edittime ) );
                        }
                        if ( $this->incompleteForm ) {
                                # If the form is incomplete, force to preview.
@@ -1597,7 +1601,8 @@ class EditPage {
                # Check image redirect
                if ( $this->mTitle->getNamespace() == NS_FILE &&
                        $textbox_content->isRedirect() &&
-                       !$wgUser->isAllowed( 'upload' ) ) {
+                       !$wgUser->isAllowed( 'upload' )
+               ) {
                                $code = $wgUser->isAnon() ? self::AS_IMAGE_REDIRECT_ANON : self::AS_IMAGE_REDIRECT_LOGGED;
                                $status->setResult( false, $code );
 
@@ -1959,7 +1964,7 @@ class EditPage {
                }
 
                // Check for length errors again now that the section is merged in
-                       $this->kblength = (int)( strlen( $this->toEditText( $content ) ) / 1024 );
+               $this->kblength = (int)( strlen( $this->toEditText( $content ) ) / 1024 );
                if ( $this->kblength > $wgMaxArticleSize ) {
                        $this->tooBig = true;
                        $status->setResult( false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED );
@@ -1972,8 +1977,8 @@ class EditPage {
                        ( ( $this->minoredit && !$this->isNew ) ? EDIT_MINOR : 0 ) |
                        ( $bot ? EDIT_FORCE_BOT : 0 );
 
-                       $doEditStatus = $this->mArticle->doEditContent( $content, $this->summary, $flags,
-                                                                                                                       false, null, $this->contentFormat );
+               $doEditStatus = $this->mArticle->doEditContent( $content, $this->summary, $flags,
+                                                                                                               false, null, $this->contentFormat );
 
                if ( !$doEditStatus->isOK() ) {
                        // Failure from doEdit()
@@ -2301,7 +2306,7 @@ class EditPage {
                        if ( $title instanceof Title && $title->exists() && $title->userCan( 'read' ) ) {
                                global $wgOut;
                                // Added using template syntax, to take <noinclude>'s into account.
-                               $wgOut->addWikiTextTitleTidy( '{{:' . $title->getFullText() . '}}', $this->mTitle );
+                               $wgOut->addWikiTextTitleTidy( '<div class="mw-editintro">{{:' . $title->getFullText() . '}}</div>', $this->mTitle );
                                return true;
                        }
                }
@@ -2583,6 +2588,9 @@ class EditPage {
                        }
                }
 
+               // Marker for detecting truncated form data.  This must be the last
+               // parameter sent in order to be of use, so do not move me.
+               $wgOut->addHTML( Html::hidden( 'wpUltimateParam', true ) );
                $wgOut->addHTML( $this->editFormTextBottom . "\n</form>\n" );
 
                if ( !$wgUser->getOption( 'previewontop' ) ) {
@@ -3482,7 +3490,6 @@ HTML
                        if ( $this->mTriedSave && !$this->mTokenOk ) {
                                if ( $this->mTokenOkExceptSuffix ) {
                                        $note = wfMessage( 'token_suffix_mismatch' )->plain();
-
                                } else {
                                        $note = wfMessage( 'session_fail_preview' )->plain();
                                }
@@ -3890,11 +3897,11 @@ HTML
                #$categories = $skin->getCategoryLinks();
 
                $s =
-               '<?xml version="1.0" encoding="UTF-8" ?>' . "\n" .
-               Xml::tags( 'livepreview', null,
-                       Xml::element( 'preview', null, $previewText )
-                       #.      Xml::element( 'category', null, $categories )
-               );
+                       '<?xml version="1.0" encoding="UTF-8" ?>' . "\n" .
+                       Xml::tags( 'livepreview', null,
+                               Xml::element( 'preview', null, $previewText )
+                               #.      Xml::element( 'category', null, $categories )
+                       );
                echo $s;
        }