From 502c84b1ee6ea375248baa740f21671c44919616 Mon Sep 17 00:00:00 2001 From: Friedrich Weber Date: Tue, 9 Apr 2024 10:16:11 +0200 Subject: [PATCH] window: edit: avoid sharing custom config objects between subclasses Currently, `Proxmox.window.Edit` initializes `extraRequestParams` and `submitOptions` to two objects that, if not overwritten, are shared between all instances of subclasses. This bears the danger of modifying the shared object in a subclass instead of overwriting it, which affects all edit windows of the current session and can cause hard-to-catch GUI bugs. One such bug is the following: Currently, the `PVE.pool.AddStorage` component inadvertently adds `poolid` to an `extraRequestParams` object that is shared between all instances of `Proxmox.window.Edit`. As a result, after adding a storage to a pool, opening any edit window will send a GET request with a superfluous `poolid` parameter and cause an error in the GUI: > Parameter verification failed. (400) > poolid: property is not defined in schema and the schema does not > allow additional properties This breaks all edit windows of the current session. A workaround is to reload the current browser session. To avoid this class of bugs in the future, implement a constructor that makes copies of `extraRequestParams` and `submitOptions`. This ensures that any subclass instance modifies only its own copies, and modifications do not leak to other subclass instances. Suggested-by: Stefan Sterz Suggested-by: Thomas Lamprecht Signed-off-by: Friedrich Weber Tested-by: Stefan Sterz --- src/window/Edit.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/window/Edit.js b/src/window/Edit.js index d4a2b55..c55ff79 100644 --- a/src/window/Edit.js +++ b/src/window/Edit.js @@ -69,6 +69,15 @@ Ext.define('Proxmox.window.Edit', { // onlineHelp of our first item, if set. onlineHelp: undefined, + 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.callParent(arguments); + }, + isValid: function() { let me = this;