Page MenuHomePhabricator

Babel extension automatically creates categories on page preview
Closed, ResolvedPublic

Description

When editing my #babel parameters, I made a test and inserted zh-hans-N in the English Wiktionary. I simply previewed the page in order to see the result and realized that the Babel categories had been automatically created at that time.

The categories should only be created on page save, and not on preview.


Version: master
Severity: normal

Details

Reference
bz40159

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:47 AM
bzimport set Reference to bz40159.

Thank you for your bug report.

[ Current code analysis ]

In the extension, the {{#babel}} is currently a tag to render. This uses setFunctionHook - https://www.mediawiki.org /wiki/Manual:Parser_functions#The_setFunctionHook_hook - and create needed categories.

The rendering operation is done in Babel::Render static method (Babel.class.php).

This method calls mGenerateCategories, which calls twice BabelAutoCreate::create to create relevant code and code/level categories.

[ Solutions to fix this ]

  1. Check $parser->mOptions->mIsPreview in Render() and add a automatic categories creation parameter to mGenerateCategories method (gerrit change 23508)
  1. Consider having an empty category isn't an issue (-> RESO WONTFIX)
  1. Add an option to let configure if we want or not the category automatic creation at preview time.

[ Side effect ]

User could want to create categories themselves in preview mode, if they see them not existent, or could avoid the code, being afraid this is wrong.