jayvdb added a comment.
A significant cause of this problem is that WikibasePage.text is a dict rather than a string as is expected (and quite logical given the name of the property). This causes _regex to fail badly, and _mwpfh is more graceful.
Another significant issue not yet solved is that textlib.extract_templates_and_params_regex is only able to support 'wikitext' -like text, specifically syntax which uses '{{' and '}}', and we dont have a use-case for extract_templates_and_params other than wikitext templates. The MW 'templates'/'transclusions' concept also includes Lua modules and possibly other extensions, but is there any benefit in extracting parameters from lua invocations? Probably not. And I doubt that mwpfh is likely to support Lua 'transclusions'.
So even if WikibasePage.text returned the raw JSON as a string, calling extract_templates_and_params is simply wasted computation.
So, I propose we move templatesWithParams from BasePage into Page.
TASK DETAIL https://phabricator.wikimedia.org/T71664
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: XZise, jayvdb Cc: pywikipedia-bugs, XZise, jayvdb
pywikipedia-bugs@lists.wikimedia.org