Page MenuHomePhabricator

ApiQuerySiteinfo should provide known and defined slot roles
Open, LowPublicFeature

Description

Feature summary:
ApiQuerySiteinfo should add a siprop 'slotroles' to provide known and defined slot roles including content_model and layout hints.
Example response:

{
    "batchcomplete": "",
    "query": {
        "slotroles": {
            "main": {
                "defined": "",
                "slot_role_layout": {
                    "display": "section",
                    "region": "center",
                    "placement": "append"
                },
                "content_model": "wikitext"
            },
            "jsondata": {
                "defined": "",
                "slot_role_layout": {
                    "display": "details",
                    "region": "footer",
                    "placement": "append"
                },
                "content_model": "json"
            },
            "deprecated": {
                "slot_role_layout": {
                    "display": "section",
                    "region": "center",
                    "placement": "append"
                },
                "content_model": "unknown"
            }
        }
    }
}

Example implementation

$result = $module->getResult();
$data = [];

$slotRoleRegistry = MediaWikiServices::getInstance()->getSlotRoleRegistry();
$definedRoles = $slotRoleRegistry->getDefinedRoles();
$knownRoles = $slotRoleRegistry->getKnownRoles();

foreach ( $knownRoles as $slotName ) {
	$defined = in_array( $slotName, $definedRoles );
	$slotRoleHandler = $slotRoleRegistry->getRoleHandler( $slotName );
	$data[$slotName]['defined'] = $defined;
	$data[$slotName]['slot_role_layout'] = $slotRoleHandler->getOutputLayoutHints();
	$data[$slotName]['content_model'] = $slotRoleHandler->getDefaultModel(Title::newFromDBkey(  "Main_Page" ));
}

$result->addValue(['query'], 'slots', $data);

Use case(s):
Enable bots to check if a slot role is defined and to retrieve it's content model

Benefits:
Currently there's (to my knowledge) no option to direct access this information via API. Fetching revisions of a page only provides access to slot roles already used within a page.

Details

Related Objects

StatusSubtypeAssignedTask
OpenBUG REPORTNone
OpenNone
StalledNone
OpenNone
OpenNone
DuplicateNone
OpenFeatureNone
OpenFeatureNone
DuplicateNone
ResolvedNone
ResolvedNone
OpenNone
OpenFeatureNone
OpenNone
ResolvedNone
ResolvedNone
OpenFeatureNone
OpenNone
OpenFeatureNone
StalledNone
OpenNone
OpenNone
OpenFeatureNone

Event Timeline

Reedy subscribed.

Your code looks fine (bar some very minor code style issues that CI will flag)...

Would you be able to submit it as a patch to gerrit?

Change 927324 had a related patch set uploaded (by Simon Stier; author: Simon Stier):

[mediawiki/core@master] api: add known and defined slot roles to siteinfo

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

Not sure how to update the documentation - directly in API:Siteinfo?

Not sure how to update the documentation - directly in API:Siteinfo?

Which documentation are you referring to?

Certainly, that page on mediawiki.org wouldn't be updated until the patch is actually merged :)

Certainly, that page on mediawiki.org wouldn't be updated until the patch is actually merged :)

Makes sense... =D

I was wondering how the api/i18n/qqq.json works, e. g.

{{doc-apihelp-param|query+siteinfo|slotrolestitle}}

Is this autogenerating a doc string?

I was wondering how the api/i18n/qqq.json works, e. g.

{{doc-apihelp-param|query+siteinfo|slotrolestitle}}

Is this autogenerating a doc string?

https://translatewiki.net/wiki/Template:Doc-apihelp-param

@Simontaurus Removing task assignee as this open task has been assigned for more than two years - See the email sent to task assignee on 2025-11-25.
Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be welcome! :)
If this task has been resolved in the meantime, or should not be worked on by anybody ("declined"), please update its task status via "Add Action… 🡒 Change Status".
Also see https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator. Thanks!

OWresch-WMF lowered the priority of this task from Medium to Low.Feb 11 2026, 2:28 PM
OWresch-WMF added a project: good first task.

Thank you for tagging this task with good first task for Wikimedia newcomers!

Newcomers often may not be aware of things that may seem obvious to seasoned contributors, so please take a moment to reflect on how this task might look to somebody who has never contributed to Wikimedia projects.

A good first task is a self-contained, non-controversial task with a clear approach. It should be well-described with pointers to help a completely new contributor, for example it should clearly point to the codebase URL and provide clear steps to help a contributor get set up for success. We've included some guidelines at https://phabricator.wikimedia.org/tag/good_first_task/ !

Thank you for helping us drive new contributions to our projects <3

Hi! I'm Manish, a 2nd-year CS student from India interested in contributing to MediaWiki for GSoC 2026.

I'm familiar with JavaScript, HTML, CSS, and have experience with web development and API integrations. This task on ApiQuerySiteinfo looks interesting as it involves enhancing the MediaWiki API to provide known and defined slot roles.

I'd like to work on this task. Please let me know if I can proceed or if there are any specific steps I should follow.

Thanks!

@Manishhdev: Hi and welcome! See the placeholder text in the comment field pointing to https://www.mediawiki.org/wiki/New_Developers - thanks!

Change #927324 abandoned by Hashar:

[mediawiki/core@master] api: add known slot roles to site- and pageinfo

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

Change #927324 restored by Thcipriani:

[mediawiki/core@master] api: add known slot roles to site- and pageinfo

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