Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\RepoHooks Class Reference

File defining the hook handlers for the Wikibase extension. More...

Inheritance diagram for Wikibase\Repo\RepoHooks:
Collaboration diagram for Wikibase\Repo\RepoHooks:

Public Member Functions

 onBeforeDisplayNoArticleText ( $article)
 We implement this solely to replace the standard message that is shown when an entity does not exists.
 onBeforePageDisplay ( $out, $skin)
 Handler for the BeforePageDisplay hook, that conditionally adds the wikibase mobile styles and injects the wikibase.ui.entitysearch module replacing the native search box with the entity selector widget.
 onMediaWikiServices ( $services)
 Handler for the MediaWikiServices hook, completing the content and namespace setup.
 onUnitTestsList (&$paths)
 onNamespaceIsMovable ( $ns, &$movable)
 onRevisionFromEditComplete ( $wikiPage, $rev, $originalRevId, $user, &$tags)
 onGetPreferences ( $user, &$preferences)
 NOTE: Might make sense to put the inner functionality into a well structured Preferences file once this becomes more.
 onPageHistoryLineEnding ( $historyAction, &$row, &$s, &$classes, &$attribs)
 onSkinTemplateNavigation__Universal ( $sktemplate, &$links)
 onOutputPageBodyAttributes ( $out, $sk, &$bodyAttrs)
 Used to append a css class to the body, so the page can be identified as Wikibase item page.
 onTitleGetRestrictionTypes ( $title, &$types)
 Implemented to prevent people from protecting pages from being created or moved in an entity namespace (which is pointless).
 onAbuseFilter_contentToString (Content $content, ?string &$text)
 Hook handler for AbuseFilter's AbuseFilter-contentToString hook, implemented to provide a custom text representation of Entities for filtering.
 onFormatAutocomments (&$comment, $pre, $auto, $post, $title, $local, $wiki)
 Handler for the FormatAutocomments hook, implementing localized formatting for machine readable autocomments generated by SummaryFormatter.
 onOutputPageParserOutput ( $outputPage, $parserOutput)
 Used to transfer 'wikibase-view-chunks' and entity data from ParserOutput to OutputPage.
 onContentModelCanBeUsedOn ( $contentModel, $title, &$ok)
 Handler for the ContentModelCanBeUsedOn hook, used to prevent pages of inappropriate type to be placed in an entity namespace.
 onAPIQuerySiteInfoGeneralInfo ( $module, &$results)
 Exposes configuration values to the action=query&meta=siteinfo API, including lists of property and data value types, sparql endpoint, and several base URLs and URIs.
 onImportHandleRevisionXMLTag ( $reader, $pageInfo, $revisionInfo)
 Called by Import.php.
 onResourceLoaderRegisterModules ( $rl)
 onInfoAction ( $context, &$pageInfo)
 Adds the Wikis using the entity in action=info.
 onParserOptionsRegister (&$defaults, &$inCacheKey, &$lazyLoad)
 Handler for the ParserOptionsRegister hook to add a "wb" option for cache-splitting.
 onApiQuery__moduleManager ( $moduleManager)
 onApiMain__moduleManager ( $moduleManager)
 onParserFirstCallInit ( $parser)
 onApiMain__onException ( $apiMain, $e)
 Attempt to create an entity locks an entity id (for items, it would be Q####) and if saving fails due to validation issues for example, that id would be wasted.
 onWikibaseContentLanguages (&$contentLanguages)
 onMaintenanceShellStart ()
 onVectorSearchResourceLoaderConfig (array &$vectorSearchConfig)
 Handler for the VectorSearchResourceLoaderConfig hook to overwrite search pattern highlighting for wikibase.
 onSkinPageReadyConfig (Context $context, array &$config)
Public Member Functions inherited from Wikibase\Lib\Hooks\WikibaseContentLanguagesHook
 onWikibaseContentLanguages (array &$contentLanguages)
 This hook is called to define the content languages per context.

Static Public Member Functions

static onUserGetDefaultOptions (array &$defaultOptions)
 Called after fetching the core default user options.
static onRegistration ()
static inheritDefaultRateLimits (array &$rateLimits)
 Make the 'wikibase-idgenerator' rate limit inherit the 'create' rate limit, or the 'edit' rate limit if no 'create' limit is defined, unless the 'wikibase-idgenerator' rate limit was itself customized.

Static Private Member Functions

static defaultEntityNamespaces ()
 PhanUndeclaredConstant.
static ensureConstant (string $name, int $value)
 Ensure that a constant is set to a certain (integer) value, defining it or checking its value if it was already defined.
static isNamespaceUsedByLocalEntities (int $namespace)
static notifyEntityStoreWatcherOnUpdate (EntityContent $content, RevisionRecord $revision)

Detailed Description

File defining the hook handlers for the Wikibase extension.

Member Function Documentation

◆ defaultEntityNamespaces()

Wikibase\Repo\RepoHooks::defaultEntityNamespaces ( )
staticprivate

PhanUndeclaredConstant.

◆ ensureConstant()

Wikibase\Repo\RepoHooks::ensureConstant ( string $name,
int $value )
staticprivate

Ensure that a constant is set to a certain (integer) value, defining it or checking its value if it was already defined.

◆ inheritDefaultRateLimits()

Wikibase\Repo\RepoHooks::inheritDefaultRateLimits ( array & $rateLimits)
static

Make the 'wikibase-idgenerator' rate limit inherit the 'create' rate limit, or the 'edit' rate limit if no 'create' limit is defined, unless the 'wikibase-idgenerator' rate limit was itself customized.

Parameters
array&$rateLimitsshould be $wgRateLimits or a similar array

◆ isNamespaceUsedByLocalEntities()

Wikibase\Repo\RepoHooks::isNamespaceUsedByLocalEntities ( int $namespace)
staticprivate

◆ notifyEntityStoreWatcherOnUpdate()

Wikibase\Repo\RepoHooks::notifyEntityStoreWatcherOnUpdate ( EntityContent $content,
RevisionRecord $revision )
staticprivate

◆ onAbuseFilter_contentToString()

Wikibase\Repo\RepoHooks::onAbuseFilter_contentToString ( Content $content,
?string & $text )

Hook handler for AbuseFilter's AbuseFilter-contentToString hook, implemented to provide a custom text representation of Entities for filtering.

Called when converting a Content object to a string to which filters can be applied. If the hook function returns true, Content::getTextForSearchIndex() will be used for non-text content.

Parameters
Content$content
?string&$textSet this to the desired text
Returns
bool|void True or no return value to continue or false to abort

◆ onApiMain__moduleManager()

Wikibase\Repo\RepoHooks::onApiMain__moduleManager ( $moduleManager)

◆ onApiMain__onException()

Wikibase\Repo\RepoHooks::onApiMain__onException ( $apiMain,
$e )

Attempt to create an entity locks an entity id (for items, it would be Q####) and if saving fails due to validation issues for example, that id would be wasted.

We want to penalize the user by adding a bigger number to ratelimit and slow them down to avoid bots wasting significant number of Q-ids by sending faulty data over and over again. See T284538 for more information.

◆ onApiQuery__moduleManager()

Wikibase\Repo\RepoHooks::onApiQuery__moduleManager ( $moduleManager)

◆ onAPIQuerySiteInfoGeneralInfo()

Wikibase\Repo\RepoHooks::onAPIQuerySiteInfoGeneralInfo ( $module,
& $results )

Exposes configuration values to the action=query&meta=siteinfo API, including lists of property and data value types, sparql endpoint, and several base URLs and URIs.

◆ onBeforeDisplayNoArticleText()

Wikibase\Repo\RepoHooks::onBeforeDisplayNoArticleText ( $article)

We implement this solely to replace the standard message that is shown when an entity does not exists.

◆ onBeforePageDisplay()

Wikibase\Repo\RepoHooks::onBeforePageDisplay ( $out,
$skin )

Handler for the BeforePageDisplay hook, that conditionally adds the wikibase mobile styles and injects the wikibase.ui.entitysearch module replacing the native search box with the entity selector widget.

It additionally schedules a WikibasePingback

Parameters
OutputPage$out
Skin$skin

◆ onContentModelCanBeUsedOn()

Wikibase\Repo\RepoHooks::onContentModelCanBeUsedOn ( $contentModel,
$title,
& $ok )

Handler for the ContentModelCanBeUsedOn hook, used to prevent pages of inappropriate type to be placed in an entity namespace.

◆ onFormatAutocomments()

Wikibase\Repo\RepoHooks::onFormatAutocomments ( & $comment,
$pre,
$auto,
$post,
$title,
$local,
$wiki )

Handler for the FormatAutocomments hook, implementing localized formatting for machine readable autocomments generated by SummaryFormatter.

◆ onGetPreferences()

Wikibase\Repo\RepoHooks::onGetPreferences ( $user,
& $preferences )

NOTE: Might make sense to put the inner functionality into a well structured Preferences file once this becomes more.

◆ onImportHandleRevisionXMLTag()

Wikibase\Repo\RepoHooks::onImportHandleRevisionXMLTag ( $reader,
$pageInfo,
$revisionInfo )

Called by Import.php.

Implemented to prevent the import of entities.

◆ onInfoAction()

Wikibase\Repo\RepoHooks::onInfoAction ( $context,
& $pageInfo )

Adds the Wikis using the entity in action=info.

◆ onMaintenanceShellStart()

Wikibase\Repo\RepoHooks::onMaintenanceShellStart ( )

◆ onMediaWikiServices()

Wikibase\Repo\RepoHooks::onMediaWikiServices ( $services)

Handler for the MediaWikiServices hook, completing the content and namespace setup.

This updates the $wgContentHandlers and $wgNamespaceContentModels registries according to information provided by entity type definitions and the entityNamespaces setting for the local entity source. Note that we must not access any MediaWiki core services here (except for the hook container); see the warning in ().

Parameters
MediaWikiServices$services
Returns
bool|void True or no return value to continue or false to abort

◆ onNamespaceIsMovable()

Wikibase\Repo\RepoHooks::onNamespaceIsMovable ( $ns,
& $movable )

◆ onOutputPageBodyAttributes()

Wikibase\Repo\RepoHooks::onOutputPageBodyAttributes ( $out,
$sk,
& $bodyAttrs )

Used to append a css class to the body, so the page can be identified as Wikibase item page.

◆ onOutputPageParserOutput()

Wikibase\Repo\RepoHooks::onOutputPageParserOutput ( $outputPage,
$parserOutput )

Used to transfer 'wikibase-view-chunks' and entity data from ParserOutput to OutputPage.

◆ onPageHistoryLineEnding()

Wikibase\Repo\RepoHooks::onPageHistoryLineEnding ( $historyAction,
& $row,
& $s,
& $classes,
& $attribs )

◆ onParserFirstCallInit()

Wikibase\Repo\RepoHooks::onParserFirstCallInit ( $parser)

◆ onParserOptionsRegister()

Wikibase\Repo\RepoHooks::onParserOptionsRegister ( & $defaults,
& $inCacheKey,
& $lazyLoad )

Handler for the ParserOptionsRegister hook to add a "wb" option for cache-splitting.

This registers a lazy-loaded parser option with its value being the EntityHandler parser version. Non-Wikibase parses will ignore this option, while Wikibase parses will trigger its loading via ParserOutput::recordOption() and thereby include it in the cache key to fragment the cache by EntityHandler::PARSER_VERSION.

◆ onRegistration()

Wikibase\Repo\RepoHooks::onRegistration ( )
static

◆ onResourceLoaderRegisterModules()

Wikibase\Repo\RepoHooks::onResourceLoaderRegisterModules ( $rl)

◆ onRevisionFromEditComplete()

Wikibase\Repo\RepoHooks::onRevisionFromEditComplete ( $wikiPage,
$rev,
$originalRevId,
$user,
& $tags )

◆ onSkinPageReadyConfig()

Wikibase\Repo\RepoHooks::onSkinPageReadyConfig ( Context $context,
array & $config )

◆ onSkinTemplateNavigation__Universal()

Wikibase\Repo\RepoHooks::onSkinTemplateNavigation__Universal ( $sktemplate,
& $links )
Todo
T282549 Consider moving some of this logic into a place where it can be more adequately tested

◆ onTitleGetRestrictionTypes()

Wikibase\Repo\RepoHooks::onTitleGetRestrictionTypes ( $title,
& $types )

Implemented to prevent people from protecting pages from being created or moved in an entity namespace (which is pointless).

◆ onUnitTestsList()

Wikibase\Repo\RepoHooks::onUnitTestsList ( & $paths)

◆ onUserGetDefaultOptions()

Wikibase\Repo\RepoHooks::onUserGetDefaultOptions ( array & $defaultOptions)
static

Called after fetching the core default user options.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/UserGetDefaultOptions
Parameters
array&$defaultOptions

◆ onVectorSearchResourceLoaderConfig()

Wikibase\Repo\RepoHooks::onVectorSearchResourceLoaderConfig ( array & $vectorSearchConfig)

Handler for the VectorSearchResourceLoaderConfig hook to overwrite search pattern highlighting for wikibase.

Parameters
array&$vectorSearchConfig
Returns
void

◆ onWikibaseContentLanguages()

Wikibase\Repo\RepoHooks::onWikibaseContentLanguages ( & $contentLanguages)


The documentation for this class was generated from the following file: