Jump to content

Wikia code/includes/RecentChange.php

From mediawiki.org
--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\RecentChange.php	2011-07-18 22:31:28.016601600 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\RecentChange.php	2011-08-17 15:28:46.379882800 +0100
@@ -135,6 +135,7 @@
 	# Writes the data in this object to the database
 	public function save() {
 		global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPOmitBots;
+		global $wgRC2UDPPort, $wgRC2UDPPrefix, $wgRC2UDPEnabled;
 		$fname = 'RecentChange::save';
 
 		$dbw = wfGetDB( DB_MASTER );
@@ -162,6 +163,11 @@
 			unset( $this->mAttribs['rc_cur_id'] );
 		}
 
+		/* Wikia change begin - @author: Macbre */
+		/* Wysiwyg: add extra data before row is added */
+		wfRunHooks( 'RecentChange_beforeSave', array( &$this ) );
+		/* Wikia change end */
+
 		# Insert new row
 		$dbw->insert( 'recentchanges', $this->mAttribs, $fname );
 
@@ -172,7 +178,7 @@
 		wfRunHooks( 'RecentChange_save', array( &$this ) );
 
 		# Notify external application via UDP
-		if( $wgRC2UDPAddress && ( !$this->mAttribs['rc_bot'] || !$wgRC2UDPOmitBots ) ) {
+		if( $wgRC2UDPEnabled && $wgRC2UDPAddress && ( !$this->mAttribs['rc_bot'] || !$wgRC2UDPOmitBots ) ) {
 			self::sendToUDP( $this->getIRCLine() );
 		}
 
@@ -195,8 +201,27 @@
 				$this->mAttribs['rc_timestamp'],
 				$this->mAttribs['rc_comment'],
 				$this->mAttribs['rc_minor'],
-				$this->mAttribs['rc_last_oldid'] );
+				$this->mAttribs['rc_last_oldid'],
+				$this->mAttribs['rc_log_action'] );
+		}
+
+		// temporary code begin /Inez
+		if($this->mAttribs['rc_type'] == RC_NEW) {
+			$eventType = 'new';
+		} else if($this->mAttribs['rc_type'] == RC_EDIT) {
+			$eventType = 'edit';
+		} else if($this->mAttribs['rc_type'] == RC_LOG && $this->mAttribs['rc_namespace'] == NS_IMAGE) {
+			$eventType = 'upload';
+		}
+		if(!empty($eventType)) {
+			global $wgMemc;
+			$key = $eventType.gmdate('Ymd_Hi00');
+			$ret = $wgMemc->incr($key);
+			if(empty($ret)) {
+				$wgMemc->set($key, 1, 60*5);
+			}
 		}
+		// temporary code end
 	}
 	
 	public function notifyRC2UDP() {
@@ -623,7 +648,7 @@
 		$title = self::cleanupForIRC( $title );
 
 		if( $rc_type == RC_LOG ) {
-			$url = '';
+			$url = $titleObj->getInternalURL(); # modified per trac #1831
 		} else {
 			if( $rc_type == RC_NEW ) {
 				$url = "oldid=$rc_this_oldid";