? PR-4.3-dev Pending

User tests: Successful: Unsuccessful:

avatar obuisard
obuisard
6 Mar 2023

Summary of Changes

The plugin registers events only when under administrator.

Testing Instructions

Run the patch and see if the tours are still available and able to run.
There is no longer a load in the site side.

Actual result BEFORE applying this Pull Request

The tours are available and can run.

Expected result AFTER applying this Pull Request

The tours are available and can run.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar joomla-cms-bot joomla-cms-bot - change - 6 Mar 2023
Category Front End Plugins
avatar obuisard obuisard - open - 6 Mar 2023
avatar obuisard obuisard - change - 6 Mar 2023
Status New Pending
avatar obuisard obuisard - change - 6 Mar 2023
Title
[4.3] [Guided Tours] Plugin registers events only under administrator
[4.3][Guided Tours] Plugin registers events only under administrator
avatar obuisard obuisard - edited - 6 Mar 2023
avatar laoneo
laoneo - comment - 6 Mar 2023

The get subscribed events function should not contain that much logic when possible. It would be better to get rid of the whole system plugin at all.

avatar wilsonge
wilsonge - comment - 7 Mar 2023

To explain why @laoneo is correct - this has next has no peformance impact in the frontend because we are still loading the plugin and acl checking it before we boot it to get the plugin events. Where the check happens in the context of that is relatively small scale. If this is only intended for the backend a dedicated plugin group is better (for extension devs too to save the same stuff that is loaded inside of AdministratorApplication. As I suggested in the original PR

avatar obuisard
obuisard - comment - 7 Mar 2023

To explain why @laoneo is correct - this has next has no peformance impact in the frontend because we are still loading the plugin and acl checking it before we boot it to get the plugin events. Where the check happens in the context of that is relatively small scale. If this is only intended for the backend a dedicated plugin group is better (for extension devs too to save the same stuff that is loaded inside of AdministratorApplication. As I suggested in the original PR

You also suggested in the original PR that if we do that, we take away the possibility to bring guided tours to the frontend in future developments. That's an option we should not close either.

avatar wilsonge
wilsonge - comment - 7 Mar 2023

You also suggested in the original PR that if we do that, we take away the possibility to bring guided tours to the frontend in future developments. That's an option we should not close either.

If that's the plan then I'd leave the code as it is. Although nothing stops you adding it to SiteApplication as well in the future. The most important thing will be that you validate that your in an html application IF that is the plan. But I've also not seen anything documented that that is the plan (and for 3PD's implementing this - that's a very relevant fact for their 3rd party plugins - which will also be system plugins???)

A lot of this has been raised because you've introduced a system plugin (which will impact to a degree site load times) which currently only loads in the admin client. So you're impacting google load times for something currently exclusive to the admin.

avatar obuisard
obuisard - comment - 8 Mar 2023

To be honest, I understand your points but I have no idea how I would implement this. This is completely unfamiliar to me.

avatar laoneo
laoneo - comment - 8 Mar 2023

I made another approach in #40046 where the template itself is loading it as I have believe that the template must somehow support that feature.

avatar Fedik
Fedik - comment - 8 Mar 2023

This should do the trick without fancy hacks.
The plugin:

protected $autoloadLanguage = false;
protected static $enabled = false;

public function __construct($subject, $config = [], $enabled = false)
{
    $this->autoloadLanguage = $enabled;
    self::$enabled = $enabled;

    parent::__construct($subject, $config);
}

public static function getSubscribedEvents(): array
{
    return self::$enabled ? [
        'onAjaxGuidedtours'   => 'startTour',
        'onBeforeCompileHead' => 'onBeforeCompileHead',
    ] : [];
}

The plugin provider:

$app    = Factory::getApplication();
$plugin = new GuidedTours(
    $dispatcher,
    (array) PluginHelper::getPlugin('system', 'guidedtours'),
    $app->isClient('administrator')
);
avatar laoneo
laoneo - comment - 9 Mar 2023

What @wilsonge and me are trying to explain here, is that the whole approach is not right. There should be no system plugin at all which is loaded on every page request. This is what should be avoided, not only registering events, loading the whole plugin. That's why I made #40046. This change here has little to no effect, loading the plugin is what counts here.

avatar obuisard obuisard - change - 11 Mar 2023
Labels Added: PR-4.3-dev
avatar khu5h1 khu5h1 - test_item - 11 Mar 2023 - Tested successfully
avatar khu5h1
khu5h1 - comment - 11 Mar 2023

I have tested this item successfully on 697cc72


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

avatar sdwjoomla sdwjoomla - test_item - 11 Mar 2023 - Tested successfully
avatar sdwjoomla
sdwjoomla - comment - 11 Mar 2023

I have tested this item successfully on 697cc72

Downloaded prebuilt and was able to successfully run tour


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

avatar Quy Quy - change - 11 Mar 2023
Status Pending Ready to Commit
avatar Quy
Quy - comment - 11 Mar 2023

RTC


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

avatar obuisard obuisard - change - 12 Mar 2023
Labels Added: ?
avatar obuisard obuisard - change - 12 Mar 2023
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-03-12 00:41:21
Closed_By obuisard
avatar obuisard obuisard - close - 12 Mar 2023
avatar obuisard obuisard - merge - 12 Mar 2023
avatar wilsonge
wilsonge - comment - 13 Mar 2023

I'm sorry I missed the updates here but what is merged here is wrong. You can't have the constructor for a non-static method influencing the behaviour of a static method. That's totally wrong.

Add a Comment

Login with GitHub to post a comment