From 36a664643bd6bcf52052e657ee295f4aa4b07bf5 Mon Sep 17 00:00:00 2001 From: Erik Bernhardson Date: Mon, 3 Mar 2014 13:26:54 -0800 Subject: [PATCH] New Hook rc/watchlist hook ChangesListInitRows 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 | 3 +++ docs/hooks.txt | 5 +++++ includes/changes/ChangesList.php | 7 +++++++ includes/specials/SpecialRecentchanges.php | 1 + includes/specials/SpecialWatchlist.php | 2 ++ 5 files changed, 18 insertions(+) diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index d99c4fd54c..393b2687ee 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -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 diff --git a/docs/hooks.txt b/docs/hooks.txt index 3d1ba7e6d3..ff1d6a18f5 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index ca9efc3934..99b60bbf05 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -173,6 +173,13 @@ class ChangesList extends ContextSource { return '
'; } + /** + * @param ResultWrapper|array $rows + */ + public function initChangesListRows( $rows ) { + wfRunHooks( 'ChangesListInitRows', array( $this, $rows ) ); + } + /** * Show formatted char difference * @param int $old Number of bytes diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 2c563c6199..72fa9bce26 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -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 ) { diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index dd9f2624df..c1fe21ae8d 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -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; -- 2.20.1