* (bug 3816) Throw edit conflict instead of fatal error when a page is
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 28 Oct 2005 07:07:21 +0000 (07:07 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 28 Oct 2005 07:07:21 +0000 (07:07 +0000)
  moved or deleted during section edit

RELEASE-NOTES
includes/Article.php
includes/EditPage.php

index e132b2f..3bfb41b 100644 (file)
@@ -181,7 +181,8 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 3806) Gracefully fall back to client-side scaling on |thumb| image
   that passes $wgMaxImageArea
 * MySQL 5.0 strict mode fix for moving unwatched pages
-
+* (bug 3816) Throw edit conflict instead of fatal error when a page is
+  moved or deleted during section edit
 
 === Caveats ===
 
index 35fb57b..19866f6 100644 (file)
@@ -1111,6 +1111,9 @@ class Article {
                $this->replaceSection( $section, $text, $summary, $edittime );
        }
 
+       /**
+        * @return string Complete article text, or null if error
+        */
        function replaceSection($section, $text, $summary = '', $edittime = NULL) {
                $fname = 'Article::replaceSection';
                wfProfileIn( $fname );
@@ -1122,6 +1125,11 @@ class Article {
                                $dbw =& wfGetDB( DB_MASTER );
                                $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime );
                        }
+                       if( is_null( $rev ) ) {
+                               wfDebug( "Article::replaceSection asked for bogus section (page: " .
+                                       $this->getId() . "; section: $section; edittime: $edittime)\n" );
+                               return null;
+                       }
                        $oldtext = $rev->getText();
 
                        if($section=='new') {
index 87aa4d7..b4bb6fa 100644 (file)
@@ -541,6 +541,11 @@ class EditPage {
                        wfDebug( "EditPage::editForm getting section '$this->section'\n" );
                        $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary);
                }
+               if( is_null( $text ) ) {
+                       wfDebug( "EditPage::editForm activating conflict; section replace failed.\n" );
+                       $this->isConflict = true;
+                       $text = $this->textbox1;
+               }
 
                # Suppress edit conflict with self, except for section edits where merging is required.
                if ( ( $this->section == '' ) && ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {