Steps to reproduce:
- Set up a MediaWiki instance that uses PostgreSQL
- Set up TemplateData
- Add templatedata to a template and save (or do a null edit to a page with existing templatedata)
Expected results:
VisualError should show information about that template.
Actual results:
VisualEditor is unable to show any information about the template. Looking at the API requests in the browser console reveals that this is because the templatedata API fails with the following error:
Code: templatedata-corrupt
Message: templatedata contains invalid data: Syntax error in JSON.
So I looked at the database and indeed, pp_value values for templatedata look really wrong...
mediawiki@localhost:wiki> select json_agg(t) from (select * from page_props where pp_propname='templatedata') t +-----------------------------------------------------------------------------------------+ | json_agg | |-----------------------------------------------------------------------------------------| | [{"pp_page":235,"pp_propname":"templatedata","pp_value":"\u001f?\b","pp_sortkey":null}] | +-----------------------------------------------------------------------------------------+
It looks like the TemplateData extension stores the templatedata JSON as a gzipped string. However the pp_value column type is text, which means the binary data is getting truncated at the first null byte.
For some reason, changing the column type to bytea manually (with alter table page_props alter column pp_value type bytea using (pp_value::bytea)) does not fix the issue. The data is still visibly getting truncated at the same place. Any help would be appreciated.