MediaWiki  1.28.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 Protected Attributes

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

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

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 66 of file Hooks.php.

References $name.

Referenced by TestSetup\applyInitialConfig(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\hookMailer(), HooksTest\setUp(), ParserTestRunner\setupInterwikis(), and ParserTestRunner\staticSetup().

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 97 of file Hooks.php.

References $name, $wgHooks, and global.

Referenced by HooksTest\testNewStyleHookInteraction().

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 83 of file Hooks.php.

References $name, $wgHooks, and global.

Referenced by MediaWiki\Linker\LinkRenderer\buildAElement(), ChangeTags\listSoftwareActivatedTags(), ChangeTags\listSoftwareDefinedTags(), MediaWiki\Linker\LinkRenderer\runLegacyBeginHook(), ContentHandler\runLegacyHooks(), and HooksTest\testNewStyleHookInteraction().

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

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

For a certain 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.

Parameters
string$eventEvent name
array$argsArray of parameters passed to hook functions
string | null$deprecatedVersionOptionally, 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 131 of file Hooks.php.

References $args, $retval, as, and wfDeprecated().

Referenced by Parser\__clone(), ExtensionsTestSuite\__construct(), Languages\__construct(), DatabaseUpdater\__construct(), LinksUpdate\__construct(), ApiQuery\__construct(), DatabaseOracle\__construct(), ApiMain\__construct(), RedirectSpecialArticle\__construct(), ResourceLoader\__construct(), UploadForm\__construct(), EmailNotification\actuallyNotifyOnPageChange(), User\addAutopromoteOnceGroups(), OutputPage\addCategoryLinks(), User\addGroup(), OutputPage\addParserOutputMetadata(), OutputPage\addParserOutputText(), Skin\afterContentHook(), SpecialPageLanguage\alterForm(), ApiQuerySiteinfo\appendGeneralInfo(), ApiQuerySiteinfo\appendStatistics(), MimeMagic\applyDefaultParameters(), SpecialChangeEmail\attemptChange(), EditPage\attemptSave(), SearchEngine\augmentSearchResults(), MediaWiki\Auth\AuthManager\autoCreateUser(), MediaWiki\Auth\AuthManager\beginAuthentication(), BenchmarkHooks\benchHooks(), Skin\bottomScripts(), MediaWiki\Linker\LinkRenderer\buildAElement(), SkinTemplate\buildContentNavigationUrls(), ProtectionForm\buildForm(), SkinTemplate\buildNavUrls(), SkinTemplate\buildPersonalUrls(), SpecialEditWatchlist\buildRemoveLine(), Skin\buildSidebar(), ContentHandler\canBeUsedOn(), ChangeTags\canCreateTag(), ChangeTags\canDeleteTag(), User\canSendEmail(), EmailNotification\canSendUserTalkEmail(), Autopromote\checkCondition(), ApiMain\checkConditionalRequestHeaders(), ApiMain\checkExecutePermissions(), OutputPage\checkLastModified(), User\checkPasswordValidity(), Title\checkPermissionHooks(), MovePage\checkPermissions(), Title\checkQuickPermissions(), Title\checkReadPermissions(), User\clearNotification(), Parser\clearState(), ApiFormatBase\closePrinter(), WikiPage\commitRollback(), SearchEngine\completionSearchBackend(), Article\confirmDelete(), User\confirmEmail(), MediaWiki\Auth\AuthManager\continueAccountCreation(), MediaWiki\Auth\AuthManager\continueAuthentication(), AbstractContent\convert(), create_function(), ContentHandler\createDifferenceEngine(), UploadBase\createFromRequest(), ChangeTags\deleteTagEverywhere(), EditPage\displayViewSourcePage(), Block\doAutoblock(), UsersPager\doBatchLookups(), HistoryPager\doBatchLookups(), CategoryViewer\doCategoryQuery(), WikiPage\doCreate(), FileDeleteForm\doDelete(), Article\doDelete(), WikiPage\doDeleteArticleReal(), WikiPage\doEditContent(), Skin\doEditSectionLink(), WikiPage\doEditUpdates(), WikiImporter\doImport(), Language\doMagicHook(), SpecialWatchlist\doMainQuery(), RecentChange\doMarkPatrolled(), WikiPage\doModify(), RevDelRevisionList\doPostCommitUpdates(), WikiPage\doPurge(), RefreshLinks\doRefreshLinks(), Block\doRetroactiveAutoblock(), UserrightsPage\doSaveUserGroups(), MovePageForm\doSubmit(), TransformationalImageHandler\doTransform(), WatchAction\doUnwatch(), LinksUpdate\doUpdate(), WikiPage\doUpdateRestrictions(), LinkHolderArray\doVariants(), WikiPage\doViewUpdates(), WatchAction\doWatch(), WikiExporter\dumpFrom(), EditPage\edit(), ApiUndelete\execute(), ApiExpandTemplates\execute(), SpecialContributions\execute(), SpecialLog\execute(), ApiChangeAuthenticationData\execute(), ApiEditPage\execute(), ApiLogout\execute(), SpecialStatistics\execute(), SpecialUserLogout\execute(), ApiParse\execute(), ApiRemoveAuthenticationData\execute(), ApiLogin\execute(), SpecialImport\execute(), ApiOpenSearch\execute(), SpecialEmailUser\execute(), PasswordReset\execute(), SpecialUpload\execute(), ApiQuery\execute(), ApiMain\executeAction(), ApiPageSet\executeInternal(), Title\exists(), ApiQueryInfo\extractPageInfo(), Collation\factory(), WikiPage\factory(), ApiFeedContributions\feedItem(), FormatMetadata\fetchExtendedMetadata(), AuthManagerSpecialPage\fieldInfoToFormDescriptor(), WikiImporter\finishImportPage(), Parser\firstCallInit(), Linker\formatAutocomments(), Parser\formatHeadings(), UsersPager\formatRow(), DeletedContribsPager\formatRow(), ContribsPager\formatRow(), File\generateAndSaveThumb(), CategoryViewer\generateLink(), ParserCache\get(), MessageCache\get(), LegacyLogFormatter\getActionLinks(), ApiImport\getAllowedImportSources(), User\getAllRights(), ChangesList\getArticleLink(), Autopromote\getAutopromoteGroups(), User\getBlockedStatus(), OutputPage\getCacheVaryCookies(), MWNamespace\getCanonicalNamespaces(), Title\getCanonicalURL(), Title\getCategorySortkey(), Title\getCdnUrls(), CheckLanguageCLI\getCheckBlacklist(), EditPage\getCheckboxes(), BacklinkCache\getConditions(), ResourceLoaderStartUpModule\getConfigSettings(), Skin\getCopyright(), EditPage\getCopyrightWarning(), SpecialRecentChanges\getCustomFilters(), SpecialWatchlist\getCustomFilters(), ChangesListSpecialPage\getCustomFilters(), ContentHandler\getDataForSearchIndex(), ContentHandler\getDefaultModelFor(), User\getDefaultOptions(), UsersPager\getDefaultQuery(), WikiPage\getDeletionUpdates(), ResourceLoaderForeignApiModule\getDependencies(), DifferenceEngine\getDiffBody(), MagicWord\getDoubleUnderscoreArray(), EditPage\getEditButtons(), Title\getEditNotices(), EditPage\getEditToolbar(), User\getEffectiveGroups(), User\getEmail(), User\getEmailAuthenticationTimestamp(), FormatMetadata\getExtendedMetadataFromHook(), SpecialVersion\getExtensionTypes(), LogEventsList\getExtraInputs(), SpecialRecentChanges\getExtraOptions(), LoginSignupSpecialPage\getFakeTemplate(), ApiBase\getFinalDescription(), ApiBase\getFinalParamDescription(), ApiBase\getFinalParams(), FormAction\getForm(), FormSpecialPage\getForm(), SpecialBlock\getFormFields(), ContentHandler\getForModelID(), Title\getFullURL(), User\getGlobalBlock(), OutputPage\getHeadLinksArray(), ApiHelp\getHelpInternal(), LocalFile\getHistory(), Language\getHumanTimestamp(), User\getImplicitGroups(), Title\getInternalURL(), OutputPage\getJSVars(), RequestContext\getLanguage(), SkinTemplate\getLanguages(), PreferencesForm\getLegend(), IRCColourfulRCFeedFormatter\getLine(), EnhancedChangesList\getLineData(), Title\getLocalURL(), EnhancedChangesList\getLogText(), SpecialLog\getLogTypesOnUser(), DifferenceEngine\getMarkPatrolledLinkInfo(), Language\getMessagesFileName(), MediaHandler\getMetadataVersion(), MessageCache\getMsgFromNamespace(), Language\getNamespaces(), SearchNearMatcher\getNearMatch(), SearchNearMatcher\getNearMatchInternal(), User\getNewMessageLinks(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProvider\getNewPasswordExpiry(), Skin\getNewtalks(), SpecialEditWatchlist\getNormalForm(), UsersPager\getPageHeader(), ContentHandler\getPageLanguage(), SpecialPageFactory\getPageList(), QueryPage\getPages(), AbstractContent\getParserOutput(), WebRequest\getPathInfo(), SpecialEmailUser\getPermissionsError(), UserPasswordPolicy\getPoliciesForUser(), Skin\getPoweredBy(), Preferences\getPreferences(), BacklinkCache\getPrefix(), EditPage\getPreviewLimitReport(), EditPage\getPreviewText(), ShortPagesPage\getQueryInfo(), NewPagesPager\getQueryInfo(), LonelyPagesPage\getQueryInfo(), WantedPagesPage\getQueryInfo(), UsersPager\getQueryInfo(), RandomPage\getQueryInfo(), ContribsPager\getQueryInfo(), HistoryPager\getQueryInfo(), RandomPage\getRandomTitle(), MWTimestamp\getRelativeTimestamp(), Title\getRestrictionTypes(), User\getRights(), ApiRsd\getRsdApiList(), SearchEngine\getSearchIndexFields(), SpecialSearch\getSearchProfiles(), AbstractContent\getSecondaryDataUpdates(), BaseTemplate\getSidebar(), Skin\getSiteNotice(), RequestContext\getSkin(), UploadForm\getSourceSection(), Language\getSpecialPageAliases(), ApiQueryRevisions\getTokenFunctions(), ApiQueryRecentChanges\getTokenFunctions(), ApiQueryUsers\getTokenFunctions(), ApiQueryInfo\getTokenFunctions(), SpecialResetTokens\getTokensList(), ApiTokens\getTokenTypes(), ApiQueryTokens\getTokenTypeSalts(), BaseTemplate\getToolbox(), LoginHelper\getValidErrorMessages(), MagicWord\getVariableIDs(), Parser\getVariableValue(), GitInfo\getViewers(), SpecialVersion\getwgVersionLinked(), SpecialSearch\goResult(), ApiMain\handleException(), WikiImporter\handleLogItem(), WikiImporter\handlePage(), WikiImporter\handleRevision(), EditPage\handleStatus(), WikiImporter\handleUpload(), OutputPage\headElement(), HistoryPager\historyLine(), ImageHistoryList\imageHistoryLine(), EditPage\importFormData(), LinksUpdate\incrTableUpdate(), ChangesList\initChangesListRows(), SearchResult\initFromTitle(), MediaWiki\initializeArticle(), MediaWiki\Auth\AuthManagerAuthPlugin\initUser(), Revision\insertOn(), EditPage\internalAttemptSave(), Parser\internalParse(), Parser\internalParseHalfParsed(), User\invalidateEmail(), UploadFromUrl\isAllowedUrl(), Title\isAlwaysKnown(), User\isBlockedFrom(), User\isBot(), Title\isCssOrJsPage(), User\isEmailConfirmed(), User\isEveryoneAllowed(), Article\isFileCacheable(), User\isHidden(), TransformationalImageHandler\isImageAreaOkForThumbnaling(), User\isLocked(), MWNamespace\isMovable(), Title\isMovable(), ProxyLookup\isTrustedProxy(), User\isUsableName(), MovePage\isValidMove(), ApiMain\lacksSameOriginSecurity(), SpecialWhatLinksHere\listItem(), ChangeTags\listSoftwareActivatedTags(), ChangeTags\listSoftwareDefinedTags(), ParserTestRunner\listTables(), MediaWiki\Interwiki\ClassicInterwikiLookup\load(), User\load(), User\loadDefaults(), ImagePage\loadFile(), User\loadFromDatabase(), User\loadFromSession(), ImageGalleryBase\loadModes(), User\loadOptions(), DifferenceEngine\loadRevisionIds(), MediaWiki\Session\SessionManager\loadSessionInfoFromStore(), MWExceptionHandler\logError(), MWExceptionHandler\logException(), User\logout(), MediaWiki\main(), Linker\makeExternalImage(), Linker\makeExternalLink(), Parser\makeImage(), Linker\makeImageLink(), Linker\makeMediaLinkFile(), ApiParse\makeParserOptions(), Linker\makeSelfLinkObj(), DifferenceEngine\markPatrolledLink(), MergeHistory\merge(), MovePage\move(), MovePage\moveToInternal(), ChangesList\newFromContext(), UserArray\newFromResult(), TitleArray\newFromResult(), Article\newFromTitle(), MediaWiki\MediaWikiServices\newInstance(), SearchEngine\normalizeNamespaces(), EditPage\noSuchSectionPage(), SpecialChangeCredentials\onAuthChangeFormFields(), SpecialChangeContentModel\onSubmit(), RawAction\onView(), InfoAction\onView(), HistoryAction\onView(), XmlDumpWriter\openPage(), ImagePage\openShowImage(), ParserOptions\optionsHash(), OutputPage\output(), MediaWikiTestCase\overrideMwServices(), WikiPage\pageData(), Parser\parse(), ApiStashEdit\parseAndStash(), MediaWiki\performAction(), AuthManagerSpecialPage\performAuthenticationStep(), MediaWiki\performRequest(), UploadBase\performUpload(), MediaWiki\Session\CookieSessionProvider\persistSession(), ParserTestRunner\perTestSetup(), User\pingLimiter(), SpecialSearch\powerSearchBox(), Skin\preloadExistence(), WikiPage\prepareContentForEdit(), SkinTemplate\prepareQuickTemplate(), Parser\preprocess(), SpecialBlock\preText(), SpecialBlock\processForm(), ApiQueryBase\processRow(), SpecialUpload\processUpload(), LocalFile\purgeOldThumbnails(), LocalFile\purgeThumbnails(), DeletedContribsPager\reallyDoQuery(), ContribsPager\reallyDoQuery(), LocalisationCache\recache(), EnhancedChangesList\recentChangesBlockLine(), OldChangesList\recentChangesLine(), LocalFile\recordUpload2(), Parser\recursiveTagParse(), ResourceLoader\registerTestModules(), User\removeGroup(), BaseTemplate\renderAfterPortlet(), Parser\renderImageGallery(), DifferenceEngine\renderNewRevision(), MessageCache\replace(), LinkHolderArray\replaceInternal(), WikitextContent\replaceSection(), ImportReporter\reportPage(), User\requiresHTTPS(), User\resetOptions(), SpecialPage\run(), MediaWiki\Linker\LinkRenderer\runBeginHook(), MediaWiki\Linker\LinkRenderer\runLegacyBeginHook(), ContentHandler\runLegacyHooks(), SpecialRecentChanges\runMainQueryHook(), SpecialWatchlist\runMainQueryHook(), ChangesListSpecialPage\runMainQueryHook(), EditPage\runPostMergeFilters(), UploadBase\runUploadStashFileHook(), ProtectionForm\save(), ParserCache\save(), RecentChange\save(), MediaWiki\Session\SessionBackend\save(), User\saveOptions(), User\saveSettings(), PrefixSearch\search(), SearchEngineConfig\searchableNamespaces(), PrefixSearch\searchBackend(), SpecialSearch\searchOptions(), MediaWiki\Auth\AuthManager\securitySensitiveOperationStatus(), ApiQueryBase\select(), UserMailer\send(), 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(), SpecialSearch\showHit(), SpecialBookSources\showList(), SpecialBlockList\showList(), LogEventsList\showLogExtract(), ProtectionForm\showLogExtract(), Article\showMissingArticle(), EditPage\showPreview(), Article\showRedirectedFromHeader(), SpecialSearch\showResults(), LoginHelper\showReturnToPage(), SpecialUndelete\showRevision(), EditPage\showStandardInputs(), ImagePage\showTOC(), EditPage\showTosSummary(), Article\showViewFooter(), SpecialVersion\softwareInformation(), Parser\statelessFetchTemplate(), SpecialEmailUser\submit(), Skin\subPageSubtitle(), SpecialCreateAccount\successfulAction(), SpecialUserLogin\successfulAction(), SkinTemplate\tabAction(), HooksTest\testFalseReturn(), HooksTest\testFatalError(), MediaWiki\Auth\LegacyHookPreAuthenticationProvider\testForAccountCreation(), MediaWiki\Auth\ThrottlePreAuthenticationProvider\testForAccountCreation(), MediaWiki\Auth\LegacyHookPreAuthenticationProvider\testForAuthentication(), HooksTest\testNewStyleHookInteraction(), HooksTest\testNewStyleHooks(), MediaWiki\Auth\AuthPluginPrimaryAuthenticationProviderTest\testOnLocalUserCreated(), MediaWiki\Auth\AuthPluginPrimaryAuthenticationProviderTest\testOnUserGroupsChanged(), MediaWiki\Auth\AuthPluginPrimaryAuthenticationProviderTest\testOnUserLoggedIn(), MediaWiki\Auth\AuthPluginPrimaryAuthenticationProviderTest\testOnUserSaveSettings(), HooksTest\testUncallableFunction(), MediaWiki\Auth\LegacyHookPreAuthenticationProvider\testUserForCreation(), TraditionalImageGallery\toHTML(), ThumbnailImage\toHtml(), WikiPage\triggerOpportunisticLinksUpdate(), Preferences\tryFormSubmit(), MediaWiki\tryNormaliseRedirect(), AuthManagerSpecialPage\trySubmit(), PageArchive\undelete(), SpecialUndelete\undelete(), PageArchive\undeleteRevisions(), SpecialEditWatchlist\unwatchTitles(), WikiPage\updateCategoryCounts(), MediaWiki\Auth\AuthManagerAuthPlugin\updateExternalDBGroups(), ChangeTags\updateTags(), MediaWiki\Auth\AuthManagerAuthPlugin\updateUser(), HTMLFileCache\useFileCache(), Linker\userToolLinks(), Sanitizer\validateEmail(), UploadBase\verifyFile(), UploadBase\verifyUpload(), CategoryPage\view(), ImagePage\view(), Article\view(), wfExtractThumbParams(), and XmlDumpWriter\writeRevision().

Member Data Documentation

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