From: jenkins-bot Date: Thu, 5 Jun 2014 21:01:58 +0000 (+0000) Subject: Merge "WikiPage: Allow replaceSection on an nonexistent page" X-Git-Tag: 1.31.0-rc.0~15456 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=62f8720d0c5b6f32d9a3eea6c384e6640f1cd91d;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "WikiPage: Allow replaceSection on an nonexistent page" --- 62f8720d0c5b6f32d9a3eea6c384e6640f1cd91d diff --combined includes/WikiPage.php index d012d7a2a1,1c66ef53f0..db8e104b9c --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@@ -1479,7 -1479,7 +1479,7 @@@ class WikiPage implements Page, IDBAcce * @throws MWException * @return string New complete article text, or null if error. * - * @deprecated since 1.21, use replaceSectionContent() instead + * @deprecated since 1.21, use replaceSectionAtRev() instead */ public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null @@@ -1540,13 -1540,9 +1540,9 @@@ if ( $edittime && $section !== 'new' ) { $dbw = wfGetDB( DB_MASTER ); $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime ); - if ( !$rev ) { - wfDebug( __METHOD__ . " given bad revision time for page " . - $this->getId() . "; edittime: $edittime)\n" ); - wfProfileOut( __METHOD__ ); - return null; + if ( $rev ) { + $baseRevId = $rev->getId(); } - $baseRevId = $rev->getId(); } wfProfileOut( __METHOD__ ); @@@ -1583,12 -1579,12 +1579,12 @@@ if ( is_null( $baseRevId ) || $section == 'new' ) { $oldContent = $this->getContent(); } else { - // TODO: try DB_READ first + // TODO: try DB_SLAVE first $dbw = wfGetDB( DB_MASTER ); $rev = Revision::loadFromId( $dbw, $baseRevId ); if ( !$rev ) { - wfDebug( "WikiPage::replaceSection asked for bogus section (page: " . + wfDebug( __METHOD__ . " asked for bogus section (page: " . $this->getId() . "; section: $section; edittime: $edittime)\n" ); wfProfileOut( __METHOD__ ); return null; @@@ -1603,7 -1599,6 +1599,6 @@@ return null; } - // FIXME: $oldContent might be null? $newContent = $oldContent->replaceSection( $section, $sectionContent, $sectionTitle ); } @@@ -2781,22 -2776,15 +2776,22 @@@ return $status; } + $dbw = wfGetDB( DB_MASTER ); + $dbw->begin( __METHOD__ ); + if ( $id == 0 ) { $this->loadPageData( 'forupdate' ); $id = $this->getID(); if ( $id == 0 ) { + $dbw->rollback( __METHOD__ ); $status->error( 'cannotdelete', wfEscapeWikiText( $this->getTitle()->getPrefixedText() ) ); return $status; } } + // we need to remember the old content so we can use it to generate all deletion updates. + $content = $this->getContent( Revision::RAW ); + // Bitfields to further suppress the content if ( $suppress ) { $bitfield = 0; @@@ -2809,6 -2797,11 +2804,6 @@@ $bitfield = 'rev_deleted'; } - // we need to remember the old content so we can use it to generate all deletion updates. - $content = $this->getContent( Revision::RAW ); - - $dbw = wfGetDB( DB_MASTER ); - $dbw->begin( __METHOD__ ); // For now, shunt the revision data into the archive table. // Text is *not* removed from the text table; bulk storage // is left intact to avoid breaking block-compression or