Index: trunk/extensions/XMLRC/XMLRC.class.php |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | public static function RecentChange_save( $rc ) { |
22 | 22 | global $wgXMLRCTransport, $wgXMLRCProperties; |
23 | 23 | |
24 | | - if ( !empty( $GLOBALS['wgXMLRCTransport'] ) ) { |
| 24 | + if ( $wgXMLRCTransport ) { |
25 | 25 | $xmlrc = new XMLRC( $wgXMLRCTransport, $wgXMLRCProperties ); |
26 | 26 | $xmlrc->processRecentChange( $rc ); |
27 | 27 | } |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | if ( !$prop ) $prop = "title|timestamp|ids"; //default taken from the API |
73 | 73 | |
74 | 74 | if ( is_string( $prop ) ) { |
75 | | - $prop = preg_split( '\\s*[,;/|+]\\s*', $prop ); |
| 75 | + $prop = preg_split( '!\\s*[,;/|+]\\s*!', $prop ); |
76 | 76 | } |
77 | 77 | |
78 | 78 | foreach ( $prop as $k => $v ) { |
— | — | @@ -106,12 +106,12 @@ |
107 | 107 | $row = $rc->getAttributes(); |
108 | 108 | $row = XMLRC::array2object( $row ); |
109 | 109 | |
110 | | - #wfDebug( "XMLRC: got attribute row: " . preg_replace('/\s+/', ' ', var_export($row, true)) . "\n" ); |
| 110 | + #wfDebugLog( "XMLRC", "got attribute row: " . preg_replace('/\s+/', ' ', var_export($row, true)) . "\n" ); |
111 | 111 | |
112 | 112 | $info = $query->extractRowInfo( $row ); |
113 | 113 | $info['wikiid'] = wfWikiID(); |
114 | 114 | |
115 | | - #wfDebug( "XMLRC: got info: " . preg_replace('/\s+/', ' ', var_export($info, true)) . "\n" ); |
| 115 | + #wfDebugLog( "XMLRC", "got info: " . preg_replace('/\s+/', ' ', var_export($info, true)) . "\n" ); |
116 | 116 | |
117 | 117 | $xml = $format->recXmlPrint( "rc", $info, "" ); |
118 | 118 | $xml = trim( $xml ); |
— | — | @@ -120,8 +120,7 @@ |
121 | 121 | } |
122 | 122 | |
123 | 123 | public function sendRecentChangeXML( $xml ) { |
124 | | - if ( !is_string( $xml ) ) wfDebugDieBacktrace( "XMLRC: parameter xml must be a string\n" ); |
125 | | - else wfDebug( "XMLRC: sending xml\n" ); |
| 124 | + wfDebugLog( "XMLRC", "sending xml\n" ); |
126 | 125 | |
127 | 126 | $transport = $this->getTransport(); |
128 | 127 | $transport->send( $xml ); |
Index: trunk/extensions/XMLRC/XMLRC_UDP.class.php |
— | — | @@ -6,34 +6,35 @@ |
7 | 7 | |
8 | 8 | class XMLRC_UDP extends XMLRC_Transport { |
9 | 9 | function __construct( $config ) { |
10 | | - $this->conn = null; |
| 10 | + $this->socket = null; |
11 | 11 | |
12 | 12 | $this->address = isset( $config['address'] ) ? $config['address'] : '127.0.0.1'; |
13 | 13 | $this->port = isset( $config['port'] ) ? $config['port'] : 4455; |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function connect() { |
17 | | - if ( $this->conn ) return; |
| 17 | + if ( $this->socket ) return; |
18 | 18 | |
19 | | - $this->conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); |
20 | | - if ( !$this->handle ) wfDebug("XMLRC_UDP: failed to create UDP socket\n"); |
21 | | - else wfDebug("XMLRC_UDP: created UDP socket\n"); |
| 19 | + $this->socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); |
| 20 | + if ( !$this->socket ) wfDebugLog("XMLRC", "failed to create UDP socket\n"); |
| 21 | + else wfDebugLog("XMLRC", "created UDP socket\n"); |
22 | 22 | } |
23 | 23 | |
24 | 24 | public function disconnect() { |
25 | | - if ( !$this->conn ) return; |
| 25 | + if ( !$this->socket ) return; |
26 | 26 | |
27 | | - socket_close( $this->conn ); |
28 | | - $this->conn = null; |
29 | | - wfDebug("XMLRC_UDP: closed UDP socket\n"); |
| 27 | + socket_close( $this->socket ); |
| 28 | + $this->socket = null; |
| 29 | + wfDebugLog("XMLRC", "closed UDP socket\n"); |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function send( $xml ) { |
33 | | - $do_disconnect = !$this->conn; |
| 33 | + $do_disconnect = !$this->socket; |
34 | 34 | $this->connect(); |
35 | 35 | |
36 | | - $ok = socket_sendto( $this->conn, $xml, strlen($xml), 0, $this->address, $this->port ); |
37 | | - if ( !$ok ) wfDebug("XMLRC_UDP: failed to send UDP packet to {$this->address}:{$this->port}\n"); |
| 36 | + $ok = socket_sendto( $this->socket, $xml, strlen($xml), 0, $this->address, $this->port ); |
| 37 | + if ( $ok ) wfDebugLog("XMLRC", "sent UDP packet to {$this->address}:{$this->port}\n"); |
| 38 | + else wfDebugLog("XMLRC", "failed to send UDP packet to {$this->address}:{$this->port}\n"); |
38 | 39 | |
39 | 40 | if ( $do_disconnect ) $this->disconnect(); |
40 | 41 | } |
Index: trunk/extensions/XMLRC/XMLRC.php |
— | — | @@ -31,36 +31,12 @@ |
32 | 32 | # 'address' => '127.0.0.1', |
33 | 33 | #); |
34 | 34 | |
35 | | -$wgXMLRCProperties = 'user|comment|flags|timestamp|title|ids|sizes|redirect|loginfo'; # sensible default |
| 35 | +$wgXMLRCProperties = 'user|comment|flags|timestamp|title|ids|sizes|redirect|loginfo|tags'; # sensible default |
36 | 36 | # $wgXMLRCProperties = 'title|timestamp|ids'; # default as per the API |
37 | 37 | # $wgXMLRCProperties = 'user|comment|parsedcomment|flags|timestamp|title|ids|sizes|redirect|loginfo|tags'; # everything except "patrolled", which is verboten |
38 | 38 | |
39 | | -/* |
40 | | -$wgXMLRCTransport = array( |
41 | | - 'class' => 'XMLRC_XMPP', |
42 | | - 'channel' => 'recentchanges', |
43 | | - 'nickname' => $wgSitename, |
44 | | - 'host' => 'localhost', |
45 | | - 'port' => 5222, |
46 | | - 'user' => 'mediawiki', |
47 | | - 'server' => 'localhost', |
48 | | - 'resource' => 'recentchanges', |
49 | | - 'password' => 'yourpassword', |
50 | | - 'include_path' => './xmpphp', |
51 | | -); |
52 | | -*/ |
53 | | - |
54 | | -/* |
55 | | -$wgXMLRCTransport = array( |
56 | | - 'class' => 'XMLRC_UDP', |
57 | | - 'address' => 'localhost', |
58 | | - 'port' => 12345, |
59 | | -); |
60 | | -*/ |
61 | | - |
62 | 39 | $wgAutoloadClasses[ 'XMLRC' ] = "$dir/XMLRC.class.php"; |
63 | 40 | $wgAutoloadClasses[ 'XMLRC_Transport' ] = "$dir/XMLRC.class.php"; |
64 | | -$wgAutoloadClasses[ 'XMLRC_XMPP' ] = "$dir/XMLRC_XMPP.class.php"; |
65 | 41 | $wgAutoloadClasses[ 'XMLRC_UDP' ] = "$dir/XMLRC_UDP.class.php"; |
66 | 42 | $wgAutoloadClasses[ 'XMLRC_File' ] = "$dir/XMLRC_File.class.php"; |
67 | 43 | |
Index: trunk/extensions/XMLRC/XMLRC_File.class.php |
— | — | @@ -15,8 +15,8 @@ |
16 | 16 | if ( $this->handle ) return; |
17 | 17 | |
18 | 18 | $this->handle = fopen( $this->file, 'a' ); |
19 | | - if ( !$this->handle ) wfDebug("XMLRC_File: failed to open {$this->file}\n"); |
20 | | - else wfDebug("XMLRC_File: opened {$this->file}\n"); |
| 19 | + if ( !$this->handle ) wfDebugLog("XMLRC", "failed to open {$this->file}\n"); |
| 20 | + else wfDebugLog("XMLRC", "opened {$this->file}\n"); |
21 | 21 | } |
22 | 22 | |
23 | 23 | public function close() { |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | fclose( $this->handle ); |
27 | 27 | $this->handle = null; |
28 | 28 | |
29 | | - wfDebug("XMLRC_File: closed {$this->file}\n"); |
| 29 | + wfDebugLog("XMLRC", "closed {$this->file}\n"); |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function send( $xml ) { |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | |
36 | 36 | $ok = fwrite( $this->handle, $xml . "\n" ); |
37 | 37 | if ( $ok ) $ok = fflush( $this->handle ); |
38 | | - if ( !$ok ) wfDebug("XMLRC_File: failed to write to {$this->file}\n"); |
| 38 | + if ( !$ok ) wfDebugLog("XMLRC", "failed to write to {$this->file}\n"); |
39 | 39 | |
40 | 40 | if ( $do_close ) $this->close(); |
41 | 41 | } |