Page MenuHomePhabricator

Make hook entries in extension.json less verbose
Closed, ResolvedPublic

Description

We should be able to write:

{
	"Hooks": {
		"ParserFirstCallInit": [
			"MassMessageHooks::onParserFirstCallInit"
		],
		"SpecialStatsAddExtra": [
			"MassMessageHooks::onSpecialStatsAddExtra"
		],
		"APIQuerySiteInfoStatisticsInfo": [
			"MassMessageHooks::onAPIQuerySiteInfoStatisticsInfo"
		],
		"RenameUserPreRename": [
			"MassMessageHooks::onRenameUserPreRename"
		],
		"UserGetReservedNames": [
			"MassMessageHooks::onUserGetReservedNames"
		],
		"UnitTestsList": [
			"MassMessageHooks::onUnitTestsList"
		],
		"BeforeEchoEventInsert": [
			"MassMessageHooks::onBeforeEchoEventInsert"
		],
		"SkinTemplateNavigation": [
			"MassMessageHooks::onSkinTemplateNavigation"
		],
		"BeforePageDisplay": [
			"MassMessageHooks::onBeforePageDisplay"
		],
		"ListDefinedTags": [
			"MassMessageHooks::onRegisterTags"
		],
		"ChangeTagsListActive": [
			"MassMessageHooks::onRegisterTags"
		]
	}
}

as

{
	"Hooks": {
		"ParserFirstCallInit": "MassMessageHooks::onParserFirstCallInit",
		"SpecialStatsAddExtra": "MassMessageHooks::onSpecialStatsAddExtra",
		"APIQuerySiteInfoStatisticsInfo": "MassMessageHooks::onAPIQuerySiteInfoStatisticsInfo",
		"RenameUserPreRename": "MassMessageHooks::onRenameUserPreRename",
		"UserGetReservedNames": "MassMessageHooks::onUserGetReservedNames",
		"UnitTestsList": "MassMessageHooks::onUnitTestsList",
		"BeforeEchoEventInsert": "MassMessageHooks::onBeforeEchoEventInsert",
		"SkinTemplateNavigation": "MassMessageHooks::onSkinTemplateNavigation",
		"BeforePageDisplay": "MassMessageHooks::onBeforePageDisplay",
		"ListDefinedTags": "MassMessageHooks::onRegisterTags",
		"ChangeTagsListActive": "MassMessageHooks::onRegisterTags"

	}
}

That's so much better. And if for some reason an extension has two hooks for the same event, they can use the array syntax. But we should encourage the string one by default (aka have the conversion script use it)

Details

Related Gerrit Patches:

Event Timeline

Legoktm created this task.Apr 26 2016, 1:21 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 26 2016, 1:21 AM
Florian claimed this task.Apr 29 2016, 9:11 PM
Florian triaged this task as Medium priority.

Change 286241 had a related patch set uploaded (by Florianschmidtwelzow):
registration: Allow string value for Hooks

https://gerrit.wikimedia.org/r/286241

Change 286241 merged by jenkins-bot:
registration: Allow string value for Hooks

https://gerrit.wikimedia.org/r/286241

Jdforrester-WMF closed this task as Resolved.May 7 2016, 11:44 AM
Jdforrester-WMF removed a project: Patch-For-Review.