Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\RepoHooks Class Reference

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

Static Public Member Functions

static onBeforePageDisplay (OutputPage $out, Skin $skin)
 Handler for the BeforePageDisplay hook, simply injects wikibase.ui.entitysearch module replacing the native search box with the entity selector widget. More...
 
static onBeforePageDisplayMobile (OutputPage $out, Skin $skin)
 Handler for the BeforePageDisplayMobile hook that adds the wikibase mobile styles. More...
 
static onSetupAfterCache ()
 Handler for the SetupAfterCache hook, completing the content and namespace setup. More...
 
static registerUnitTests (array &$paths)
 Hook to add PHPUnit test cases. More...
 
static onNamespaceIsMovable ( $ns, &$movable)
 Handler for the NamespaceIsMovable hook. More...
 
static onRevisionFromEditComplete (WikiPage $wikiPage, RevisionRecord $revisionRecord, $baseID, UserIdentity $user)
 Called when a revision was inserted due to an edit. More...
 
static onArticleUndelete (Title $title, $created, $comment)
 Handle changes for undeletions. More...
 
static onGetPreferences (User $user, array &$preferences)
 Allows to add user preferences. More...
 
static onUserGetDefaultOptions (array &$defaultOptions)
 Called after fetching the core default user options. More...
 
static onPageHistoryLineEnding (HistoryPager $history, $row, &$html, array $classes)
 Modify line endings on history page. More...
 
static onSkinTemplateNavigationUniversal (SkinTemplate $skinTemplate, array &$links)
 Alter the structured navigation links in SkinTemplates. More...
 
static onSpecialPageReorderPages (&$groups, $moveOther)
 Reorder the groups for the special pages. More...
 
static onOutputPageBodyAttributes (OutputPage $out, Skin $skin, array &$bodyAttrs)
 Used to append a css class to the body, so the page can be identified as Wikibase item page. More...
 
static onTitleGetRestrictionTypes (Title $title, array &$types)
 Handler for the TitleGetRestrictionTypes hook. More...
 
static onAbuseFilterContentToString (Content $content, &$text)
 Hook handler for AbuseFilter's AbuseFilter-contentToString hook, implemented to provide a custom text representation of Entities for filtering. More...
 
static onFormat (&$comment, $pre, $auto, $post, $title, $local)
 Handler for the FormatAutocomments hook, implementing localized formatting for machine readable autocomments generated by SummaryFormatter. More...
 
static onOutputPageParserOutput (OutputPage $out, ParserOutput $parserOutput)
 Called when pushing meta-info from the ParserOutput into OutputPage. More...
 
static onContentModelCanBeUsedOn ( $contentModel, LinkTarget $title, &$ok)
 Handler for the ContentModelCanBeUsedOn hook, used to prevent pages of inappropriate type to be placed in an entity namespace. More...
 
static onAPIQuerySiteInfoGeneralInfo (ApiQuerySiteinfo $api, array &$data)
 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. More...
 
static onAPIQuerySiteInfoStatisticsInfo (array &$data)
 Adds DispatchStats info to the API. More...
 
static onImportHandleRevisionXMLTag ( $importer, $pageInfo, $revisionInfo)
 Called by Import.php. More...
 
static onSidebarBeforeOutput (Skin $skin, array &$sidebar)
 Add Concept URI link to the toolbox section of the sidebar. More...
 
static onResourceLoaderRegisterModules (ResourceLoader $resourceLoader)
 Register ResourceLoader modules with dynamic dependencies. More...
 
static onInfoAction (IContextSource $context, array &$pageInfo)
 Adds the Wikis using the entity in action=info. More...
 
static onApiMaxLagInfo (array &$lagInfo)
 Handler for the ApiMaxLagInfo to add dispatching lag stats. More...
 
static onParserOptionsRegister (&$defaults, &$inCacheKey, &$lazyOptions)
 Handler for the ParserOptionsRegister hook to add a "wb" option for cache-splitting. More...
 
static onRejectParserCacheValue (ParserOutput $parserValue, WikiPage $wikiPage, ParserOptions $parserOpts)
 
static onApiQueryModuleManager (ApiModuleManager $moduleManager)
 
static onParserFirstCallInit (Parser $parser)
 Register the parser functions. More...
 
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. More...
 
