?
avatar iv660
iv660
1 Nov 2016

Steps to reproduce the issue

Call JPluginHelper::importPlugin() with two unique instances of JEventDispatcher class:

    $type = 'quickicon';
    
    $dispatcher1 = new JEventDispatcher();
    $dispatcher2 = new JEventDispatcher();
    JPluginHelper::importPlugin($type, null, true, $dispatcher1);
    JPluginHelper::importPlugin($type, null, true, $dispatcher2);
    echo "<p>Dispatcher1:</p>"; ##
    echo "<pre>"; ##
    print_r($dispatcher1); ##
    echo "</pre>"; ##
    echo "<p>Dispatcher2:</p>"; ##
    echo "<pre>"; ##
    print_r($dispatcher2); ##
    echo "</pre>"; ##

Expected result

Both dispatchers should be identical, with plugins loaded as observers:

Dispatcher1:

JEventDispatcher Object
(
    [_observers:protected] => Array
        (
            [0] => PlgQuickiconJoomlaupdate Object
                (
                    [autoloadLanguage:protected] => 1
                    [params] => Joomla\Registry\Registry Object
                        (
                            [data:protected] => stdClass Object
                                (
                                )

                            [initialized:protected] => 1
                            [separator] => .
                        )

                    [_name:protected] => joomlaupdate
                    [_type:protected] => quickicon
                    [_subject:protected] => JEventDispatcher Object
 *RECURSION*
                    [_errors:protected] => Array
                        (
                        )

                )

            [1] => PlgQuickiconExtensionupdate Object
                (
                    [autoloadLanguage:protected] => 1
                    [params] => Joomla\Registry\Registry Object
                        (
                            [data:protected] => stdClass Object
                                (
                                )

                            [initialized:protected] => 1
                            [separator] => .
                        )

                    [_name:protected] => extensionupdate
                    [_type:protected] => quickicon
                    [_subject:protected] => JEventDispatcher Object
 *RECURSION*
                    [_errors:protected] => Array
                        (
                        )

                )

        )

    [_state:protected] => 
    [_methods:protected] => Array
        (
            [ongeticons] => Array
                (
                    [0] => 0
                    [1] => 1
                )

        )
 
    [_errors:protected] => Array
        (
         )
 
)
Dispatcher2:

JEventDispatcher Object
(
    [_observers:protected] => Array
        (
            [0] => PlgQuickiconJoomlaupdate Object
                (
                    [autoloadLanguage:protected] => 1
                    [params] => Joomla\Registry\Registry Object
                        (
                            [data:protected] => stdClass Object
                                (
                                )

                            [initialized:protected] => 1
                            [separator] => .
                        )

                    [_name:protected] => joomlaupdate
                    [_type:protected] => quickicon
                    [_subject:protected] => JEventDispatcher Object
 *RECURSION*
                    [_errors:protected] => Array
                        (
                        )

                )

            [1] => PlgQuickiconExtensionupdate Object
                (
                    [autoloadLanguage:protected] => 1
                    [params] => Joomla\Registry\Registry Object
                        (
                            [data:protected] => stdClass Object
                                (
                                )

                            [initialized:protected] => 1
                            [separator] => .
                        )

                    [_name:protected] => extensionupdate
                    [_type:protected] => quickicon
                    [_subject:protected] => JEventDispatcher Object
 *RECURSION*
                    [_errors:protected] => Array
                        (
                        )

                )

        )

    [_state:protected] => 
    [_methods:protected] => Array
        (
            [ongeticons] => Array
                (
                    [0] => 0
                    [1] => 1
                )

        )

    [_errors:protected] => Array
        (
        )

)

Actual result

Second dispatcher has no observers loaded:

Dispatcher1:

JEventDispatcher Object
(
    [_observers:protected] => Array
        (
            [0] => PlgQuickiconJoomlaupdate Object
                (
                    [autoloadLanguage:protected] => 1
                    [params] => Joomla\Registry\Registry Object
                        (
                            [data:protected] => stdClass Object
                                (
                                )

                            [initialized:protected] => 1
                            [separator] => .
                        )

                    [_name:protected] => joomlaupdate
                    [_type:protected] => quickicon
                    [_subject:protected] => JEventDispatcher Object
 *RECURSION*
                    [_errors:protected] => Array
                        (
                        )

                )

            [1] => PlgQuickiconExtensionupdate Object
                (
                    [autoloadLanguage:protected] => 1
                    [params] => Joomla\Registry\Registry Object
                        (
                            [data:protected] => stdClass Object
                                (
                                )

                            [initialized:protected] => 1
                            [separator] => .
                        )

                    [_name:protected] => extensionupdate
                    [_type:protected] => quickicon
                    [_subject:protected] => JEventDispatcher Object
 *RECURSION*
                    [_errors:protected] => Array
                        (
                        )

                )

        )

    [_state:protected] => 
    [_methods:protected] => Array
        (
            [ongeticons] => Array
                (
                    [0] => 0
                    [1] => 1
                )

        )

    [_errors:protected] => Array
        (
        )

)

Dispatcher2:

JEventDispatcher Object
(
    [_observers:protected] => Array
        (
        )

    [_state:protected] => 
    [_methods:protected] => Array
        (
        )

    [_errors:protected] => Array
        (
        )

)

System information (as much as possible)

Platform Windows NT KEY 6.1 build 7601 (Windows 7 Business Edition Service Pack 1) i586
DB 5.5.38-log
DB encoding utf8_general_ci
DB connection encoding utf8mb4_general_ci
PHP version 5.4.29
Web-server Apache/2.2.27 (Win32)
apache2handler
Joomla! 3.6.4 Stable [ Noether ] 21-October-2016 16:33 GMT
Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
User agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0

Additional comments

The ability to load the plugin with individual dispatchers is important when dealing with extension-specific plugins. It is the way to run the plugins from the specific plugin group(s) in isolation from the "system-wide" plugins.

avatar iv660 iv660 - open - 1 Nov 2016
avatar iv660 iv660 - change - 1 Nov 2016
The description was changed
avatar iv660 iv660 - edited - 1 Nov 2016
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Apr 2017

@iv660 is this Issue on latest Staging too?


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

avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Apr 2017
Status New Information Required
avatar iv660
iv660 - comment - 14 Apr 2017

@franz-wohlkoenig I'm not sure if I've got your question right, but if you are talking about Joomla! 3.6.5, sorry, I didn't have a chance to check yet.

avatar zero-24
zero-24 - comment - 14 Apr 2017
avatar zero-24
zero-24 - comment - 14 Apr 2017

but it is still the same behavior on staging (just checked) using your code above.

avatar mbabker
mbabker - comment - 14 Apr 2017

To fix this, the static loaded array is going to need to become an associative array with the key being a hash of the injected dispatcher (or whatever the default one is when the param is null) and it holds an array of the loaded plugins for that dispatcher.

avatar mbabker mbabker - change - 27 Apr 2017
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2017-04-27 01:32:35
Closed_By mbabker
avatar mbabker mbabker - close - 27 Apr 2017
avatar mbabker
mbabker - comment - 27 Apr 2017

See #15607

Add a Comment

Login with GitHub to post a comment