r70866 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70865‎ | r70866 | r70867 >
Date:10:43, 11 August 2010
Author:daniel
Status:deferred
Tags:
Comment:
smoothed out config vars
Modified paths:
  • /trunk/extensions/XMLRC/XMLRC.class.php (modified) (history)
  • /trunk/extensions/XMLRC/XMLRC.php (modified) (history)
  • /trunk/extensions/XMLRC/XMLRC_UDP.class.php (modified) (history)
  • /trunk/extensions/XMLRC/bridge/udp2xmpp.py (modified) (history)

Diff [purge]

Index: trunk/extensions/XMLRC/XMLRC.class.php
@@ -9,16 +9,22 @@
1010 var $query;
1111 var $format;
1212 var $transport;
 13+ var $filter;
 14+ var $props;
1315
14 - public function __construct() {
15 - $this->transportConfig = $GLOBALS['wgXMLRCTransport'];
16 - $this->filter = @$GLOBALS['wgXMLRCFilter'];
 16+ public function __construct( $transportConfig, $props = null ) {
 17+ $this->transportConfig = $transportConfig;
 18+ $this->props = $props;
1719 }
1820
1921 public static function RecentChange_save( $rc ) {
20 - $xmlrc = new XMLRC();
21 - $xmlrc->processRecentChange( $rc );
 22+ global $wgXMLRCTransport, $wgXMLRCProperties;
2223
 24+ if ( !empty( $GLOBALS['wgXMLRCTransport'] ) ) {
 25+ $xmlrc = new XMLRC( $wgXMLRCTransport, $wgXMLRCProperties );
 26+ $xmlrc->processRecentChange( $rc );
 27+ }
 28+
2329 return true; //continue processing normally
2430 }
2531
@@ -60,19 +66,23 @@
6167 $main = $this->getMainModule();
6268 $this->query = new ApiQueryRecentChanges( $main, "recentchanges" );
6369
64 - //TODO: configure!
65 - $prop['comment'] = true;
66 - $prop['user'] = true;
67 - $prop['flags'] = true;
68 - $prop['timestamp'] = true;
69 - $prop['title'] = true;
70 - $prop['ids'] = true;
71 - $prop['sizes'] = true;
72 - $prop['redirect'] = true;
73 - $prop['patrolled'] = true;
74 - $prop['loginfo'] = true;
75 - $prop['tags'] = true;
 70+ $prop = $this->props;
7671
 72+ if ( !$prop ) $prop = "title|timestamp|ids"; //default taken from the API
 73+
 74+ if ( is_string( $prop ) ) {
 75+ $prop = preg_split( '\\s*[,;/|+]\\s*', $prop );
 76+ }
 77+
 78+ foreach ( $prop as $k => $v ) {
 79+ if ( is_int( $k ) ) {
 80+ unset( $prop[ $k ] );
 81+ $prop[ $v ] = true;
 82+ }
 83+ }
 84+
 85+ unset( $prop[ 'patrolled' ] ); //restricted info, don't publish. API denies it.
 86+
7787 $this->query->initProperties( $prop );
7888
7989 return $this->query;
Index: trunk/extensions/XMLRC/XMLRC_UDP.class.php
@@ -8,7 +8,7 @@
99 function __construct( $config ) {
1010 $this->conn = null;
1111
12 - $this->address = $config['address'];
 12+ $this->address = isset( $config['address'] ) ? $config['address'] : '127.0.0.1';
1313 $this->port = isset( $config['port'] ) ? $config['port'] : 4455;
1414 }
1515
Index: trunk/extensions/XMLRC/XMLRC.php
@@ -18,11 +18,23 @@
1919 $dir = dirname(__FILE__) . '/';
2020 $wgExtensionMessagesFiles['XMLRC'] = $dir . 'XMLRC.i18n.php';
2121
22 -$wgXMLRCTransport = array(
23 - 'class' => 'XMLRC_File',
24 - 'file' => '/tmp/rc.xml',
25 -);
 22+$wgXMLRCTransport = null;
2623
 24+#$wgXMLRCTransport = array(
 25+# 'class' => 'XMLRC_File',
 26+# 'file' => '/tmp/rc.xml',
 27+#);
 28+
 29+#$wgXMLRCTransport = array(
 30+# 'class' => 'XMLRC_UDP',
 31+# 'port' => 4455,
 32+# 'address' => '127.0.0.1',
 33+#);
 34+
 35+$wgXMLRCProperties = 'user|comment|flags|timestamp|title|ids|sizes|redirect|loginfo'; # sensible default
 36+# $wgXMLRCProperties = 'title|timestamp|ids'; # default as per the API
 37+# $wgXMLRCProperties = 'user|comment|parsedcomment|flags|timestamp|title|ids|sizes|redirect|loginfo|tags'; # everything except "patrolled", which is verboten
 38+
2739 /*
2840 $wgXMLRCTransport = array(
2941 'class' => 'XMLRC_XMPP',
Index: trunk/extensions/XMLRC/bridge/udp2xmpp.py
@@ -71,8 +71,6 @@
7272 self.loglevel = LOG_VERBOSE
7373 self.wiki_info = wiki_info;
7474
75 - #FIXME: test unicode!
76 -
7775 def warn(self, message):
7876 if self.loglevel >= LOG_QUIET:
7977 sys.stderr.write( "WARNING: %s\n" % ( message.encode( self.console_encoding ) ) )

Status & tagging log