Merge "allow OldChangesListRecentChangesLine hook to return false and omit line from RC"
authorIAlex <ialex.wiki@gmail.com>
Thu, 27 Dec 2012 13:39:27 +0000 (13:39 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 27 Dec 2012 13:39:27 +0000 (13:39 +0000)
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();