# Update the protection log
$log = new LogPage( 'protect' );
-
-
-
if( $protect ) {
$log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle, trim( $reason . " [$updated]$cascade_description$expiry_description" ) );
} else {
$bitfield = 'rev_deleted';
}
+ $dbw->begin();
// 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
# Now that it's safely backed up, delete it
$dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__);
+ $ok = ( $dbw->affectedRows() > 0 ); // getArticleId() uses slave, could be laggy
+ if( !$ok ) {
+ $dbw->rollback();
+ return false;
+ }
# If using cascading deletes, we can skip some explicit deletes
if ( !$dbw->cascadingDeletes() ) {
# Log the deletion, if the page was suppressed, log it at Oversight instead
$logtype = $suppress ? 'suppress' : 'delete';
$log = new LogPage( $logtype );
- $log->addEntry( 'delete', $this->mTitle, $reason );
+ # Make sure logging got through
+ $ok = $log->addEntry( 'delete', $this->mTitle, $reason, array(), $dbw );
+ if( !$ok ) {
+ $dbw->rollback();
+ return false;
+ }
+ $dbw->commit();
return true;
}
/**
* Insert a block into the block table.
- *@return Whether or not the insertion was successful.
+ * @param Database $dbw, optional
+ * @return Whether or not the insertion was successful.
*/
- function insert()
+ function insert( $dbw = NULL)
{
wfDebug( "Block::insert; timestamp {$this->mTimestamp}\n" );
- $dbw = wfGetDB( DB_MASTER );
+ $dbw = $dbw ? $dbw : wfGetDB( DB_MASTER );
# Unset ipb_anon_only for user blocks, makes no sense
if ( $this->mUser ) {
), 'Block::insert', array( 'IGNORE' )
);
$affected = $dbw->affectedRows();
- $dbw->commit();
if ($affected)
$this->doRetroactiveAutoblock();
$this->updateRecentChanges = $rc;
}
- function saveContent() {
+ function saveContent( $dbw ) {
if( wfReadOnly() ) return false;
global $wgUser, $wgLogRestrictions;
$fname = 'LogPage::saveContent';
- $dbw = wfGetDB( DB_MASTER );
+ $dbw = $dbw ? $dbw : wfGetDB( DB_MASTER );
$uid = $wgUser->getID();
$log_id = $dbw->nextSequenceValue( 'log_log_id_seq' );
* @param object &$target A title object.
* @param string $comment Description associated
* @param array $params Parameters passed later to wfMsg.* functions
+ * @param Database $dbw, optional
*/
- function addEntry( $action, $target, $comment, $params = array() ) {
+ function addEntry( $action, $target, $comment, $params = array(), $dbw = NULL ) {
if ( !is_array( $params ) ) {
$params = array( $params );
}
$this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params );
- return $this->saveContent();
+ return $this->saveContent( $dbw );
}
/**
$this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName,
$this->BlockEmail);
- if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) {
-
- if ( !$block->insert() ) {
+ if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) {
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->begin();
+ if ( !$block->insert( $dbw ) ) {
+ $dbw->rollback(); // this could be commit as well; zero rows either way
return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress));
}
- wfRunHooks('BlockIpComplete', array($block, $wgUser));
-
# Prepare log parameters
$logParams = array();
$logParams[] = $expirestr;
# Make log entry, if the name is hidden, put it in the oversight log
$log_type = ($this->BlockHideName) ? 'suppress' : 'block';
$log = new LogPage( $log_type );
- $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ),
+ $ok = $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ),
$reasonstr, $logParams );
-
+ # Make sure logging got through
+ if( !$ok ) {
+ $dbw->rollback();
+ return array('databaseerror');
+ }
+ $dbw->commit();
+ wfRunHooks('BlockIpComplete', array($block, $wgUser));
# Report to the user
return array();
- }
- else
+ } else {
return array('hookaborted');
+ }
}
/**