Description
Steps to reproduce:
- With a user that has no higher permissions (only editor),
- Go to https://wikifunctions.beta.wmflabs.org/wiki/Z11
- Click on "Edit source"
- Edit the multilingual data of any key
- Try to publish
Observed behavior:
- The operation is not successful
- Privileges-related message observed sometimes
Additional details
When initializing an edit page for types, because a type might have many fields which are not present, we initialize these fields with falsy values, so that they can be edited if the user intends to.
These are:
- For every key, the Z3K4/is identity flag: initialize to Z42/False
- Z4K3/validator, Z4K4/equality, Z4K5/renderer and Z4K6/parser: initialized to empty references
- Z4K7/converters to code and Z4K8/converters from code: initialized to empty arrays
Before submission, those keys with invalid falsy values are deleted:
- Z4K3/validator, Z4K4/equality, Z4K5/renderer and Z4K6/parser
But valid falsy values are left (Z3K4s, Z4K7 and Z4K8).
This implies that if the editor has no type editing rights, the operation will fail and the reason will be incomprehensible to the editor.
Solution
- Only initialize type fields if the editor has the ability to edit them (there's wikilambda-edit-type permission present)
- DISCUSS: We should contemplate building scripts to keep production types up to date; there's been multiple changes in the function model (so many keys added to types, specially), and production objects are outdated, which means having to add these hardcoded initializations to the front-end.
Completion checklist
- Before closing this task, review one by one the checklist available here: https://www.mediawiki.org/wiki/Abstract_Wikipedia_team/Definition_of_Done#Front-end_Task/Bug_Completion_Checklist