lkucharczyk / mediawiki-PortableInfobox

Port of Fandom's https://github.com/Wikia/app/tree/dev/extensions/wikia/PortableInfobox extension to the MediaWiki 1.32+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API page extract blank with exintro

HilbertGilbertson opened this issue · comments

When using the API to retrieve content, pages with a PortableInfobox will return an empty extract field.

https://mywiki.com/w/api.php?prop=extracts&explaintext=&exintro=&titles=My%20Page&format=json&action=query&redirects=

Result:
{"batchcomplete":"","query":{"pages":{"6":{"pageid":6,"ns":0,"title":"My Page","extract":""}}}}

Expected result:
{"batchcomplete":"","query":{"pages":{"6":{"pageid":6,"ns":0,"title":"My Page","extract":"The opening text of the page. Some more fascinating information about my page, serving as an excellent summary useful in external applications."}}}}

Removing the PortableInfobox restores the extract contents.

Standard info boxes do not, as far as I know, affect the output of the extract field (e.g. https://en.wikipedia.org/w/api.php?prop=extracts&explaintext=&exintro=&titles=Google&format=json&action=query&redirects=)

I can't reproduce this issue with TextExtracts master branch, PortableInfobox master branch and MW 1.32-alpha. Could you provide more details?

Issue is caused by TextExtracts itself. when it tries to extract the first section of an article and it finds a cached parser output, it cuts its text to the first heading tag (TextExtracts/includes/ApiQueryExtracts.php#L237-L246, TextExtracts/includes/ApiQueryExtracts.php#L211-L213). PIs use h2 and h3 tags as section headers and data labels, so everything below an infobox is cut.

I've added an option to use divs instead, as these may cause more incompatibilities with other extensions and skins (I had to make some skin-specific fixes to the stylesheet already). Just add following line to the LocalSettings.php:

$wgPortableInfoboxUseHeadings = false;