Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPluginHelper::importPlugin() method does not load the same plugin with two different dispatchers #12690

Closed
iv660 opened this issue Nov 1, 2016 · 6 comments

Comments

@iv660
Copy link

iv660 commented Nov 1, 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.

@ghost
Copy link

ghost commented Apr 5, 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.

@iv660
Copy link
Author

iv660 commented Apr 14, 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.

@zero-24
Copy link
Contributor

zero-24 commented Apr 14, 2017

@iv660 3.6.5 or https://github.com/joomla/joomla-cms/tree/staging the staging branch 😄

@zero-24
Copy link
Contributor

zero-24 commented Apr 14, 2017

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

@mbabker
Copy link
Contributor

mbabker commented Apr 14, 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.

@mbabker
Copy link
Contributor

mbabker commented Apr 27, 2017

See #15607

@mbabker mbabker closed this as completed Apr 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants