From: Aaron Schulz Date: Fri, 9 Jan 2009 18:30:47 +0000 (+0000) Subject: Revert r45605 and generalize the ability to have logs go to UDP. X-Git-Tag: 1.31.0-rc.0~43476 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=9d9ad4dab84019c8e9daf61780e2b399ea98b7d5;p=lhc%2Fweb%2Fwiklou.git Revert r45605 and generalize the ability to have logs go to UDP. --- diff --git a/includes/LogPage.php b/includes/LogPage.php index 3f38301afc..d3016c0523 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -37,7 +37,7 @@ class LogPage { /* @access private */ var $type, $action, $comment, $params, $target, $doer; /* @acess public */ - var $updateRecentChanges; + var $updateRecentChanges, $sendToUDP; /** * Constructor @@ -45,10 +45,12 @@ class LogPage { * @param string $type One of '', 'block', 'protect', 'rights', 'delete', * 'upload', 'move' * @param bool $rc Whether to update recent changes as well as the logging table + * @param bool $udp Whether to send to the UDP feed */ - function __construct( $type, $rc = true ) { + function __construct( $type, $rc = true, $udp = true ) { $this->type = $type; $this->updateRecentChanges = $rc; + $this->sendToUDP = $udp; } protected function saveContent() { @@ -85,6 +87,17 @@ class LogPage { RecentChange::notifyLog( $now, $titleObj, $this->doer, $rcComment, '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId ); } + } else if( $this->sendToUDP ) { + # Notify external application via UDP. + # We send this to IRC but do not want to add it the RC table. + global $wgRC2UDPAddress, $wgRC2UDPOmitBots; + $titleObj = SpecialPage::getTitleFor( 'Log', $this->type ); + $rcComment = $this->getRcComment(); + $rc = RecentChange::newLogEntry( $now, $titleObj, $this->doer, $rcComment, '', + $this->type, $this->action, $this->target, $this->comment, $this->params, $newId ); + if( $wgRC2UDPAddress && ( !$rc->getAttribute('rc_bot') || !$wgRC2UDPOmitBots ) ) { + RecentChange::sendToUDP( $rc->getIRCLine() ); + } } return true; } diff --git a/includes/PatrolLog.php b/includes/PatrolLog.php index 561438e435..3b9a3699fd 100644 --- a/includes/PatrolLog.php +++ b/includes/PatrolLog.php @@ -23,14 +23,8 @@ class PatrolLog { $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) ); if( is_object( $title ) ) { $params = self::buildParams( $rc, $auto ); - $log = new LogPage( 'patrol', false ); # False suppresses RC entries + $log = new LogPage( 'patrol', false, true ); # False suppresses RC entries $log->addEntry( 'patrol', $title, '', $params ); - # Notify external application via UDP. - # We send this to IRC but do not want to add it the RC table. - global $wgRC2UDPAddress, $wgRC2UDPOmitBots; - if( $wgRC2UDPAddress && ( !$rc->getAttribute('rc_bot') || !$wgRC2UDPOmitBots ) ) { - RecentChange::sendToUDP( $rc->getIRCLine() ); - } return true; } return false; diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 5c6bdddc9d..4a8fa8f530 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -475,6 +475,14 @@ class RecentChange public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='', $type, $action, $target, $logComment, $params, $newId=0 ) + { + $rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action, + $target, $logComment, $params, $newId ); + $rc->save(); + } + + public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip='', + $type, $action, $target, $logComment, $params, $newId=0 ) { global $wgRequest; @@ -518,7 +526,7 @@ class RecentChange 'lastTimestamp' => 0, 'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage ); - $rc->save(); + return $rc; } # Initialises the members of this object from a mysql row object