From f40dfbc98d4cde03c7b150a0878567269b42a2e5 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 28 Oct 2005 07:07:21 +0000 Subject: [PATCH] * (bug 3816) Throw edit conflict instead of fatal error when a page is moved or deleted during section edit --- RELEASE-NOTES | 3 ++- includes/Article.php | 8 ++++++++ includes/EditPage.php | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e132b2f48f..3bfb41b12e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/Article.php b/includes/Article.php index 35fb57be3c..19866f622d 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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') { diff --git a/includes/EditPage.php b/includes/EditPage.php index 87aa4d7ed9..b4bb6facb1 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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 ) ) { -- 2.20.1