TL;DR: die regexp werden korrekt in frontend benutzt, aber die plugin-config-werte werden nicht in backend gespeichert. und ich bin zu dumm die problem quelle zu finden, also gebe ich auf.
aber zumindest hab ich die genaue problem gefunden. (sorry für englisch, bin zu faul meine notizen zu übersetzen)...
new patch:
```
diff --git a/themes/Backend/ExtJs/backend/base/component/Shopware.form.PluginPanel.js b/themes/Backend/ExtJs/backend/base/component/Shopware.form.PluginPanel.js
index f419c79..f268c12 100644
--- a/themes/Backend/ExtJs/backend/base/component/Shopware.form.PluginPanel.js
+++ b/themes/Backend/ExtJs/backend/base/component/Shopware.form.PluginPanel.js
@@ -257,6 +257,17 @@ Ext.define('Shopware.form.PluginPanel',
}
}
+ // TODO: see if other xtypes have more regexps, these are from xtype text.
+ [
+ "maskRe",
+ "regex",
+ "stripCharsRe"
+ ].forEach(function(opt){
+ if (Ext.isDefined(options[opt])) {
+ options[opt] = new RegExp(options[opt]);
+ }
+ });
+
var field = Ext.apply({
xtype: type,
name: name,
```
plugin Resources/config.xml:
```
foo_1
maskRe [a-z]
[a-z]
foo_2
regex ^[a-z]*$
^[a-z]*$
```
works: heres what get posted to https://shopware.vanilla/backend/config/saveForm when we remove all regex options from config.xml:
{"id":279,"label":"FoobarRegexConfig","name":"FoobarRegexConfig","description":"test regex in config.xml","elements":[{"id":1064,"name":"foo_1","value":null,"label":"maskRe [a-z]","description":null,"type":"text","required":false,"scope":0,"options":[],"values":[{"id":null,"shopId":1,"value":"asd"}]},{"id":1065,"name":"foo_2","value":null,"label":"regex ^[a-z]*$","description":null,"type":"text","required":false,"scope":0,"options":[],"values":[{"id":null,"shopId":1,"value":"asd"}]}]}
fails: and heres with regexp options:
{"id":279,"label":"FoobarRegexConfig","name":"FoobarRegexConfig","description":"test regex in config.xml","elements":[{"id":1064,"name":"foo_1","value":null,"label":"maskRe [a-z]","description":null,"type":"text","required":false,"scope":0,"options":{"maskRe":undefined},"values":[{"id":null,"shopId":1,"value":"asd"}]},{"id":1065,"name":"foo_2","value":null,"label":"regex ^[a-z]*$","description":null,"type":"text","required":false,"scope":0,"options":{"regex":undefined},"values":[{"id":null,"shopId":1,"value":"asd"}]}]}
the differences are, in working one:
"options":[]
in failing one:
"options":{"maskRe":undefined}
and the server error is:
[Mon May 13 11:11:59.066325 2019] [:error] [pid 2886] [client 10.20.30.1:50436] PHP Fatal error: Uncaught Zend_Json_Exception: Decoding failed: Syntax error in /home/vagrant/web/shopware.vanilla/engine/Library/Zend/Json.php:63\nStack trace:\n#0 /home/vagrant/web/shopware.vanilla/engine/Library/Enlight/Controller/Plugins/JsonRequest/Bootstrap.php(93): Zend_Json::decode('{"id":279,"labe...')\n#1 /home/vagrant/web/shopware.vanilla/engine/Library/Enlight/Event/Handler/Default.php(91): Enlight_Controller_Plugins_JsonRequest_Bootstrap->onPreDispatch(Object(Enlight_Controller_ActionEventArgs))\n#2 /home/vagrant/web/shopware.vanilla/engine/Library/Enlight/Event/EventManager.php(219): Enlight_Event_Handler_Default->execute(Object(Enlight_Controller_ActionEventArgs))\n#3 /home/vagrant/web/shopware.vanilla/engine/Library/Enlight/Controller/Action.php(170): Enlight_Event_EventManager->notify('Enlight_Control...', Object(Enlight_Controller_ActionEventArgs))\n#4 /home/vagrant/web/shopware.vanilla/engine/Library/Enlight/Controller/Dispatcher/Default.php(563): Enlight_Controller_Action->dispatch('errorAction')\n#5 /home/vagran in /home/vagrant/web/shopware.vanilla/engine/Library/Zend/Json.php on line 63, referer: https://shopware.vanilla/backend/
that is not really helpful, so lets test in browser:
JSON.parse('{"id":279,"label":"FoobarRegexConfig","name":"FoobarRegexConfig","description":"test regex in config.xml","elements":[{"id":1064,"name":"foo_1","value":null,"label":"maskRe [a-z]","description":null,"type":"text","required":false,"scope":0,"options":{"maskRe":undefined},"values":[{"id":null,"shopId":1,"value":"asd"}]},{"id":1065,"name":"foo_2","value":null,"label":"regex ^[a-z]*$","description":null,"type":"text","required":false,"scope":0,"options":{"regex":undefined},"values":[{"id":null,"shopId":1,"value":"asd"}]}]}');
SyntaxError: JSON.parse: unexpected character at line 1 column 261 of the JSON data
so the problem is exactly at:
..."options":{"maskRe":undefined}...
^
so something changes the regexp object to undefined, when posted to backend!
> rant: why does frontend even send backend the options? and given that `null` is allowed in json, why is not `undefined` allowed?
my tests show that shopware frontend code has the options intact everywhere, but looks like im too stupid to understand extjs, so i couldnt even find where it gets and sends the data...
so, given that extjs in shopware is dead old, and future version of shopware probably even gets rid of extjs, i'm bailing out on this one.
ps. wtf of the day, in ext-all-debug.js: eval("var batch = 30803;");