Page MenuHomePhabricator

User requirements conditions hooks: set the condition type as string|int
Closed, ResolvedPublic

Description

Until MediaWiki 1.45, AutopromoteConditionHook accepted any datatype as the condition type and had a doc comment saying that it should be a string. I practice, strings and ints were passed. Given that we'd like to actually specify type hints on UserRequirementsConditionHook and UserRequirementsConditionDisplayHook, the practice should be reconciled into one of two options:

  1. Specify string|int as parameter type in the hooks. Extensions would require no changes to adapt.
  2. Convert condition type to string and then have only string as accepted parameter type. Extensions would need to adjust the type of the value they compare to.

The first option will sanction the current state of passing strings or ints to the hooks, unlike specified in the documentation for AutopromoteConditionHook. This will be the option to go.

Acceptance criteria

  • UserRequirementsConditionHook and UserRequirementsConditionDisplayHook define the parameters as string|int
  • FlaggedRevs is updated to have string|int type specified
  • CentralAuth is updated to have string|int type specified
  • OATHAuth is updated to have string|int type specified
  • TorBlock is updated to have string|int type specified

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1261414 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/FlaggedRevs@master] Prepare user requirements condition hooks for string-only $type

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

Change #1261415 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/CentralAuth@master] Prepare user requirements condition hooks for string-only $type

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

Change #1261414 abandoned by Mszwarc:

[mediawiki/extensions/FlaggedRevs@master] Prepare user requirements condition hooks for string-only $type

Reason:

string|int will be kept as type

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

Change #1261415 abandoned by Mszwarc:

[mediawiki/extensions/CentralAuth@master] Prepare user requirements condition hooks for string-only $type

Reason:

string|int will be kept as type

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

mszwarc renamed this task from User requirements conditions hooks: pass the condition type as string only to User requirements conditions hooks: set the condition type as string|int.Mar 27 2026, 11:20 AM
mszwarc updated the task description. (Show Details)

Change #1266206 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/CentralAuth@master] Add type hint to user requirements conditions hooks

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

Change #1266207 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/FlaggedRevs@master] Add type hint to user requirements conditions hooks

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

Change #1266208 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/OATHAuth@master] Add type hint to UserRequirementsCondition hook

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

Change #1266209 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/TorBlock@master] Add type hint to UserRequirementsCondition hook

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

Change #1266209 merged by jenkins-bot:

[mediawiki/extensions/TorBlock@master] Add type hint to UserRequirementsCondition hook

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

Change #1266208 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@master] Add type hint to UserRequirementsCondition hook

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

Change #1266207 merged by jenkins-bot:

[mediawiki/extensions/FlaggedRevs@master] Add type hint to user requirements conditions hooks

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

Change #1266206 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Add type hint to user requirements conditions hooks

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