Maximum article size, since max_allowed_packet is too large on wikimedia these days...
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 22 Feb 2006 00:55:25 +0000 (00:55 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 22 Feb 2006 00:55:25 +0000 (00:55 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/EditPage.php
languages/Messages.php

index b435f02..582a9d8 100644 (file)
@@ -137,6 +137,7 @@ Maintenance:
 * Maintenance script to wipe a page and all revisions from the database
 * Maintenance script to reassign edits from one user to another
 * Maintenance script to find and remove links to a given domain (cleanupSpam.php)
+* Fix --report interval option for dumpTextPass
 
 i18n / Languages:
 * Partial support for Basque language (from wikipedia and meta)
@@ -643,8 +644,8 @@ fully support the editing toolbar, but was found to be too confusing.
 * Fix explicit s-maxage=0 on raw pages; should help with proxy issues in
   generated stylesheets... hopefully...
 * (bug 4685) More fixes for Slovenian project namespace
-* Fix --report interval option for dumpTextPass
 * Fixed and enhanced a little the Live Preview, which had been broken for some time
+* Added article size limit, $wgMaxArticleSize
 
 
 === Caveats ===
index a11d082..9d52656 100644 (file)
@@ -683,6 +683,7 @@ $wgRedirectSources = false;
 
 $wgShowIPinHeader      = true; # For non-logged in users
 $wgMaxNameChars                = 255;  # Maximum number of bytes in username
+$wgMaxArticleSize      = 2048; # Maximum article size in kilobytes
 
 $wgExtraSubtitle       = '';
 $wgSiteSupportPage     = ''; # A page where you users can receive donations
index f90e135..1aad75f 100644 (file)
@@ -24,6 +24,8 @@ class EditPage {
        var $firsttime;
        var $lastDelete;
        var $mTokenOk = true;
+       var $tooBig = false;
+       var $kblength = false;
 
        # Form values
        var $save = false, $preview = false, $diff = false;
@@ -451,6 +453,7 @@ class EditPage {
         */
        function attemptSave() {
                global $wgSpamRegex, $wgFilterCallback, $wgUser, $wgOut;
+               global $wgMaxArticleSize;
 
                $fname = 'EditPage::attemptSave';
                wfProfileIn( $fname );
@@ -486,7 +489,15 @@ class EditPage {
                        wfProfileOut( $fname );
                        return false;
                }
-
+               $this->kblength = (int)(strlen( $this->textbox1 ) / 1024);
+               if ( $this->kblength > $wgMaxArticleSize ) {
+                       // Error will be displayed by showEditForm()
+                       $this->tooBig = true;
+                       wfProfileOut( "$fname-checks" );
+                       wfProfileOut( $fname );
+                       return true;
+               }
+               
                if ( !$wgUser->isAllowed('edit') ) {
                        if ( $wgUser->isAnon() ) {
                                $this->userNotLoggedInPage();
@@ -641,6 +652,14 @@ class EditPage {
                $this->textbox1 = $text;
                $this->section = '';
 
+               // Check for length errors again now that the section is merged in
+               $this->kblength = (int)(strlen( $text ) / 1024);
+               if ( $this->kblength > $wgMaxArticleSize ) {
+                       $this->tooBig = true;
+                       wfProfileOut( $fname );
+                       return true;
+               }
+
                # update the article here
                if( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
                        $this->watchthis, '', $sectionanchor ) ) {
@@ -673,7 +692,7 @@ class EditPage {
         *                      near the top, for captchas and the like.
         */
        function showEditForm( $formCallback=null ) {
-               global $wgOut, $wgUser, $wgLang, $wgContLang;
+               global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize;
 
                $fname = 'EditPage::showEditForm';
                wfProfileIn( $fname );
@@ -745,10 +764,14 @@ class EditPage {
                        }
                        $wgOut->addWikiText( $notice );
                }
-               
-               $kblength = (int)(strlen( $this->textbox1 ) / 1024);
-               if( $kblength > 29 ) {
-                       $wgOut->addWikiText( wfMsg( 'longpagewarning', $wgLang->formatNum( $kblength ) ) );
+
+               if ( $this->kblength === false ) {
+                       $this->kblength = (int)(strlen( $this->textbox1 ) / 1024);
+               }
+               if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
+                       $wgOut->addWikiText( wfMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgMaxArticleSize ) );
+               } elseif( $this->kblength > 29 ) {
+                       $wgOut->addWikiText( wfMsg( 'longpagewarning', $wgLang->formatNum( $this->kblength ) ) );
                }
 
                $rows = $wgUser->getOption( 'rows' );
index cd0e872..e9a810c 100644 (file)
@@ -523,6 +523,8 @@ public domain or similar free resource (see $1 for details).
 'longpagewarning' => "<strong>WARNING: This page is $1 kilobytes long; some
 browsers may have problems editing pages approaching or longer than 32kb.
 Please consider breaking the page into smaller sections.</strong>",
+'longpageerror' => "<strong>ERROR: The text you have submitted is $1 kilobytes 
+long, which is longer than the maximum of $2 kilobytes. It cannot be saved.</strong>",
 'readonlywarning' => '<strong>WARNING: The database has been locked for maintenance,
 so you will not be able to save your edits right now. You may wish to cut-n-paste
 the text into a text file and save it for later.</strong>',