Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
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, that conditionally adds the wikibase mobile styles and injects the wikibase.ui.entitysearch module replacing the native search box with the entity selector widget.
 
static onSetupAfterCache ()
 Handler for the SetupAfterCache hook, completing the content and namespace setup.
 
static registerUnitTests (array &$paths)
 Hook to add PHPUnit test cases.
 
static onNamespaceIsMovable ( $ns, &$movable)
 Handler for the NamespaceIsMovable hook.
 
static onRevisionFromEditComplete (WikiPage $wikiPage, RevisionRecord $revisionRecord, $baseID, UserIdentity $user)
 Called when a revision was inserted due to an edit.
 
static onArticleUndelete (Title $title, $created, $comment)
 Handle changes for undeletions.
 
static onGetPreferences (User $user, array &$preferences)
 Allows to add user preferences.
 
static onUserGetDefaultOptions (array &$defaultOptions)
 Called after fetching the core default user options.
 
static onPageHistoryLineEnding (HistoryPager $history, $row, &$html, array $classes)
 Modify line endings on history page.
 
static onSkinTemplateNavigationUniversal (SkinTemplate $skinTemplate, array &$links)
 Alter the structured navigation links in SkinTemplates.
 
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.
 
static onTitleGetRestrictionTypes (Title $title, array &$types)
 Handler for the TitleGetRestrictionTypes hook.
 
static onAbuseFilterContentToString (Content $content, &$text)
 Hook handler for AbuseFilter's AbuseFilter-contentToString hook, implemented to provide a custom text representation of Entities for filtering.
 
static onFormat (&$comment, $pre, $auto, $post, $title, $local)
 Handler for the FormatAutocomments hook, implementing localized formatting for machine readable autocomments generated by SummaryFormatter.
 
static onOutputPageParserOutput (OutputPage $outputPage, ParserOutput $parserOutput)
 Called when pushing meta-info from the ParserOutput into OutputPage.
 
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.
 
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.
 
static onImportHandleRevisionXMLTag ( $importer, $pageInfo, $revisionInfo)
 Called by Import.php.
 
static onSidebarBeforeOutput (Skin $skin, array &$sidebar)
 Add Concept URI link to the toolbox section of the sidebar.
 
static onResourceLoaderRegisterModules (ResourceLoader $resourceLoader)
 Register ResourceLoader modules with dynamic dependencies.
 
static onInfoAction (IContextSource $context, array &$pageInfo)
 Adds the Wikis using the entity in action=info.
 
static onParserOptionsRegister (&$defaults, &$inCacheKey, &$lazyOptions)
 Handler for the ParserOptionsRegister hook to add a "wb" option for cache-splitting.
 
static onApiQueryModuleManager (ApiModuleManager $moduleManager)
 
static onParserFirstCallInit (Parser $parser)
 Register the parser functions.
 
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 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.
 
static onWikibaseContentLanguages (array &$contentLanguages)
 
static onMaintenanceShellStart ()
 
static onVectorSearchResourceLoaderConfig (array &$vectorSearchConfig)
 Handler for the VectorSearchResourceLoaderConfig hook to overwrite search pattern highlighting for wikibase.
 

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 ( $namespace)
 
static notifyEntityStoreWatcherOnUpdate (EntityContent $content, RevisionRecord $revision)
 

Detailed Description

File defining the hook handlers for the Wikibase extension.

Member Function Documentation

◆ defaultEntityNamespaces()

static Wikibase\Repo\RepoHooks::defaultEntityNamespaces ( )
staticprivate

PhanUndeclaredConstant.

◆ ensureConstant()

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

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

◆ 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

◆ 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, 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()

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
WikiImporter$importer
array$pageInfo
array$revisionInfo

◆ 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

◆ onMaintenanceShellStart()

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

◆ 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 $outputPage,
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$outputPage
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
\stdClass$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

◆ 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.

◆ 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

◆ 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

◆ onVectorSearchResourceLoaderConfig()

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

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

◆ onWikibaseContentLanguages()

static Wikibase\Repo\RepoHooks::onWikibaseContentLanguages ( array & $contentLanguages)
static
Parameters
ContentLanguages[]&$contentLanguages

◆ 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: