MediaWiki  1.34.0
Hooks Class Reference

Hooks class. More...

Static Public Member Functions

static clear ( $name)
 Clears hooks registered via Hooks::register(). More...
 
static getHandlers ( $name)
 Returns an array of all the event functions attached to a hook This combines functions registered via Hooks::register and with $wgHooks. More...
 
static isRegistered ( $name)
 Returns true if a hook has a function registered to it. More...
 
static register ( $name, $callback)
 Attach an event handler to a given hook. More...
 
static run ( $event, array $args=[], $deprecatedVersion=null)
 Call hook functions defined in Hooks::register and $wgHooks. More...
 
static runWithoutAbort ( $event, array $args=[], $deprecatedVersion=null)
 Call hook functions defined in Hooks::register and $wgHooks. More...
 

Static Protected Attributes

static $handlers = []
 Array of events mapped to an array of callbacks to be run when that event is triggered. More...
 

Static Private Member Functions

static callHook ( $event, $hook, array $args, $deprecatedVersion=null, &$fname=null)
 

Detailed Description

Hooks class.

Used to supersede $wgHooks, because globals are EVIL.

Since
1.18

Definition at line 34 of file Hooks.php.

Member Function Documentation

◆ callHook()

static Hooks::callHook (   $event,
  $hook,
array  $args,
  $deprecatedVersion = null,
$fname = null 
)
staticprivate
Parameters
string$eventEvent name
array | callable$hook
array$argsArray of parameters passed to hook functions
string | null$deprecatedVersion[optional]
string&$fname[optional] Readable name of hook [returned]
Returns
null|string|bool

Definition at line 116 of file Hooks.php.

References $args, and wfDeprecated().

Referenced by run(), and runWithoutAbort().

◆ clear()

static Hooks::clear (   $name)
static

Clears hooks registered via Hooks::register().

Does not touch $wgHooks. This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.

Parameters
string$nameThe name of the hook to clear.
Since
1.21
Exceptions
MWExceptionIf not in testing mode.

Definition at line 63 of file Hooks.php.

◆ getHandlers()

static Hooks::getHandlers (   $name)
static

Returns an array of all the event functions attached to a hook This combines functions registered via Hooks::register and with $wgHooks.

Since
1.18
Parameters
string$nameName of the hook
Returns
array

Definition at line 94 of file Hooks.php.

References $wgHooks.

◆ isRegistered()

static Hooks::isRegistered (   $name)
static

Returns true if a hook has a function registered to it.

The function may have been registered either via Hooks::register or in $wgHooks.

Since
1.18
Parameters
string$nameName of hook
Returns
bool True if the hook has a function registered to it

Definition at line 80 of file Hooks.php.

References $wgHooks.

Referenced by MediaWiki\Linker\LinkRenderer\buildAElement(), Article\fetchRevisionRecord(), ChangeTags\listSoftwareActivatedTags(), ChangeTags\listSoftwareDefinedTags(), and MediaWiki\Linker\LinkRenderer\runLegacyBeginHook().

◆ register()

static Hooks::register (   $name,
  $callback 
)
static

Attach an event handler to a given hook.

Parameters
string$nameName of hook
callable$callbackCallback function to attach
Since
1.18

Definition at line 49 of file Hooks.php.

Referenced by BenchmarkParse\execute().

◆ run()

static Hooks::run (   $event,
array  $args = [],
  $deprecatedVersion = null 
)
static

Call hook functions defined in Hooks::register and $wgHooks.

For the given hook event, fetch the array of hook events and process them. Determine the proper callback for each hook and then call the actual hook using the appropriate arguments. Finally, process the return value and return/throw accordingly.

For hook event that are not abortable through a handler's return value, use runWithoutAbort() instead.

Parameters
string$eventEvent name
array$argsArray of parameters passed to hook functions
string | null$deprecatedVersion[optional] Mark hook as deprecated with version number
Returns
bool True if no handler aborted the hook
Exceptions
Exception
FatalError
MWException
Since
1.22 A hook function is not required to return a value for processing to continue. Not returning a value (or explicitly returning null) is equivalent to returning true.

