? Success

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
12 Jan 2016

Description

Following #8888, this PR adds the final event afterRespond to the Joomla! Debug Console Profile Information block.

As it is now Joomla is not returning the real page time because it's not counting the afterRespond event.

To achive this goal a new event, the onBeforeEnd, is created. This event:

  • is the last one (load after the onAfterRespond events) and before the app closes.
  • can only be loaded by the debug system plugin and it was to be enabled.

Since the onAfterRespond events are now in the Profiler too, this PR will also allow to debug the onAfterRespond events.

Before PR:
image

After PR:
image

How to test

  1. Apply this patch.
  2. Turn on the debug in global config and enale the debug system plugin.
  3. Test any page in frontend or admin and check if the afterRespond time and memory usage is in the Joomla! Debug Console Profile Information block.
  4. You can now also test send info to Joomla! Debug Console on a onAfterRespond. For instance, add the following php to a system plugin that is enabled, load page and observe if the messages appear in the Joomla! Debug Console.
public function onAfterRespond()
{
    // Test to add mark in the profiler Joomla! Debug Console Profile Information block.
    JDEBUG ? JProfiler::getInstance('Application')->mark('testMark') : null;

    // Test to add log message to Log Messages block.
    JDEBUG ? JLog::add('Test log message to Joomla! Debug Console Log Messages block.', JLog::WARNING, 'deprecated') : null;
    }

Observations

Improvements or suggestions are welcome.

avatar andrepereiradasilva andrepereiradasilva - open - 12 Jan 2016
avatar andrepereiradasilva andrepereiradasilva - change - 12 Jan 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 12 Jan 2016
Labels Added: ?
9ff3529 12 Jan 2016 avatar andrepereiradasilva typo
avatar mbabker
mbabker - comment - 12 Jan 2016

The parent JApplicationWeb class has onBeforeExecute and onAfterExecute
events that we pulled out when migrating the application classes from the
legacy stuff. So if we're going to put a new trigger at the end of the
execute method I'd put that onAfterExecute trigger back.

On Tuesday, January 12, 2016, andrepereiradasilva notifications@github.com
wrote:

Description

Following #8888 #8888, this PR
adds the final event afterRespond to the Joomla! Debug Console Profile
Information block.

As it is now Joomla is not returning the real page time because it's not
counting the afterRespond event.

To achive this goal a new event, the onBeforeEnd, is created. This event:

  • is the last one (load after the onAfterRespond events) and before the app closes.
  • can only be loaded by the debug system plugin and it was to be enabled.

Since the onAfterRespond events are now in the Profiler too, this PR will
also allow to debug the onAfterRespond events.

Before PR:
[image: image]
https://cloud.githubusercontent.com/assets/9630530/12278208/b02e2976-b977-11e5-8411-e4d4c343c96c.png

After PR:
[image: image]
https://cloud.githubusercontent.com/assets/9630530/12278187/8e778b74-b977-11e5-9059-28a9fdd8947a.png
How to test

  1. Apply this patch.
  2. Turn on the debug in global config and enale the debug system plugin.
  3. Test any page in frontend or admin and check if the afterRespond time and memory usage is in the Joomla! Debug Console Profile Information block.
  4. You can now also test send info to Joomla! Debug Console on a onAfterRespond. For instance, add the following php to a system plugin that is enabled, load page and observe if the messages appear in the Joomla! Debug Console.

public function onAfterRespond(){ // Test to add mark in the profiler Joomla! Debug Console Profile Information block. JDEBUG ? JProfiler::getInstance('Application')->mark('testMark') : null; // Test to add log message to Log Messages block. JDEBUG ? JLog::add('Test log message to Joomla! Debug Console Log Messages block.', JLog::WARNING, 'deprecated') : null; }

Observations

Improvements or suggestions are welcome.

You can view, comment on, or merge this pull request online at:

#8890
Commit Summary

  • Merge remote-tracking branch 'refs/remotes/joomla/staging' into staging
  • Merge remote-tracking branch 'refs/remotes/joomla/staging' into staging
  • Merge remote-tracking branch 'refs/remotes/joomla/staging' into staging
  • Merge branch 'staging' of https://github.com/andrepereiradasilva/joomla-cms into staging
  • Merge remote-tracking branch 'refs/remotes/joomla/staging' into staging
  • Merge remote-tracking branch 'refs/remotes/joomla/staging' into staging
  • Merge remote-tracking branch 'refs/remotes/joomla/staging' into debugger-onBeforeEnd
  • debugger onBeforeEnd event

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#8890.

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Jan 2016

ok. i will replace it onBeforeEnd for onAfterExecute. But only for JDEBUG right?

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Jan 2016

In the Joomla the onAfterExecute event is executed before onAfterRespond event (https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/application/web.php#L263).

The goal here is to have a last event that is executed after the onAfterRespond event to be only used by the debugger so we can debug all events in the application so i think onAfterExecute will not serve the goal.

avatar mbabker
mbabker - comment - 13 Jan 2016

Oh... These web application classes are so inconsistent. The base application class triggers that event as the last thing in execute, I wish I knew why the folks who wrote those classes decided to have onAfterExecute in the middle of execute :facepalm:

Also, you can't create an event trigger that will only dispatch to one plugin. If you really wanted to do that, you'd need to just trigger $plugin->runThisAfterExecuteFinishes() instead of using the event dispatcher. Even if it's only dispatched if JDEBUG is true, any plugin with a public function onAfterExecute() would still listen to that event.

I'd just use onAfterExecute for the method and consider changing the event trigger order in JApplicationWeb so that the method is actually triggered after execute finishes.

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Jan 2016

Check also the comments in Joomla Framework:

If i understand this correctly there is a doExecute inside the execute. The onBeforeExecute and onAfterExecute are related to the doExecute, in other words, onAfterExecute the doExecute.

Regarding this PR, i will try to change and call the debug plugin directly (with no new event).

avatar mbabker
mbabker - comment - 13 Jan 2016

As the only crazy guy left using the Framework, I'd say the current trigger position is wrong, or the web application classes need an additional afterExecute type of event after the response is sent. Either way what's there now is less than optimal.

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Jan 2016

Look on the bright side, if you're the only crazy guy left using the Framework you have more liberty to correct it. :smile:

avatar brianteeman brianteeman - change - 14 Mar 2016
Category Libraries
avatar andrepereiradasilva
andrepereiradasilva - comment - 5 Sep 2016

closing for lack of interest

avatar andrepereiradasilva andrepereiradasilva - change - 5 Sep 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-09-05 21:56:38
Closed_By andrepereiradasilva
avatar andrepereiradasilva andrepereiradasilva - close - 5 Sep 2016
avatar joomla-cms-bot joomla-cms-bot - change - 5 Sep 2016
Category Libraries Libraries Plugins Front End

Add a Comment

Login with GitHub to post a comment