/**
* Contain log classes
- *
+ * @file
*/
/**
$this->updateRecentChanges = $rc;
}
- function saveContent( $dbw ) {
- if( wfReadOnly() ) return false;
-
+ protected function saveContent() {
global $wgUser, $wgLogRestrictions;
$fname = 'LogPage::saveContent';
- $dbw = $dbw ? $dbw : wfGetDB( DB_MASTER );
- $uid = $wgUser->getID();
+ $dbw = wfGetDB( DB_MASTER );
+ $uid = $wgUser->getId();
$log_id = $dbw->nextSequenceValue( 'log_log_id_seq' );
$this->timestamp = $now = wfTimestampNow();
$data = array(
+ 'log_id' => $log_id,
'log_type' => $this->type,
'log_action' => $this->action,
'log_timestamp' => $dbw->timestamp( $now ),
'log_params' => $this->params
);
$dbw->insert( 'logging', $data, $fname );
- $newId = $dbw->insertId();
+ $newId = !is_null($log_id) ? $log_id : $dbw->insertId();
+ if( !($dbw->affectedRows() > 0) ) {
+ wfDebugLog( "logging", "LogPage::saveContent failed to insert row - Error {$dbw->lastErrno()}: {$dbw->lastError()}" );
+ }
# And update recentchanges
if( $this->updateRecentChanges ) {
# Don't add private logs to RC!
$this->type, $this->action, $this->target, $this->comment, $this->params, $newId );
}
}
- return ($dbw->affectedRows() > 0);
+ return true;
}
public function getRcComment() {
}
}
} else {
- wfDebug( "LogPage::actionText - unknown action $key\n" );
- $rv = "$action";
+ global $wgLogActionsHandlers;
+ if( isset( $wgLogActionsHandlers[$key] ) ) {
+ $args = func_get_args();
+ $rv = call_user_func_array( $wgLogActionsHandlers[$key], $args );
+ } else {
+ wfDebug( "LogPage::actionText - unknown action $key\n" );
+ $rv = "$action";
+ }
}
if( $filterWikilinks ) {
$rv = str_replace( "[[", "", $rv );
* @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(), $dbw = NULL ) {
+ function addEntry( $action, $target, $comment, $params = array() ) {
if ( !is_array( $params ) ) {
$params = array( $params );
}
$this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params );
- return $this->saveContent( $dbw );
+ return $this->saveContent();
}
/**