static onApiMainOnException ( $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. More...
 

Static Private Member Functions

static isNamespaceUsedByLocalEntities ( $namespace)
 
static notifyEntityStoreWatcherOnUpdate (EntityContent $content, RevisionRecord $revision)
 
static formatDispatchRow ( $row)
 Helper for onAPIQuerySiteInfoStatisticsInfo. More...
 

Detailed Description

File defining the hook handlers for the Wikibase extension.

Member Function Documentation

◆ formatDispatchRow()

static Wikibase\Repo\RepoHooks::formatDispatchRow (   $row)
staticprivate

Helper for onAPIQuerySiteInfoStatisticsInfo.

Parameters
object$row
Returns
array

◆ inheritDefaultRateLimits()

static 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()

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

◆ notifyEntityStoreWatcherOnUpdate()

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

◆ onAbuseFilterContentToString()

static Wikibase\Repo\RepoHooks::onAbuseFilterContentToString ( Content  $content,
$text 
)
static

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

Parameters
Content$content
string&$textThe resulting text
Returns
bool

◆ onApiMainOnException()

static Wikibase\Repo\RepoHooks::onApiMainOnException (   $apiMain,
  $e 
)
static

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.

Parameters
ApiMain$apiMain
Throwable$e
Returns
bool|void
Exceptions
MWException

◆ onApiMaxLagInfo()

static Wikibase\Repo\RepoHooks::onApiMaxLagInfo ( array &  $lagInfo)
static

Handler for the ApiMaxLagInfo to add dispatching lag stats.

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

◆ onApiQueryModuleManager()

static Wikibase\Repo\RepoHooks::onApiQueryModuleManager ( ApiModuleManager  $moduleManager)
static

◆ onAPIQuerySiteInfoGeneralInfo()

static Wikibase\Repo\RepoHooks::onAPIQuerySiteInfoGeneralInfo ( ApiQuerySiteinfo  $api,
array &  $data 
)
static

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.

Parameters
ApiQuerySiteinfo$api
array&$data

◆ onAPIQuerySiteInfoStatisticsInfo()

static Wikibase\Repo\RepoHooks::onAPIQuerySiteInfoStatisticsInfo ( array &  $data)
static

Adds DispatchStats info to the API.

Parameters
array[]&$data

◆ onArticleUndelete()

static Wikibase\Repo\RepoHooks::onArticleUndelete ( Title  $title,
  $created,
  $comment 
)
static

Handle changes for undeletions.

Parameters
Title$title
bool$created
string$comment

◆ onBeforePageDisplay()

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

Handler for the BeforePageDisplay hook, simply injects wikibase.ui.entitysearch module replacing the native search box with the entity selector widget.

It additionally schedules a WikibasePingback

Parameters
OutputPage$out
Skin$skin

◆ onBeforePageDisplayMobile()

static Wikibase\Repo\RepoHooks::onBeforePageDisplayMobile ( OutputPage  $out,
Skin  $skin 
)
static

Handler for the BeforePageDisplayMobile hook that adds the wikibase mobile styles.

Parameters
OutputPage$out
Skin$skin

◆ onContentModelCanBeUsedOn()

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

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

Parameters
string$contentModel
LinkTarget$titleActually a Title object, but we only require getNamespace
bool&$ok
Returns
bool

◆ onFormat()

static Wikibase\Repo\RepoHooks::onFormat ( $comment,
  $pre,
  $auto,
  $post,
  $title,
  $local 
)
static

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

Parameters
string&$commentreference to the autocomment text
bool$pretrue if there is content before the autocomment
string$autothe autocomment unformatted
bool$posttrue if there is content after the autocomment
Title | null$titleuse for further information
bool$localshall links be generated locally or globally

◆ onGetPreferences()

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

Allows to add user preferences.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences

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

Parameters
User$user
array[]&$preferences

◆ onImportHandleRevisionXMLTag()

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

Called by Import.php.

Implemented to prevent the import of entities.

Parameters
object$importerunclear, see Bug T66657
array$pageInfo
array$revisionInfo
Exceptions
MWException

◆ onInfoAction()

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

Adds the Wikis using the entity in action=info.

Parameters
IContextSource$context
array[]&$pageInfo

◆ onNamespaceIsMovable()

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

Handler for the NamespaceIsMovable hook.

Implemented to prevent moving pages that are in an entity namespace.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/NamespaceIsMovable
Parameters
int$nsNamespace ID
bool&$movable

◆ onOutputPageBodyAttributes()

static Wikibase\Repo\RepoHooks::onOutputPageBodyAttributes ( OutputPage  $out,
Skin  $skin,
array &  $bodyAttrs 
)
static

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

See also
https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageBodyAttributes
Parameters
OutputPage$out
Skin$skin
array&$bodyAttrs

◆ onOutputPageParserOutput()

static Wikibase\Repo\RepoHooks::onOutputPageParserOutput ( OutputPage  $out,
ParserOutput  $parserOutput 
)
static

Called when pushing meta-info from the ParserOutput into OutputPage.

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

Parameters
OutputPage$out
ParserOutput$parserOutput

◆ onPageHistoryLineEnding()

static Wikibase\Repo\RepoHooks::onPageHistoryLineEnding ( HistoryPager  $history,
  $row,
$html,
array  $classes 
)
static

Modify line endings on history page.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/PageHistoryLineEnding
Parameters
HistoryPager$history
object$row
string&$html
array$classes

◆ onParserFirstCallInit()

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

Register the parser functions.

Parameters
Parser$parser

◆ onParserOptionsRegister()

static Wikibase\Repo\RepoHooks::onParserOptionsRegister ( $defaults,
$inCacheKey,
$lazyOptions 
)
static

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.

Parameters
array&$defaultsOptions and their defaults
array&$inCacheKeyWhether each option splits the parser cache
array&$lazyOptionsInitializers for lazy-loaded options

◆ onRegistration()

static Wikibase\Repo\RepoHooks::onRegistration ( )
static

◆ onRejectParserCacheValue()

static Wikibase\Repo\RepoHooks::onRejectParserCacheValue ( ParserOutput  $parserValue,
WikiPage  $wikiPage,
ParserOptions  $parserOpts 
)
static

◆ onResourceLoaderRegisterModules()

static Wikibase\Repo\RepoHooks::onResourceLoaderRegisterModules ( ResourceLoader  $resourceLoader)
static

Register ResourceLoader modules with dynamic dependencies.

Parameters
ResourceLoader$resourceLoader

◆ onRevisionFromEditComplete()

static Wikibase\Repo\RepoHooks::onRevisionFromEditComplete ( WikiPage  $wikiPage,
RevisionRecord  $revisionRecord,
  $baseID,
UserIdentity  $user 
)
static

Called when a revision was inserted due to an edit.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/RevisionFromEditComplete
Parameters
WikiPage$wikiPage
RevisionRecord$revisionRecord
int$baseID
UserIdentity$user

◆ onSetupAfterCache()

static Wikibase\Repo\RepoHooks::onSetupAfterCache ( )
static

Handler for the SetupAfterCache 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.

Exceptions
MWException

◆ onSidebarBeforeOutput()

static Wikibase\Repo\RepoHooks::onSidebarBeforeOutput ( Skin  $skin,
array &  $sidebar 
)
static

Add Concept URI link to the toolbox section of the sidebar.

Parameters
Skin$skin
string[]&$sidebar
Returns
void

◆ onSkinTemplateNavigationUniversal()

static Wikibase\Repo\RepoHooks::onSkinTemplateNavigationUniversal ( SkinTemplate  $skinTemplate,
array &  $links 
)
static

Alter the structured navigation links in SkinTemplates.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateNavigation::Universal
Todo:
T282549 Consider moving some of this logic into a place where it can be more adequately tested
Parameters
SkinTemplate$skinTemplate
array[]&$links

◆ onSpecialPageReorderPages()

static Wikibase\Repo\RepoHooks::onSpecialPageReorderPages ( $groups,
  $moveOther 
)
static

Reorder the groups for the special pages.

Parameters
array&$groups
bool$moveOther

◆ onTitleGetRestrictionTypes()

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

Handler for the TitleGetRestrictionTypes hook.

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

See also
https://www.mediawiki.org/wiki/Manual:Hooks/TitleGetRestrictionTypes
Parameters
Title$title
string[]&$typesThe types of protection available

◆ onUserGetDefaultOptions()

static 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

◆ registerUnitTests()

static Wikibase\Repo\RepoHooks::registerUnitTests ( array &  $paths)
static

Hook to add PHPUnit test cases.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
Parameters
string[]&$paths

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