Page MenuHomePhabricator

PATCH: extension hook for RC notification
Closed, DeclinedPublic

Description

I propose to add an extension hook for RC notification. The current option of
sending UDP packets is not very flexible, and different ways of notification
would sometimes be helpful.

The following functionality is included in the patch:

  • infrastructure for generic RC notification hooks. Each hook can also have

arbitrary, per-instance configuration (port, etc)

  • UDP notification as before
  • Writing notifications to a file (or, more sensibly, to a fifo)
  • Three different formats: human-readable colorized (like is currently done),

plain text, and CSV

It would thus be for instance possible to send notifications to a separate IRC
channel in a format that can be parsed more easily by scripts (I know of at
least two scripts that currently parse the RC channels).

For low-traffic sites, extensions for notification via e-mail, jabber, etc could
be plugged in easily, as opposed to hacking the core code.

patch to follow in a minute


Version: 1.6.x
Severity: enhancement

Details

Reference
bz3670

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 8:52 PM
bzimport set Reference to bz3670.
bzimport added a subscriber: Unknown Object (MLST).

Created attachment 964
patch for DefaultSettings.php, RecentChange.php, and Setup.php - includes compatibility hack

attachment rcHook.diff ignored as obsolete

Created attachment 972
revamped this patch to use wfRunHooks. Moved all notification code into an extension.

This only removes functionality from the main code. A patch containing
extensions to handle rc notifications will follow in a minute.

Attached:

Created attachment 973
extensions to handle rc notification via UDP and plain file output. Patched against a dummy, not CVS.

This provides a base class for hooks (RCHook.php) and two implementations
(RC2UDP.php and RC2File.php) that handle RC-notifications. They can be used
like this:

$wgHooks['RecentChange'][] = new RC2UDP('localhost', 6666,

       array( 'prefix' => $wgSitename . ": ", 
	      'colorize' => true, 
	      'suffix' => "\n" ) );

$wgHooks['RecentChange'][] = new RC2File('/var/log/pub/testwiki.rc',

array( 'csv' => true ) );

The first one would send UDP packets that are compatible with the current UDP
nitification mechanism. The second would fill a file (or fifo) with entries in
CSV format. Other combinations are possible.

attachment rcNotify.diff ignored as obsolete

micklweiss wrote:

RC2Email.php works. //the rc hook for emails

I sent it to Daniel. I'm going to rewrite one part to use UserMailer.php instead
of just using mail() - and perhaps I'll add formatting options.

If you really want this code now (and you aren't picky about how it looks) -
email me.

  • Mick

Created attachment 984
extensions to handle rc notification via UDP and plain file output. Patched against a dummy, not CVS.

removed print_r that was left over from debugging. oops!

Attached:

Security review:

  • Remote code execution: RC2File.php, RC2UDP.php use an undefined variable as the

prefix of a require_once, with no execution guard. Systems with register_globals on
may be seriously compromised through these files.

  • Information disclosure: RC2File.php, RC2UDP.php will show error messages

including local path information if executed via web with display_errors on.

Compatibility review:

  • All files should use full PHP open tags (<?php, not <?) or they won't work on

systems with short tags disabled

Style review:

  • Some instances of "$a= $b" where "$a = $b" is expected
  • "else if" sometimes used where "elseif" is expected
  • Inconsistent parenthesis spacing

Patch fails security review; needs fixing.

No activity in nearly 3 years, closing as WONTFIX.