New Hook rc/watchlist hook ChangesListInitRows
authorErik Bernhardson <ebernhardson@wikimedia.org>
Mon, 3 Mar 2014 21:26:54 +0000 (13:26 -0800)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Tue, 1 Apr 2014 16:38:16 +0000 (09:38 -0700)
An extension hooking into recent changes may need to load additional
data that did not fit into the recentchanges table.  This hook gives
extensions an opportunity to see the full result prior to rendering
and batch load where approprite rather than loading piecemeal during
the render process.

This is implemented as an optional method called by the ChangesList
consumer, since the ChangesList never sees the full result set. Hook
implementers must be able to work regardless of the hook being called,
they just have the oportunity to be more efficient when it is called.

Change-Id: If74ae600ffba949364dd381dd3d466cbbaa27286

RELEASE-NOTES-1.23
docs/hooks.txt
includes/changes/ChangesList.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialWatchlist.php

index d99c4fd..393b268 100644 (file)
@@ -137,6 +137,9 @@ production.
 * Changes to content typography (fonts, line-height, etc.). See
   https://www.mediawiki.org/wiki/Typography_refresh for further information.
 * ResourceLoader: mw.loader.using() now implements a Promise interface.
+* Add new hook ChangesListInitRows accessed via ChangesList::initChangesListRows.
+  If called by the ChangesList consumer this gives extensions a chance to batch
+  process the result set prior to rendering.
 
 === Bug fixes in 1.23 ===
 * (bug 41759) The "updated since last visit" markers (on history pages, recent
index 3d1ba7e..ff1d6a1 100644 (file)
@@ -839,6 +839,11 @@ ChangePassword form via the Preferences form.
 $unpatrolled: Whether or not we are showing unpatrolled changes.
 $watched: Whether or not the change is watched by the user.
 
+'ChangesListInitRows': Batch process change list rows prior to rendering.
+$changesList: ChangesList instance
+$rows: The data that will be rendered. May be a ResultWrapper instance or
+  an array.
+
 'Collation::factory': Called if $wgCategoryCollation is an unknown collation.
 $collationName: Name of the collation in question
 &$collationObject: Null. Replace with a subclass of the Collation class that
index ca9efc3..99b60bb 100644 (file)
@@ -173,6 +173,13 @@ class ChangesList extends ContextSource {
                return '<div class="mw-changeslist">';
        }
 
+       /**
+        * @param ResultWrapper|array $rows
+        */
+       public function initChangesListRows( $rows ) {
+               wfRunHooks( 'ChangesListInitRows', array( $this, $rows ) );
+       }
+
        /**
         * Show formatted char difference
         * @param int $old Number of bytes
index 2c563c6..72fa9bc 100644 (file)
@@ -296,6 +296,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                $counter = 1;
                $list = ChangesList::newFromContext( $this->getContext() );
+               $list->initChangesListRows( $rows );
 
                $rclistOutput = $list->beginRecentChangesList();
                foreach ( $rows as $obj ) {
index dd9f262..c1fe21a 100644 (file)
@@ -318,6 +318,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
                $list = ChangesList::newFromContext( $this->getContext() );
                $list->setWatchlistDivs();
+               $list->initChangesListRows( $rows );
+               $dbr->dataSeek( $rows, 0 );
 
                $s = $list->beginRecentChangesList();
                $counter = 1;