Add $conds parameter to ModifyExportDisplayQuery hook

Since I8d825eb02c69cc66d90bd41325133fd3f99f0226, modification of the
$cond parameter to the ModifyExportDisplayQuery hook has had no effect,
since $cond is now incorporated into a condition array $conds. This
seems contrary to the purpose of the hook, although no extension in
CodeSearch actually depends on it.

It was also a documentation error, with the incorrect type on the
interface causing a Phan error in the HookRunner call site migration
patch.

So, add a $conds parameter to the hook, which allows modification of
the array, and fix the documentation.

Change-Id: Id4608cec35df56456d7dad4de107bbef816e964b
This commit is contained in:
Tim Starling 2020-05-04 11:12:44 +10:00
parent 550f5930f2
commit 2bcabb0dee
3 changed files with 15 additions and 5 deletions

View file

@ -2307,9 +2307,14 @@ $mimeMagic: Instance of MimeAnalyzer.
'ModifyExportQuery': Modify the query used by the exporter.
$db: The database object to be queried.
&$tables: Tables in the query.
&$conds: Conditions in the query.
[&]$cond: An SQL fragment included in the WHERE clause which is used to filter
the results, for example to a specific page. Since 1.31, modification of this
parameter has no effect. Since 1.35, you can use $conds instead to modify the
array of conditions passed to IDatabase::select().
&$opts: Options for the query.
&$join_conds: Join conditions for the query.
&$conds: The array of conditions to be passed to IDatabase::select(). Can be
modified. Includes the value of $cond. (Since 1.35)
'MovePageCheckPermissions': Specify whether the user is allowed to move the
page.

View file

@ -16,12 +16,17 @@ interface ModifyExportQueryHook {
*
* @param IDatabase $db Database object to be queried
* @param array &$tables Tables in the query
* @param array &$conds Conditions in the query
* @param string $cond An SQL fragment included in the WHERE clause which is used to filter
* the results, for example to a specific page. Since 1.31, modification of this
* parameter has no effect. Since 1.35, you can use $conds instead to modify the
* array of conditions passed to IDatabase::select().
* @param array &$opts Options for the query
* @param array &$join_conds Join conditions for the query
* @param array &$conds The array of conditions to be passed to IDatabase::select(). Can be
* modified. Includes the value of $cond.
* @return bool|void True or no return value to continue or false to abort
*/
public function onModifyExportQuery( $db, &$tables, &$conds, &$opts,
&$join_conds
public function onModifyExportQuery( $db, &$tables, $cond, &$opts,
&$join_conds, &$conds
);
}

View file

@ -448,7 +448,7 @@ class WikiExporter {
$opts['LIMIT'] = self::BATCH_SIZE;
Hooks::run( 'ModifyExportQuery',
[ $this->db, &$tables, &$cond, &$opts, &$join ] );
[ $this->db, &$tables, &$cond, &$opts, &$join, &$conds ] );
while ( !$done ) {
// If necessary, impose the overall maximum and stop looping after this iteration.