User tests: Successful: Unsuccessful:
Because PluginHelper::$plugins
is defined as static
, getPlugin()
returns a reference to the original $plugin
object. When _loadEditor()
is invoked it will load the params
into the Registry
and overwrite the original $plugin->params
with the Registry
object. Subsequent calls to _loadEditor()
will try to load the modified $plugin->params
and will lead to unexpected results:
First call:
object(Joomla\Registry\Registry)#417 (3) {
["data":protected]=>
object(stdClass)#422 (11) {
["lineNumbers"]=>
string(1) "1"
["lineWrapping"]=>
string(1) "1"
["matchTags"]=>
string(1) "1"
["matchBrackets"]=>
string(1) "1"
["marker-gutter"]=>
string(1) "1"
["autoCloseTags"]=>
string(1) "1"
["autoCloseBrackets"]=>
string(1) "1"
["autoFocus"]=>
string(1) "1"
["theme"]=>
string(7) "default"
["tabmode"]=>
string(6) "indent"
["syntax"]=>
string(3) "php"
}
["initialized":protected]=>
bool(true)
["separator"]=>
string(1) "."
}
Second call:
object(Joomla\Registry\Registry)#423 (3) {
["data":protected]=>
object(stdClass)#425 (4) {
["data"]=>
object(stdClass)#426 (11) {
["lineNumbers"]=>
string(1) "1"
["lineWrapping"]=>
string(1) "1"
["matchTags"]=>
string(1) "1"
["matchBrackets"]=>
string(1) "1"
["marker-gutter"]=>
string(1) "1"
["autoCloseTags"]=>
string(1) "1"
["autoCloseBrackets"]=>
string(1) "1"
["autoFocus"]=>
string(1) "1"
["theme"]=>
string(7) "default"
["tabmode"]=>
string(6) "indent"
["syntax"]=>
string(3) "php"
}
["initialized"]=>
bool(true)
["separator"]=>
string(1) "."
["syntax"]=>
string(10) "javascript"
}
["initialized":protected]=>
bool(true)
["separator"]=>
string(1) "."
}
As you can see, data
is now inside another data
object.
Let's say you want to display two CodeMirror editors - one for PHP, the other one for Javascript. For the sake of it, I'll make the code simple:
$instance = new JEditor('codemirror');
echo $instance->display('first_editor', '<?php echo "test"; ?>', '100%', 300, 75, 20, $buttons = false, $id = null, $asset = null, $author = null, array('syntax' => 'php'));
$instance2 = new JEditor('codemirror');
echo $instance2->display('second_editor', 'var test;', '100%', 300, 75, 20, $buttons = false, $id = null, $asset = null, $author = null, array('syntax' => 'javascript'));
Two editors with different syntax highlighting - no other differences.
Two editors but the second editor grabbing incorrect plugin parameters (no line numbers, no gutters etc).
Hopefully none?
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Title |
|
I have tested this item
I have tested this item
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
@HLeithner please a final response
1 year old rtc pr
As far as I know is our plugin system a singleton so the editor plugins have to deal with this correctly. This seams like a wrong workaround.
ymmv
It's been more than a year - this has been indirectly solved through #20583 (Registry update). Original commit here:
joomla-framework/registry@3813e93
So it can be closed.
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-05-13 08:27:56 |
Closed_By | ⇒ | OctavianC | |
Labels |
Removed:
J3 Issue
|
Sorry, didn't notice the title was taken from the commit :)