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

Change-Id: I28d4e41437e485e518f2a23b6da00cdc430a8c23

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

index 340aa50..4e00d40 100644 (file)
@@ -130,6 +130,8 @@ production.
 * Added BaseTemplateAfterPortlet hook to allow injecting html after portlets in skins.
 * Support has been added for a JSON based localisation file format. The
   installer has been updated to use it.
+* Add new hooks OldChangesListBegin and EnhancedChangesListBegin hooks to allow
+  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 e4037e6..122a89b 100644 (file)
@@ -1112,6 +1112,11 @@ $editToken: The user's edit token.
 &$hookErr: Out-param for the error. Passed as the parameters to
   OutputPage::showErrorPage.
 
+'EnhancedChangesListBegin': to receive the full list of rows to be rendered
+in the enhanced changes list before rendering begings.
+$changesList: EnhancedChangesList object
+$rows: ResultWrapper containing all rows to be rendered
+
 'ExemptFromAccountCreationThrottle': Exemption from the account creation
 throttle.
 $ip: The ip address of the user
@@ -1742,6 +1747,11 @@ displayed.
 &$transform: whether or not to expand variables and templates
   in the message (bool)
 
+'OldChangesListBegin': to receive the full list of rows to be rendered
+in the enhanced changes list before rendering begings.
+$changesList: OldChangesList object
+$rows: array containing all rows to be rendered
+
 'OldChangesListRecentChangesLine': Customize entire recent changes line, or
 return false to omit the line from RecentChanges and Watchlist special pages.
 &$changeslist: The OldChangesList instance.
index ca9efc3..5116901 100644 (file)
@@ -160,9 +160,10 @@ class ChangesList extends ContextSource {
 
        /**
         * Returns text for the start of the tabular part of RC
+        * @param ResultWrapper|array $rows
         * @return string
         */
-       public function beginRecentChangesList() {
+       public function beginRecentChangesList( $rows ) {
                $this->rc_cache = array();
                $this->rcMoveIndex = 0;
                $this->rcCacheIndex = 0;
index feb6d7b..de8bf72 100644 (file)
@@ -59,9 +59,11 @@ class EnhancedChangesList extends ChangesList {
 
        /**
         * Add the JavaScript file for enhanced changeslist
+        *
+        * @param ResultWrapper $res
         * @return string
         */
-       public function beginRecentChangesList() {
+       public function beginRecentChangesList( $res ) {
                $this->rc_cache = array();
                $this->rcMoveIndex = 0;
                $this->rcCacheIndex = 0;
@@ -76,6 +78,8 @@ class EnhancedChangesList extends ChangesList {
                        'mediawiki.icon',
                ) );
 
+               wfRunHooks( 'EnhancedChangesListBegin', array( $this, $res ) );
+
                return '<div class="mw-changeslist">';
        }
 
index 458f21a..d88e99a 100644 (file)
@@ -130,4 +130,15 @@ class OldChangesList extends ChangesList {
 
                return "$dateheader<li class=\"" . implode( ' ', $classes ) . "\">" . $s . "</li>\n";
        }
+
+       /**
+        * Returns text for the start of the tabular part of RC
+        *
+        * @param ResultWrapper $res
+        * @return string
+        */
+       public function beginRecentChangesList( $res ) {
+               wfRunHooks( 'OldChangesListBegin', array( $this, $res ) );
+               return parent::beginRecentChangesList( $res );
+       }
 }
index 720d0a8..885e4cf 100644 (file)
@@ -295,7 +295,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                $counter = 1;
                $list = ChangesList::newFromContext( $this->getContext() );
 
-               $rclistOutput = $list->beginRecentChangesList();
+               $rclistOutput = $list->beginRecentChangesList( $rows );
                foreach ( $rows as $obj ) {
                        if ( $limit == 0 ) {
                                break;
index 4c3f17b..7c3002d 100644 (file)
@@ -317,7 +317,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $list = ChangesList::newFromContext( $this->getContext() );
                $list->setWatchlistDivs();
 
-               $s = $list->beginRecentChangesList();
+               $s = $list->beginRecentChangesList( $rows );
+               $dbr->dataSeek( $rows, 0 );
                $counter = 1;
                foreach ( $rows as $obj ) {
                        # Make RC entry