Oops, gotta use $exp here
[lhc/web/wiklou.git] / includes / LogPage.php
index 041d05c..fcc245a 100644 (file)
@@ -20,7 +20,7 @@
 
 /**
  * Contain log classes
- *
+ * @file
  */
 
 /**
@@ -51,18 +51,17 @@ class LogPage {
                $this->updateRecentChanges = $rc;
        }
 
-       function saveContent() {
-               if( wfReadOnly() ) return false;
-
+       protected function saveContent() {
                global $wgUser, $wgLogRestrictions;
                $fname = 'LogPage::saveContent';
 
                $dbw = wfGetDB( DB_MASTER );
-               $uid = $wgUser->getID();
+               $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 );