[pve-devel] [PATCH widget-toolkit v3] window: edit: avoid sharing custom config objects between subclasses

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Apr 8 14:36:34 CEST 2024


Am 08/04/2024 um 12:36 schrieb Stefan Sterz:
> On Mon Apr 8, 2024 at 11:30 AM CEST, Friedrich Weber wrote:
>> +    constructor: function(conf) {
>> +	let me = this;
>> +	// make copies in order to prevent subclasses from accidentally writing
>> +	// to objects that are shared with other edit window subclasses
>> +	me.extraRequestParams = Object.assign({}, me.extraRequestParams);
>> +	me.submitOptions = Object.assign({}, me.submitOptions);
>> +	me.initConfig(conf);
>> +	me.callParent();
> 
> 
> so, this seems like a fix bug a) creates bug b) type of situation...
> this patch means that editing a pool allows changing the name suddenly,
> but since we don't support that in the backend, that just creates a new
> pool :/
> 
> this is due to the `editable` attribute depending on `isCreate`, which
> in turn depends on the configs poolid being set. to fix this, the config
> needs to also be passed to `callParent` so it can set the configurations
> there too. so this line should be:
> 
>     me.callParent([conf]);
> 
> sorry, could have noticed that earlier in my suggestion. also this needs
> to be an arrray as `callParent` expects a list of arguments to pass to
> parent's function and not the parameters themselves directly.

Using `me.callParent(arguments)` might be more proof to future changes and
arguments is an array (or well, iterator) already







More information about the pve-devel mailing list