MediaWiki master
RedisPubSubFeedEngine.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\RCFeed;
8
10
38
45 public function send( array $feed, $line ) {
46 $parsed = wfGetUrlUtils()->parse( $feed['uri'] );
47 // @phan-suppress-next-line PhanTypeArraySuspiciousNullable Valid URL
48 $server = $parsed['host'];
49 $options = [ 'serializer' => 'none' ];
50 $channel = 'rc';
51
52 if ( isset( $parsed['port'] ) ) {
53 $server .= ":{$parsed['port']}";
54 }
55 if ( isset( $parsed['query'] ) ) {
56 parse_str( $parsed['query'], $options );
57 }
58 if ( isset( $parsed['pass'] ) ) {
59 $options['password'] = $parsed['pass'];
60 }
61 if ( isset( $parsed['path'] ) ) {
62 $channel = str_replace( '/', '.', ltrim( $parsed['path'], '/' ) );
63 }
64 $pool = RedisConnectionPool::singleton( $options );
65 $conn = $pool->getConnection( $server );
66 if ( $conn !== false ) {
67 $conn->publish( $channel, $line );
68 return true;
69 }
70
71 return false;
72 }
73}
75class_alias( RedisPubSubFeedEngine::class, 'RedisPubSubFeedEngine' );
wfGetUrlUtils()
Base class for RCFeed implementations that use RCFeedFormatter.
Send recent change to a Redis Pub/Sub channel.
Manage one or more Redis client connection.