allow OldChangesListRecentChangesLine hook to return false and omit line from RC
authoraude <aude.wiki@gmail.com>
Fri, 9 Nov 2012 16:17:48 +0000 (16:17 +0000)
committeraude <aude.wiki@gmail.com>
Thu, 27 Dec 2012 07:58:01 +0000 (07:58 +0000)
- this enables an extension to do some processing on the RC line,
and if processing fails or for other reason, the extension has the
option to not output the line at all in Special:RecentChanges and
Special:Watchlist.

Change-Id: Ibf3a217afba5b4ad7992919399710fe3da301025

docs/hooks.txt
includes/ChangesList.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialWatchlist.php

index 701c312..994c08c 100644 (file)
@@ -1522,7 +1522,8 @@ displayed
 &$transform: whether or not to expand variables and templates
        in the message (bool)
 
-'OldChangesListRecentChangesLine': Customize entire Recent Changes line.
+'OldChangesListRecentChangesLine': Customize entire Recent Changes line,
+or return false to omit the line from RecentChanges and Watchlist special pages.
 &$changeslist: The OldChangesList instance.
 &$s: HTML of the form "<li>...</li>" containing one RC entry.
 &$rc: The RecentChange object.
index 1d2f362..92cdeea 100644 (file)
@@ -590,7 +590,8 @@ class OldChangesList extends ChangesList {
         * @param $rc RecentChange, passed by reference
         * @param $watched Bool (default false)
         * @param $linenumber Int (default null)
-        * @return string
+        *
+        * @return string|bool
         */
        public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
                global $wgRCShowChangedSize;
@@ -681,7 +682,10 @@ class OldChangesList extends ChangesList {
                        $classes[] = Sanitizer::escapeClass( 'watchlist-'.$rc->mAttribs['rc_namespace'].'-'.$rc->mAttribs['rc_title'] );
                }
 
-               wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
+               if ( !wfRunHooks( 'OldChangesListRecentChangesLine', array( &$this, &$s, $rc ) ) ) {
+                       wfProfileOut( __METHOD__ );
+                       return false;
+               }
 
                wfProfileOut( __METHOD__ );
                return "$dateheader<li class=\"".implode( ' ', $classes )."\">".$s."</li>\n";
index 2984bc7..3977673 100644 (file)
@@ -529,8 +529,12 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                                }
                                $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
                        }
-                       $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
-                       --$limit;
+
+                       $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
+                       if ( $changeLine !== false ) {
+                               $s .= $changeLine;
+                               --$limit;
+                       }
                }
                $s .= $list->endRecentChangesList();
                $this->getOutput()->addHTML( $s );
index 688e0a5..3cfa31f 100644 (file)
@@ -432,7 +432,10 @@ class SpecialWatchlist extends SpecialPage {
                                $rc->numberofWatchingusers = 0;
                        }
 
-                       $s .= $list->recentChangesLine( $rc, $updated, $counter );
+                       $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
+                       if ( $changeLine !== false ) {
+                               $s .= $changeLine;
+                       }
                }
                $s .= $list->endRecentChangesList();