Page MenuHomePhabricator

Track number of times TemplateData is changed in the editor vs. by writing JSON
Closed, ResolvedPublic2 Estimated Story Points


  • Track successful edits to template pages, …
  • … but only if the <templatedata> section (or the {{templatedata}} template in dewiki) was touched.
  • Additionally track if the TemplateData editor was opened before the page was saved. (The dialog might need to set a hidden bool that is send to the server when saving. Or find another way to combine these 2 dimensions. Might as well be possible to do it entirely on the client, i.e. hook into the save button.)
  • Ideally track if actual changes have been made in the editor, if possible. Otherwise just track the fact that the dialog was opened and confirmed at least once.

Other requirements:

  • Add the topic to the inclusion list for sanitization


  • It sounds like there must be client-side code involved to track if the dialog was used. The server has no way to distinguish between manual and interactive edits otherwise.
  • To reduce complexity, try to do all tracking client-side.

Event Timeline

I did a bit of investigation for this task. In the TemplateData extension, in TemplateDataHooks.php, there is a line $parser->getOutput()->setProperty( 'templatedata', … ) that stores a TemplateData blob in the page properties table. This code is executed after all templates are expanded, i.e. this will work with the German {{templatedata}} template.

The most trivial comparison might look like this:

$props = PageProps::getInstance()->getProperties( $title, 'templatedata' );
if ( $props && $props[ $title->getArticleID() ] !== $ti->getJSONForDatabase() ) {
	// TemplateData for this page changed

This compares the gzipped byte stream, i.e. this will track any change, even irrelevant changes to the formatting of the JSON. To avoid this, we could un-gzip and normalize both JSON blobs before comparing them.

Change 644506 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/TemplateData@master] Track when (relevant) changes are made to <templatedata> tags

Lena_WMDE set the point value for this task to 2.Dec 2 2020, 10:31 AM