Manual:Hooks/ApiQueryBaseBeforeQuery

ApiQueryBaseBeforeQuery
Available from version 1.28.0 (Gerrit change 313830)
Called for (some) API query modules before a database query is made.
Define function:
public static function onApiQueryBaseBeforeQuery( $this, &$tables, &$fields, &$where, &$options, &$join_conds, &$hookData ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"ApiQueryBaseBeforeQuery": "MediaWiki\\Extension\\MyExtension\\Hooks::onApiQueryBaseBeforeQuery"
	}
}
Called from: File(s): api/ApiQueryBase.php
Function(s): select
Interface: ApiQueryBaseBeforeQueryHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:ApiQueryBaseBeforeQuery extensions.


Called for (some) API query modules before a database query is made. WARNING: It would be very easy to misuse this hook and break the module! Any joins added *must* join on a unique key of the target table unless you really know what you're doing. An API query module wanting to use this hook should see the ApiQueryBase::select() and ApiQueryBase::processRow() documentation.

Details

edit
  • $module: ApiQueryBase module in question
  • &$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
  • &$hookData: array that will be passed to the ApiQueryBaseAfterQuery ' and ApiQueryBaseProcessRow hooks, intended for inter-hook communication.