Oops, gotta use $exp here
[lhc/web/wiklou.git] / includes / LogPage.php
index e86aadf..fcc245a 100644 (file)
@@ -20,7 +20,7 @@
 
 /**
  * Contain log classes
- *
+ * @file
  */
 
 /**
@@ -51,18 +51,17 @@ class LogPage {
                $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 ),
@@ -73,8 +72,11 @@ class LogPage {
                        '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!
@@ -85,7 +87,7 @@ class LogPage {
                                        $this->type, $this->action, $this->target, $this->comment, $this->params, $newId );
                        }
                }
-               return ($dbw->affectedRows() > 0);
+               return true;
        }
 
        public function getRcComment() {
@@ -221,8 +223,14 @@ class LogPage {
                                }
                        }
                } 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 );
@@ -237,9 +245,8 @@ class LogPage {
         * @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 );
                }
@@ -251,7 +258,7 @@ class LogPage {
 
                $this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params );
 
-               return $this->saveContent( $dbw );
+               return $this->saveContent();
        }
 
        /**