Definition at line 200 of file Hooks.php.

References $args, and callHook().

Referenced by UploadForm\__construct(), RedirectSpecialArticle\__construct(), RenameuserSQL\__construct(), ChangesListSpecialPage\__construct(), DatabaseUpdater\__construct(), LinksUpdate\__construct(), ApiQuery\__construct(), ApiMain\__construct(), EmailNotification\actuallyNotifyOnPageChange(), User\addAutopromoteOnceGroups(), ApiBase\addDeprecation(), User\addGroup(), Skin\afterContentHook(), SpecialPageLanguage\alterForm(), ExternalUserNames\applyPrefix(), SpecialChangeEmail\attemptChange(), EditPage\attemptSave(), SearchEngine\augmentSearchResults(), MediaWiki\Auth\AuthManager\autoCreateUser(), MediaWiki\Auth\AuthManager\beginAuthentication(), Skin\bottomScripts(), MediaWiki\Linker\LinkRenderer\buildAElement(), SkinTemplate\buildContentNavigationUrls(), ProtectionForm\buildForm(), SkinTemplate\buildNavUrls(), SpecialEditWatchlist\buildRemoveLine(), Skin\buildSidebar(), ChangeTags\canAddTagsAccompanyingChange(), ContentHandler\canBeUsedOn(), ChangeTags\canCreateTag(), ChangeTags\canDeleteTag(), User\canSendEmail(), EmailNotification\canSendUserTalkEmail(), Autopromote\checkCondition(), ApiMain\checkConditionalRequestHeaders(), ApiMain\checkExecutePermissions(), User\checkPasswordValidity(), MediaWiki\Permissions\PermissionManager\checkPermissionHooks(), MovePage\checkPermissions(), MediaWiki\Permissions\PermissionManager\checkQuickPermissions(), MediaWiki\Permissions\PermissionManager\checkReadPermissions(), CleanupUsersWithNoId\cleanup(), User\clearNotification(), ApiFormatBase\closePrinter(), WikiPage\commitRollback(), SearchEngine\completionSearchBackend(), Article\confirmDelete(), User\confirmEmail(), MediaWiki\Auth\AuthManager\continueAuthentication(), AbstractContent\convert(), ContentHandler\createDifferenceEngine(), ChangeTags\deleteTagEverywhere(), MonoBookTemplate\deprecatedHookHack(), EditPage\displayViewSourcePage(), MediaWiki\Block\DatabaseBlock\doAutoblock(), HistoryPager\doBatchLookups(), UsersPager\doBatchLookups(), CategoryViewer\doCategoryQuery(), MediaWiki\Storage\PageUpdater\doCreate(), FileDeleteForm\doDelete(), SpecialNuke\doDelete(), Article\doDelete(), WikiPage\doDeleteArticleBatched(), WikiPage\doDeleteArticleReal(), Skin\doEditSectionLink(), WikiImporter\doImport(), RecentChange\doMarkPatrolled(), MediaWiki\Storage\PageUpdater\doModify(), RevDelRevisionList\doPostCommitUpdates(), WikiPage\doPurge(), RefreshLinks\doRefreshLinks(), MediaWiki\Block\DatabaseBlock\doRetroactiveAutoblock(), UserrightsPage\doSaveUserGroups(), MovePageForm\doSubmit(), TransformationalImageHandler\doTransform(), WatchAction\doUnwatch(), LinksUpdate\doUpdate(), WikiPage\doUpdateRestrictions(), MediaWiki\Storage\DerivedPageDataUpdater\doUpdates(), LinkHolderArray\doVariants(), WikiPage\doViewUpdates(), WatchAction\doWatch(), WikiExporter\dumpPages(), EditPage\edit(), ApiValidatePassword\execute(), SpecialRenameuser\execute(), ApiUndelete\execute(), ApiLogout\execute(), ApiExpandTemplates\execute(), VectorTemplate\execute(), ApiChangeAuthenticationData\execute(), SpecialLog\execute(), ApiOptions\execute(), SpecialContributions\execute(), SpecialTrackingCategories\execute(), BenchmarkHooks\execute(), SpecialStatistics\execute(), ApiParse\execute(), ApiRemoveAuthenticationData\execute(), CleanupPreferences\execute(), SpecialImport\execute(), ApiLogin\execute(), ApiOpenSearch\execute(), SpecialSearch\execute(), SpecialUpload\execute(), PasswordReset\execute(), ApiQuery\execute(), ApiMain\executeAction(), ApiPageSet\executeInternal(), Title\exists(), ApiQueryWatchlist\extractOutputData(), ApiQueryInfo\extractPageInfo(), Collation\factory(), WikiPage\factory(), ApiFeedContributions\feedItem(), FormatMetadata\fetchExtendedMetadata(), Article\fetchRevisionRecord(), AuthManagerSpecialPage\fieldInfoToFormDescriptor(), WikiImporter\finishImportPage(), Linker\formatAutocomments(), UsersPager\formatRow(), DeletedContribsPager\formatRow(), SpecialNewpages\formatRow(), ContribsPager\formatRow(), File\generateAndSaveThumb(), CategoryViewer\generateLink(), MediaWiki\Widget\Search\FullSearchResultWidget\generateMainLinkHtml(), ParserCache\get(), MessageCache\get(), LegacyLogFormatter\getActionLinks(), BaseTemplate\getAfterPortlet(), ApiImport\getAllowedImportSources(), MediaWiki\Permissions\PermissionManager\getAllPermissions(), ChangesList\getArticleLink(), MediaWiki\Storage\PageUpdater\getAtomicSectionUpdate(), Autopromote\getAutopromoteGroups(), User\getBlockedStatus(), NamespaceInfo\getCanonicalNamespaces(), Title\getCanonicalURL(), Title\getCategorySortkey(), Title\getCdnUrls(), CheckLanguageCLI\getCheckBlacklist(), EditPage\getCheckboxesDefinition(), BacklinkCache\getConditions(), ResourceLoaderStartUpModule\getConfigSettings(), ContentHandler\getContentModels(), Skin\getCopyright(), EditPage\getCopyrightWarning(), ContentHandler\getDataForSearchIndex(), Revision\MainSlotRoleHandler\getDefaultModel(), User\getDefaultOptions(), UsersPager\getDefaultQuery(), ParserOptions\getDefaults(), WikiPage\getDeletionUpdates(), ResourceLoaderForeignApiModule\getDependencies(), HistoryAction\getDescription(), DifferenceEngine\getDiffBody(), MagicWordFactory\getDoubleUnderscoreArray(), EditPage\getEditButtons(), Title\getEditNotices(), EditPage\getEditToolbar(), User\getEffectiveGroups(), User\getEmail(), User\getEmailAuthenticationTimestamp(), FormatMetadata\getExtendedMetadataFromHook(), WatchedItemQueryService\getExtensions(), SpecialVersion\getExtensionTypes(), LogEventsList\getExtraInputsDesc(), SpecialRecentChanges\getExtraOptions(), ApiBase\getFinalDescription(), ApiBase\getFinalParamDescription(), ApiBase\getFinalParams(), FormAction\getForm(), FormSpecialPage\getForm(), SpecialContributions\getForm(), MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor(), SpecialBlock\getFormFields(), SpecialMute\getFormFields(), ContentHandler\getForModelID(), Title\getFullURL(), User\getGlobalBlock(), ApiHelp\getHelpInternal(), LocalFile\getHistory(), Language\getHumanTimestamp(), SpecialUpload\getInitialPageText(), Title\getInternalURL(), RequestContext\getLanguage(), MediaWiki\Languages\LanguageNameUtils\getLanguageNamesUncached(), SkinTemplate\getLanguages(), PreferencesFormOOUI\getLegend(), ScribuntoEngineBase\getLibraries(), ScribuntoEngineBase\getLibraryPaths(), IRCColourfulRCFeedFormatter\getLine(), EnhancedChangesList\getLineData(), Title\getLocalURL(), EnhancedChangesList\getLogText(), SpecialLog\getLogTypesOnUser(), DifferenceEngine\getMarkPatrolledLinkInfo(), MediaWiki\Languages\LanguageNameUtils\getMessagesFileName(), MediaHandler\getMetadataVersion(), MessageCache\getMsgFromNamespace(), Language\getNamespaces(), SearchNearMatcher\getNearMatch(), SearchNearMatcher\getNearMatchInternal(), User\getNewMessageLinks(), SpecialNuke\getNewPages(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProvider\getNewPasswordExpiry(), Skin\getNewtalks(), SpecialEditWatchlist\getNormalForm(), UsersPager\getPageHeader(), CodeEditorHooks\getPageLanguage(), ContentHandler\getPageLanguage(), MediaWiki\Special\SpecialPageFactory\getPageList(), QueryPage\getPages(), AbstractContent\getParserOutput(), WebRequest\getPathInfo(), SpecialEmailUser\getPermissionsError(), UserPasswordPolicy\getPoliciesForUser(), Skin\getPoweredBy(), BacklinkCache\getPrefix(), EditPage\getPreviewLimitReport(), EditPage\getPreviewText(), SpecialShortPages\getQueryInfo(), SpecialAncientPages\getQueryInfo(), NewPagesPager\getQueryInfo(), WantedPagesPage\getQueryInfo(), SpecialLonelyPages\getQueryInfo(), HistoryPager\getQueryInfo(), UsersPager\getQueryInfo(), RandomPage\getQueryInfo(), ContribsPager\getQueryInfo(), RandomPage\getRandomTitle(), MWTimestamp\getRelativeTimestamp(), Title\getRestrictionTypes(), ApiRsd\getRsdApiList(), SearchEngine\getSearchIndexFields(), SpecialSearch\getSearchProfiles(), AbstractContent\getSecondaryDataUpdates(), MediaWiki\Storage\DerivedPageDataUpdater\getSecondaryDataUpdates(), BaseTemplate\getSidebar(), Skin\getSiteNotice(), RequestContext\getSkin(), ContentHandler\getSlotDiffRenderer(), SpecialVersion\getSoftwareInformation(), UploadForm\getSourceSection(), ApiQueryRevisions\getTokenFunctions(), ApiQueryRecentChanges\getTokenFunctions(), ApiQueryUsers\getTokenFunctions(), ApiQueryInfo\getTokenFunctions(), SpecialResetTokens\getTokensList(), ApiTokens\getTokenTypes(), ApiQueryTokens\getTokenTypeSalts(), BaseTemplate\getToolbox(), Skin\getUndeleteLink(), MediaWiki\Block\BlockManager\getUserBlock(), MediaWiki\Permissions\PermissionManager\getUserPermissions(), LoginHelper\getValidErrorMessages(), MagicWordFactory\getVariableIDs(), GitInfo\getViewers(), SpecialVersion\getwgVersionLinked(), SpecialSearch\goResult(), ApiMain\handleException(), WikiImporter\handleLogItem(), WikiImporter\handlePage(), WikiImporter\handleRevision(), EditPage\handleStatus(), WikiImporter\handleUpload(), HistoryPager\historyLine(), ImageHistoryList\imageHistoryLine(), EditPage\importFormData(), LinksUpdate\incrTableUpdate(), ChangesList\initChangesListRows(), initFromTitle(), MediaWiki\initializeArticle(), Revision\RevisionStore\insertRevisionOn(), EditPage\internalAttemptSave(), User\invalidateEmail(), UploadFromUrl\isAllowedUrl(), Title\isAlwaysKnown(), MediaWiki\BadFileLookup\isBadFile(), MediaWiki\Permissions\PermissionManager\isBlockedFrom(), User\isBot(), User\isEmailConfirmed(), MediaWiki\Permissions\PermissionManager\isEveryoneAllowed(), Article\isFileCacheable(), User\isHidden(), TransformationalImageHandler\isImageAreaOkForThumbnaling(), User\isLocked(), NamespaceInfo\isMovable(), Title\isMovable(), ProxyLookup\isTrustedProxy(), User\isUsableName(), MovePage\isValidMove(), ApiMain\lacksSameOriginSecurity(), SpecialWhatLinksHere\listItem(), ChangeTags\listSoftwareActivatedTags(), ChangeTags\listSoftwareDefinedTags(), MediaWiki\Interwiki\ClassicInterwikiLookup\load(), User\load(), User\loadDefaults(), ImagePage\loadFile(), User\loadFromDatabase(), ImageGalleryBase\loadModes(), DifferenceEngine\loadNewText(), User\loadOptions(), DifferenceEngine\loadRevisionIds(), MediaWiki\Session\SessionManager\loadSessionInfoFromStore(), DifferenceEngine\loadText(), MWExceptionHandler\logError(), MWExceptionHandler\logException(), BotPassword\loginHook(), LogEventsList\logLine(), User\logout(), MediaWiki\main(), ContentSecurityPolicy\makeCSPDirectives(), Linker\makeExternalImage(), Linker\makeExternalLink(), Linker\makeImageLink(), Linker\makeMediaLinkFile(), ApiParse\makeParserOptions(), MediaWiki\Shell\Shell\makeScriptCommand(), Linker\makeSelfLinkObj(), DifferenceEngine\markPatrolledLink(), MergeHistory\merge(), MovePage\moveToInternal(), MovePage\moveUnsafe(), ChangesList\newFromContext(), UserArray\newFromResult(), TitleArray\newFromResult(), Article\newFromTitle(), MediaWiki\MediaWikiServices\newInstance(), EditPage\noSuchSectionPage(), SpecialMute\onSubmit(), SpecialChangeContentModel\onSubmit(), SpecialUserLogout\onSuccess(), RawAction\onView(), InfoAction\onView(), HistoryAction\onView(), XmlDumpWriter\openPage(), ImagePage\openShowImage(), ParserOptions\optionsHash(), MediaWiki\Widget\Search\SearchFormWidget\optionsHtml(), WikiPage\pageData(), MediaWiki\Storage\PageEditStash\parseAndCache(), SearchEngine\parseNamespacePrefixes(), MediaWiki\performAction(), AuthManagerSpecialPage\performAuthenticationStep(), MediaWiki\performRequest(), MediaWiki\Session\CookieSessionProvider\persistSession(), User\pingLimiter(), MediaWiki\Widget\Search\SearchFormWidget\powerSearchBox(), Skin\preloadExistence(), MediaWiki\Storage\DerivedPageDataUpdater\prepareContent(), SkinTemplate\prepareQuickTemplate(), SpecialBlock\preText(), SpecialBlock\processForm(), ApiQueryBase\processRow(), SpecialUnblock\processUnblock(), SpecialUpload\processUpload(), RecentChangesUpdateJob\purgeExpiredRows(), LocalFile\purgeOldThumbnails(), LocalFile\purgeThumbnails(), DeletedContribsPager\reallyDoQuery(), ContribsPager\reallyDoQuery(), LocalisationCache\recache(), EnhancedChangesList\recentChangesBlockLine(), OldChangesList\recentChangesLine(), LocalFile\recordUpload2(), MessageCache\refreshAndReplaceInternal(), SpecialWatchlist\registerFilters(), ChangesListSpecialPage\registerFilters(), User\removeGroup(), RenameuserSQL\rename(), MediaWiki\Widget\Search\FullSearchResultWidget\render(), DifferenceEngine\renderNewRevision(), VectorTemplate\renderPortals(), LinkHolderArray\replaceInternal(), WikitextContent\replaceSection(), ImportReporter\reportPage(), User\requiresHTTPS(), WatchedItemStore\resetNotificationTimestamp(), User\resetOptions(), ApiQueryWatchlist\run(), SpecialPage\run(), MediaWiki\Linker\LinkRenderer\runBeginHook(), MediaWiki\Linker\LinkRenderer\runLegacyBeginHook(), ChangesListSpecialPage\runMainQueryHook(), EditPage\runPostMergeFilters(), SpecialEditWatchlist\runWatchUnwatchCompleteHook(), ProtectionForm\save(), ParserCache\save(), RecentChange\save(), MediaWiki\Session\SessionBackend\save(), MediaWiki\Preferences\DefaultPreferencesFactory\saveFormData(), User\saveOptions(), MediaWiki\Storage\PageUpdater\saveRevision(), User\saveSettings(), SearchEngineConfig\searchableNamespaces(), PrefixSearch\searchBackend(), MediaWiki\Auth\AuthManager\securitySensitiveOperationStatus(), ApiQueryBase\select(), UserMailer\send(), User\sendConfirmationMail(), SpecialEmailUser\sendEmailForm(), UserMailer\sendInternal(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\sendNewAccountEmail(), WebResponse\setCookie(), User\setEmail(), User\setEmailAuthenticationTimestamp(), Article\setOldSubtitle(), MediaWiki\Auth\AuthManager\setSessionDataForUser(), SpecialNewpages\setup(), EditAction\show(), EditPage\showConflict(), SpecialSearch\showCreateLink(), DifferenceEngine\showDiff(), EditPage\showDiff(), DifferenceEngine\showDiffPage(), EditPage\showEditForm(), SpecialUndelete\showHistory(), SpecialAutoblockList\showList(), SpecialBookSources\showList(), SpecialBlockList\showList(), LogEventsList\showLogExtract(), ProtectionForm\showLogExtract(), Article\showMissingArticle(), Article\showPatrolFooter(), EditPage\showPreview(), Article\showRedirectedFromHeader(), SpecialSearch\showResults(), LoginHelper\showReturnToPage(), SpecialUndelete\showRevision(), EditPage\showStandardInputs(), ImagePage\showTOC(), EditPage\showTosSummary(), Article\showViewFooter(), SpecialEmailUser\submit(), Skin\subPageSubtitle(), SpecialUserLogin\successfulAction(), SpecialCreateAccount\successfulAction(), SkinTemplate\tabAction(), MediaWiki\Auth\ThrottlePreAuthenticationProvider\testForAccountCreation(), TraditionalImageGallery\toHTML(), ThumbnailImage\toHtml(), WikiPage\triggerOpportunisticLinksUpdate(), MediaWiki\tryNormaliseRedirect(), AuthManagerSpecialPage\trySubmit(), PageArchive\undelete(), SpecialUndelete\undelete(), PageArchive\undeleteRevisions(), WikiPage\updateCategoryCounts(), ChangeTags\updateTags(), HTMLFileCache\useFileCache(), Linker\userToolLinks(), UpdateMediaWiki\validateParamsAndArgs(), CategoryPage\view(), ImagePage\view(), Article\view(), wfCanIPUseHTTPS(), wfShellWikiCmd(), and XmlDumpWriter\writeRevision().

◆ runWithoutAbort()

static Hooks::runWithoutAbort (   $event,
array  $args = [],
  $deprecatedVersion = null 
)
static

Call hook functions defined in Hooks::register and $wgHooks.

Parameters
string$eventEvent name
array$argsArray of parameters passed to hook functions
string | null$deprecatedVersion[optional] Mark hook as deprecated with version number
Returns
bool Always true
Exceptions
MWExceptionIf a callback is invalid, unknown
UnexpectedValueExceptionIf a callback returns an abort value.
Since
1.30

Definition at line 231 of file Hooks.php.

References $args, and callHook().

Referenced by SkinTemplate\buildContentNavigationUrls(), SkinTemplate\buildPersonalUrls(), MediaWiki\Auth\AuthManager\continueAccountCreation(), ApiMain\getMaxLag(), ParserOutput\getText(), and ManualLogEntry\publish().

Member Data Documentation

◆ $handlers

Hooks::$handlers = []
staticprotected

Array of events mapped to an array of callbacks to be run when that event is triggered.

Definition at line 39 of file Hooks.php.


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