* @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
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__ );
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: " .
- $this->getId() . "; section: $section; edittime: $edittime)\n" );
+ wfDebug( __METHOD__ . " asked for bogus section (page: " .
+ $this->getId() . "; section: $section)\n" );
wfProfileOut( __METHOD__ );
return null;
}
return null;
}
- // FIXME: $oldContent might be null?
$newContent = $oldContent->replaceSection( $section, $sectionContent, $sectionTitle );
}
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;
$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
$logEntry->setTarget( $logTitle );
$logEntry->setComment( $reason );
$logid = $logEntry->insert();
- $logEntry->publish( $logid );
+
+ $dbw->onTransactionPreCommitOrIdle( function() use ( $dbw, $logEntry, $logid ) {
+ // Bug 56776: avoid deadlocks (especially from FileDeleteForm)
+ $logEntry->publish( $logid );
+ } );
if ( $commit ) {
$dbw->commit( __METHOD__ );