Manual:Hooks/ArticlePageDataBefore

From mediawiki.org
ArticlePageDataBefore
Available from version 1.6.0
Executes before data is loaded for the article requested
Define function:
public static function onArticlePageDataBefore( $article, $fields, &$tables, &$joinConds ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"ArticlePageDataBefore": "MediaWiki\\Extension\\MyExtension\\Hooks::onArticlePageDataBefore"
	}
}
Called from: File(s): page/WikiPage.php
Interface: ArticlePageDataBeforeHook.php

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

Details[edit]

  • $article: WikiPage object being requested.
  • $fields: fields to load from the database
  • &$tables: tables (array) to load from the database
  • &$joinConds: join conditions (array) to load from the database

As MediaWiki reads in the page data, this hook allows you to read more data fields related to the same database row than what is specified in WikiPage::selectFields(). You specify more data fields by adding them to $fields parameter. Such data fields can then be manipulated from ArticlePageDataAfter.