From: Bartosz Dziewoński Date: Wed, 8 Jan 2014 17:17:08 +0000 (+0100) Subject: ChangesListSpecialPage: Implement two new hooks superseding 4 old ones X-Git-Tag: 1.31.0-rc.0~16230^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=a4aa71c6cf7eba2322139312ad8353f1c318c06f;p=lhc%2Fweb%2Fwiklou.git ChangesListSpecialPage: Implement two new hooks superseding 4 old ones Old hooks (called by SpecialWatchlist, SpecialRecentChanges and SpecialRecentChangesLinked) have been deprecated, but I'm not planning to remove them anytime soon. (They have lots of usages in extensions as of this writing.) The new hooks (and their deprecated friends) are: * ChangesListSpecialPageFilters: * Replaces: SpecialRecentChangesFilters and SpecialWatchlistFilters * The signature for this one is exactly the same as signatures for the other two. We might want to pass something else than $this here… * ChangesListSpecialPageQuery * Replaces: SpecialRecentChangesQuery and SpecialWatchlistQuery * These hooks have wildly different signatures. The new one is a superset of the old ones, in a more reasonable order, with the addition of the name of the special page we're doing right now. Change-Id: I9cceda5d2dcfc53c852c5682c466b48ad8f31202 --- diff --git a/docs/hooks.txt b/docs/hooks.txt index ff1d6a18f5..a9bc736052 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -844,6 +844,21 @@ $changesList: ChangesList instance $rows: The data that will be rendered. May be a ResultWrapper instance or an array. +'ChangesListSpecialPageFilters': Called after building form options on pages inheriting from ChangesListSpecialPage (in core: RecentChanges, RecentChangesLinked and Watchlist). +$special: ChangesListSpecialPage instance +&$filters: associative array of filter definitions. The keys are the HTML + name/URL parameters. Each key maps to an associative array with a 'msg' + (message key) and a 'default' value. + +'ChangesListSpecialPageQuery': Called when building SQL query on pages inheriting from ChangesListSpecialPage (in core: RecentChanges, RecentChangesLinked and Watchlist). +$name: name of the special page, e.g. 'Watchlist' +&$tables: array of tables to be queried +&$fields: array of columns to select +&$conds: array of WHERE conditionals for query +&$query_options: array of options for the database request +&$join_conds: join conditions for the tables +$opts: FormOptions for this request + '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 @@ -2369,7 +2384,7 @@ use this to change some selection criteria or substitute a different title. result from the normal query 'SpecialRecentChangesFilters': Called after building form options at -RecentChanges. +RecentChanges. Deprecated, use ChangesListSpecialPageFilters instead. $special: the special page object &$filters: associative array of filter definitions. The keys are the HTML name/URL parameters. Each key maps to an associative array with a 'msg' @@ -2381,7 +2396,8 @@ SpecialRecentChanges. $opts: FormOptions for this request 'SpecialRecentChangesQuery': Called when building SQL query for -SpecialRecentChanges and SpecialRecentChangesLinked. +SpecialRecentChanges and SpecialRecentChangesLinked. Deprecated, use +ChangesListSpecialPageQuery instead. &$conds: array of WHERE conditionals for query &$tables: array of tables to be queried &$join_conds: join conditions for the tables @@ -2471,12 +2487,14 @@ $wgVersion: Current $wgVersion for you to use &$versionUrl: Raw url to link to (eg: release notes) 'SpecialWatchlistFilters': Called after building form options at Watchlist. +Deprecated, use ChangesListSpecialPageFilters instead. $special: the special page object &$filters: associative array of filter definitions. The keys are the HTML name/URL parameters. Each key maps to an associative array with a 'msg' (message key) and a 'default' value. 'SpecialWatchlistQuery': Called when building sql query for SpecialWatchlist. +Deprecated, use ChangesListSpecialPageQuery instead. &$conds: array of WHERE conditionals for query &$tables: array of tables to be queried &$join_conds: join conditions for the tables diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 14ac401d2a..bc0b8ff26b 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -151,8 +151,12 @@ abstract class ChangesListSpecialPage extends SpecialPage { * @return array Map of filter URL param names to properties (msg/default) */ protected function getCustomFilters() { - // @todo Fire a Special{$this->getName()}Filters hook here - return array(); + if ( $this->customFilters === null ) { + $this->customFilters = array(); + wfRunHooks( 'ChangesListSpecialPageFilters', array( $this, &$this->customFilters ) ); + } + + return $this->customFilters; } /** @@ -286,13 +290,11 @@ abstract class ChangesListSpecialPage extends SpecialPage { '' ); - // @todo Fire a Special{$this->getName()}Query hook here - // @todo Uncomment and document - // if ( !wfRunHooks( 'ChangesListSpecialPageQuery', - // array( &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) ) - // ) { - // return false; - // } + if ( !wfRunHooks( 'ChangesListSpecialPageQuery', + array( $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) ) + ) { + return false; + } $dbr = $this->getDB(); diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 72fa9bce26..f1a31a5925 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -94,8 +94,8 @@ class SpecialRecentChanges extends ChangesListSpecialPage { */ protected function getCustomFilters() { if ( $this->customFilters === null ) { - $this->customFilters = array(); - wfRunHooks( 'SpecialRecentChangesFilters', array( $this, &$this->customFilters ) ); + $this->customFilters = parent::getCustomFilters(); + wfRunHooks( 'SpecialRecentChangesFilters', array( $this, &$this->customFilters ), '1.23' ); } return $this->customFilters; @@ -230,7 +230,8 @@ class SpecialRecentChanges extends ChangesListSpecialPage { ); if ( !wfRunHooks( 'SpecialRecentChangesQuery', - array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ) ) + array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ), + '1.23' ) ) { return false; } diff --git a/includes/specials/SpecialRecentchangeslinked.php b/includes/specials/SpecialRecentchangeslinked.php index 526e949a35..e73cabce79 100644 --- a/includes/specials/SpecialRecentchangeslinked.php +++ b/includes/specials/SpecialRecentchangeslinked.php @@ -110,7 +110,8 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { ); if ( !wfRunHooks( 'SpecialRecentChangesQuery', - array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$select ) ) + array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$select ), + '1.23' ) ) { return false; } diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index c1fe21ae8d..1345b76345 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -107,8 +107,8 @@ class SpecialWatchlist extends ChangesListSpecialPage { */ protected function getCustomFilters() { if ( $this->customFilters === null ) { - $this->customFilters = array(); - wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) ); + $this->customFilters = parent::getCustomFilters(); + wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ), '1.23' ); } return $this->customFilters; @@ -258,7 +258,8 @@ class SpecialWatchlist extends ChangesListSpecialPage { ); wfRunHooks( 'SpecialWatchlistQuery', - array( &$conds, &$tables, &$join_conds, &$fields, $opts ) ); + array( &$conds, &$tables, &$join_conds, &$fields, $opts ), + '1.23' ); return $dbr->select( $tables,