From: Roan Kattouw Date: Mon, 3 Mar 2008 16:40:42 +0000 (+0000) Subject: APIEDIT_VODAFONE BRANCH MERGE: X-Git-Tag: 1.31.0-rc.0~49268 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=ee76103f24cf6722b4cf0f04bb929c341f5c6dad;p=lhc%2Fweb%2Fwiklou.git APIEDIT_VODAFONE BRANCH MERGE: * Adding EditPage::wasDeletedSinceLastEdit() to replace code in EditPage::edit() to avoid duplicating it in internalAttemptSave(). * Adding $wgTitle === null check to showEditForm() as some extensions (like ConfirmEdit) call it. For further explanation see comment. --- diff --git a/includes/EditPage.php b/includes/EditPage.php index f2a73274e3..36424ba9df 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -318,6 +318,25 @@ class EditPage { $this->mArticle->mContent = $t ; $this->mMetaData = $s ; } + + protected function wasDeletedSinceLastEdit() { + /* Note that we rely on the logging table, which hasn't been always there, + * but that doesn't matter, because this only applies to brand new + * deletes. + */ + if ( $this->deletedSinceEdit ) + return true; + if ( $this->mTitle->isDeleted() ) { + $this->lastDelete = $this->getLastDelete(); + if ( !is_null($this->lastDelete) ) { + $deletetime = $this->lastDelete->log_timestamp; + if ( ($deletetime - $this->starttime) > 0 ) { + $this->deletedSinceEdit = true; + } + } + } + return $this->deletedSinceEdit; + } function submit() { $this->edit(); @@ -418,27 +437,6 @@ class EditPage { $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage(); $this->isValidCssJsSubpage = $this->mTitle->isValidCssJsSubpage(); - /* Notice that we can't use isDeleted, because it returns true if article is ever deleted - * no matter it's current state - */ - $this->deletedSinceEdit = false; - if ( $this->edittime != '' ) { - /* Note that we rely on logging table, which hasn't been always there, - * but that doesn't matter, because this only applies to brand new - * deletes. This is done on every preview and save request. Move it further down - * to only perform it on saves - */ - if ( $this->mTitle->isDeleted() ) { - $this->lastDelete = $this->getLastDelete(); - if ( !is_null($this->lastDelete) ) { - $deletetime = $this->lastDelete->log_timestamp; - if ( ($deletetime - $this->starttime) > 0 ) { - $this->deletedSinceEdit = true; - } - } - } - } - # Show applicable editing introductions if( $this->formtype == 'initial' || $this->firsttime ) $this->showIntro(); @@ -797,7 +795,7 @@ class EditPage { # If the article has been deleted while editing, don't save it without # confirmation - if ( $this->deletedSinceEdit && !$this->recreate ) { + if ( $this->wasDeletedSinceLastEdit() && !$this->recreate ) { wfProfileOut( "$fname-checks" ); wfProfileOut( $fname ); return self::AS_ARTICLE_WAS_DELETED; @@ -1009,6 +1007,13 @@ class EditPage { */ function showEditForm( $formCallback=null ) { global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle; + + # If $wgTitle is null, that means we're in API mode. + # Some hook probably called this function without checking + # for is_null($wgTitle) first. Bail out right here so we don't + # do lots of work just to discard it right after. + if(is_null($wgTitle)) + return; $fname = 'EditPage::showEditForm'; wfProfileIn( $fname ); @@ -1273,7 +1278,7 @@ class EditPage { $hidden = ''; $recreate = ''; - if ($this->deletedSinceEdit) { + if ($this->wasDeletedSinceLastEdit()) { if ( 'save' != $this->formtype ) { $wgOut->addWikiMsg('deletedwhileediting'); } else {