MediaWiki REL1_39
RedisPubSubFeedEngine.php
Go to the documentation of this file.
1<?php
47
54 public function send( array $feed, $line ) {
55 $parsed = wfParseUrl( $feed['uri'] );
56 $server = $parsed['host'];
57 $options = [ 'serializer' => 'none' ];
58 $channel = 'rc';
59
60 if ( isset( $parsed['port'] ) ) {
61 $server .= ":{$parsed['port']}";
62 }
63 if ( isset( $parsed['query'] ) ) {
64 parse_str( $parsed['query'], $options );
65 }
66 if ( isset( $parsed['pass'] ) ) {
67 $options['password'] = $parsed['pass'];
68 }
69 if ( isset( $parsed['path'] ) ) {
70 $channel = str_replace( '/', '.', ltrim( $parsed['path'], '/' ) );
71 }
72 $pool = RedisConnectionPool::singleton( $options );
73 $conn = $pool->getConnection( $server );
74 if ( $conn !== false ) {
75 $conn->publish( $channel, $line );
76 return true;
77 }
78
79 return false;
80 }
81}
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
Base class for RCFeed implementations that use RCFeedFormatter.
static singleton(array $options)
Send recent change to a Redis Pub/Sub channel.
$line
Definition mcc.php:119