Fix serialization adding empty autovalue when not needed

The autovalue field appears to be the only one with this edge-case.
This is because all other fields are either multi-lingual and
processed by the `….allowLanguages` code path above, or because
of other special-case handling somewhere else.

The idea is:
* Non-empty values are always added.
* When the property (in this case `"autovalue": "…"` existed
  before, it's kept, even if it's now empty.

Bug: T295074
Change-Id: Ie4d9825b89edb4bbbbc4283dc48e9113e537869a
This commit is contained in:
Thiemo Kreuz 2021-11-29 10:49:32 +01:00
parent baaaa4209c
commit 2b2033c6ec

View file

@ -1074,17 +1074,20 @@ Model.prototype.outputTemplateData = function () {
default:
// Check if there's a value in the model
if ( this.params[ key ][ prop ] !== undefined ) {
var compareOrig = original.params[ oldKey ] && original.params[ oldKey ][ prop ];
if ( allProps[ prop ].allowLanguages ) {
normalizedValue = this.propRemoveUnusedLanguages( this.params[ key ][ prop ] );
// Check if this should be displayed with language object or directly as string
var compareOrig = original.params[ oldKey ] ? original.params[ oldKey ][ prop ] : {};
if ( this.isOutputInLanguageObject( compareOrig, normalizedValue ) ) {
if ( this.isOutputInLanguageObject( compareOrig || {}, normalizedValue ) ) {
result.params[ name ][ prop ] = normalizedValue;
} else {
// Store only one language as a string
result.params[ name ][ prop ] = normalizedValue[ defaultLang ];
}
} else {
} else if ( this.params[ key ][ prop ] ||
// Add empty strings only if the property existed before (empty or not)
compareOrig !== undefined
) {
// Set up the result
result.params[ name ][ prop ] = this.params[ key ][ prop ];
}