? Success

User tests: Successful: Unsuccessful:

avatar OctavianC
OctavianC
25 Jan 2018

Summary of Changes

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.

Testing Instructions

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'));

Expected result

Two editors with different syntax highlighting - no other differences.

Actual result

Two editors but the second editor grabbing incorrect plugin parameters (no line numbers, no gutters etc).

Documentation Changes Required

Hopefully none?

avatar OctavianC OctavianC - open - 25 Jan 2018
avatar OctavianC OctavianC - change - 25 Jan 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Jan 2018
Category Libraries
avatar OctavianC OctavianC - change - 26 Jan 2018
Title
Needs to be a clone or params get messed up
Multiple editors don't inherit $params correctly
avatar OctavianC OctavianC - edited - 26 Jan 2018
avatar OctavianC
OctavianC - comment - 26 Jan 2018

Sorry, didn't notice the title was taken from the commit :)

avatar Quy
Quy - comment - 3 Feb 2018

I have tested this item successfully on 5c27563


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19454.

avatar Quy Quy - test_item - 3 Feb 2018 - Tested successfully
avatar viocassel
viocassel - comment - 3 Feb 2019

I have tested this item successfully on 5c27563


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19454.

avatar viocassel
viocassel - comment - 3 Feb 2019

I have tested this item successfully on 5c27563


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19454.

avatar viocassel viocassel - test_item - 3 Feb 2019 - Tested successfully
avatar Quy Quy - change - 3 Feb 2019
Status Pending Ready to Commit
avatar Quy
Quy - comment - 3 Feb 2019

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19454.

avatar alikon
alikon - comment - 2 May 2019

@HLeithner please a final response

1 year old rtc pr

avatar HLeithner
HLeithner - comment - 10 May 2019

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

avatar OctavianC
OctavianC - comment - 13 May 2019

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.

avatar OctavianC OctavianC - change - 13 May 2019
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
avatar OctavianC OctavianC - close - 13 May 2019

Add a Comment

Login with GitHub to post a comment