Jump to content

Tracy Debugger


adrian

Recommended Posts

More improvements to the Captain Hook panel which I think now makes it the definitive source for browsing and understanding what each hook does. 

You have always been able to click the line number to open the file to the line of the method in your code editor (if you have things set up correctly), but this new version adds the following two new features:

1) Inline documentation for each hook - click method (last column) to expand/collapse the docs:

59a10e50dbb6e_ScreenShot2017-08-25at10_59_21PM.thumb.png.afbaeb678e759506941c96b853edf077.png

 

2) Direct link to PW API reference (from the Class::method link in the first column), eg clicking on "Pages::saved" will take you directly to this page:

59a10ed3ac07d_ScreenShot2017-08-25at11_01_29PM.png.0ba1a31c5726858c83f65ef23c4c1164.png

  • Like 8
Link to comment
Share on other sites

Another small update for Captain Hook.

Now if you have Ryan's ProcessWire API Explorer module installed, the Class::method link will take you to the appropriate page of the API Explorer interface, rather than to the processwire.com API docs page.

This means it will work offline, and of course also means it will be updated to the version of PW running on your site.

  • Like 4
Link to comment
Share on other sites

Yep - another Captain Hook update. Often hookable methods for a class are derived from a parent class.

Take the "Roles" class for example. It lists add, delete, & save as the hookable methods that are available. But because it extends the "PagesType" class, its hookable methods are also available from the "Roles" class, eg: Roles::deleted.

To make these derived methods easier to find, I have added a new:

ClassName extends ParentClassName line to each file section. Both names are also linked directly to the API docs so you can find out more info there as well.

59a7021ac257c_ScreenShot2017-08-30at11_20_54AM.png.0f829a24b0a0e6d28fcd2eda443b89a1.png

  • Like 5
Link to comment
Share on other sites

hi adrian,

just updated tracy from the version before the console ready.php include and now i got an error

Call to a member function addHookAfter() on null

because i add my hooks like this:

  // set all languages active automatically
  $wire->addHookAfter('Pages::added', function($event) {
    $page = $event->arguments(0);
    foreach ($this->wire->languages as $lang) $page->set("status$lang", 1);
    $page->save();
  });

as quickfix i added this on top of the file:

$wire = $this->wire;

i think it would be nice to have the wire variable available by default. what do you think?

Link to comment
Share on other sites

hi adrian, me again :)

just wanted to try captain hook and got a memory error with the default 128M php setting:

Quote

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /var/www/vhosts/.../httpdocs/site/assets/cache/FileCompiler/site/modules/TracyDebugger/panels/CaptainHook/CaptainHookSearch.php on line 47

setting it to 256M helped but I'm not sure why this happend or if tracy should also work with 128M of memory and this is a bug?

Link to comment
Share on other sites

Hi @bernhard - that $wire issue is interesting. I will take a look soon.

As far as the memory limit issue with Captain Hook - I reduced my memory down to 64MB and it still worked. I had to go to 32MB to get the error so I am wondering what file caused the error on your system. Could you please debug the path of $file in this function: https://github.com/adrianbj/TracyDebugger/blob/8b92a7d6aec5d9999a77f591496fe8b3ed32080b/panels/CaptainHook/CaptainHookSearch.php#L44

Hopefully that last one to be output should be the file that is causing the limit to be reached. That will at least give me an idea of what is going on. I could of course just set a higher memory limit for this panel, but would like to see what is causing it to fail first.

Thanks!

Link to comment
Share on other sites

Small update to the ProcessWire Info panel which adds a new redirecting "Login" button. 

Obviously this is only relevant if you have checked the "Force Guest Users into Development Mode on Localhost" option in the config settings. I always do this because I like the Tracy debug bar enabled whether I am logged in or not when developing. 

The nice thing about this login button is that it redirects to the page you were on when you clicked it, so you can be viewing a page on the frontend of your site, click this button, enter your credentials and you will be automatically redirected back to the page you were viewing.

Showing the login button:

59b612ae81d09_ScreenShot2017-09-10at9_35_42PM.png.710c3b0c78f7f15a112426f7b49d6799.png

And if you are already logged in, then you'll get a logout button instead (which also returns you to the current page after logout):

59b6133b7f4ea_ScreenShot2017-09-10at9_38_07PM.png.3c0dcbd326f63ee3f1d8fe770638832d.png

  • Like 2
Link to comment
Share on other sites

On 9.9.2017 at 7:37 PM, adrian said:

Hi @bernhard - that $wire issue is interesting. I will take a look soon.

As far as the memory limit issue with Captain Hook - I reduced my memory down to 64MB and it still worked. I had to go to 32MB to get the error so I am wondering what file caused the error on your system. Could you please debug the path of $file in this function: https://github.com/adrianbj/TracyDebugger/blob/8b92a7d6aec5d9999a77f591496fe8b3ed32080b/panels/CaptainHook/CaptainHookSearch.php#L44

Hopefully that last one to be output should be the file that is causing the limit to be reached. That will at least give me an idea of what is going on. I could of course just set a higher memory limit for this panel, but would like to see what is causing it to fail first.

Thanks!

sorry no memory issue any more :( is there some caching that i can reset? i had to decrease it to 16MB to get the error...

On 10.9.2017 at 0:20 AM, adrian said:

Hey @bernhard - I took another look at the $wire variable not being available in ready.php (and init.php / finished.php) and this has been fixed in the latest version. Please confirm it all works at your end please.

thanks, works!

  • Like 2
Link to comment
Share on other sites

4 hours ago, bernhard said:

sorry no memory issue any more :( is there some caching that i can reset? i had to decrease it to 16MB to get the error...

The Captain Hook cache should be reset when you update any modules (including Tracy), or the PW core, so it should already be taken care of, but just in case, go to the database "caches" table and delete the "TracyCaptainHook" row.

4 hours ago, bernhard said:

thanks, works!

Great!

  • Like 1
Link to comment
Share on other sites

5 minutes ago, adrian said:

go to the database "caches" table and delete the "TracyCaptainHook" row.

Just an idea: could you please implement it in @Soma'Clear Cache Admin and create a pull request for it? You might also want to pull up your sleeves and try to persuade him to register it in the Modules Directory:-[

Or you might just want to integrate his module into Tracy? (At least its features.) ;)

I hope I'm not asking for too much. Thanks for all your great community service as always!!!

  • Like 1
Link to comment
Share on other sites

31 minutes ago, szabesz said:

Just an idea: could you please implement it in @Soma'Clear Cache Admin and create a pull request for it? You might also want to pull up your sleeves and try to persuade him to register it in the Modules Directory:-[

Or you might just want to integrate his module into Tracy? (At least its features.) ;)

I hope I'm not asking for too much. Thanks for all your great community service as always!!!

 

Soma's module already includes it - it finds all WireCache caches automatically - note "TracyCaptainHook" at the bottom.

59b7f58744849_ScreenShot2017-09-12at7_54_53AM.png.2022367cf5bec81b98b033fcaa6627b6.png

I am tempted to incorporate the features from his module into Tracy - it seems like an appropriate feature to have and I do like having less modules to install/update. I'll have a think on it for a bit!

Anyone else have any strong feelings on this?

  • Like 2
Link to comment
Share on other sites

6 minutes ago, adrian said:

Soma's module already includes it - it finds all WireCache caches automatically - note "TracyCaptainHook" at the bottom.

Cool, good to know, thanks! I have not yet tried TracyCaptainHook – to tell the truth – so I guess that is why I did not notice it.

6 minutes ago, adrian said:

I'll have a think on it for a bit!

Thanks. It might be useful to have it as a separate module but I do not think editors should use it, so probably it is a good fit for Tracy. Let's see what others say.

Edited by szabesz
...I have not yet tried... + typos
  • Like 1
Link to comment
Share on other sites

2 minutes ago, bernhard said:

would be nice to have in tracy

That's one +1 vote :)

 

2 minutes ago, bernhard said:

we got closer! deleted the cache and the error appeared again. last file seems to be /site/modules/RockMpdf/mpdf6/vendor/mpdf/mpdf/mpdf.php - this file has 1,1MB

That would explain it - now to figure out how to fix it. Ideally it would be good if libraries included in PW modules were excluded from the Captain Hook search (since there obviously won't be any hookable methods in them), but not sure there is a foolproof way to do that. I think an easy fix (which should work in most cases) is to do an initial check for "___" in the file before scanning fully. This will only fail if a vendor library also uses the three underscore method prefix approach. I'll try this and see how we go.

It's actually a nice speed improvement for the panel (when not cached), so a good thing to do regardless.

Please try the latest version, remembering to clear the cache, and let me know how it goes for you.

  • Like 2
Link to comment
Share on other sites

3 hours ago, bernhard said:

seems to work, thanks :)

Great, thanks for letting me know.

I just committed another update which fixes the issues you were having with the Captain Hook cache not automatically clearing when upgrading Tracy. It will now clear when you upgrade, install, or uninstall any modules, click the modules > refresh button, or change PW core versions.

Also, uninstalled (but not deleted) modules will no longer have their hooks shown.

  • Like 1
Link to comment
Share on other sites

Hi everyone,

For those of you running the core SessionHandlerDB module, I just committed an experimental fix for the problem of the "Redirect" bar not showing. The redirect bar can be very handy in debugging many things that may otherwise be lost when there is a redirect, so it's been a real shame for those who haven't had it all this time.

59bd49ff1d133_ScreenShot2017-09-16at8_57_07AM.png.0fded13a06e1c8e16251ea68267c44da.png

I discussed the approach of my fix with Ryan and long time ago (I was hoping he might include it in the core) and this was his response to me:

Quote

in experimenting with this stuff in the past, we came across servers that basically halted the PHP after a redirect or connection close header. I never experienced that behavior, but others did.

Basically what the fix does is when a $session->redirect is called, it now makes the header() call before closing down ProcessPageView. The current PW core behavior is to close it down before the redirect.

I don't think it should be an issue for your sites to use this new version because it only makes this change if:

1) SessionHandlerDB is installed
2) The debug bar is enabled

#2 in particular means that regular users won't be impacted by this at all - only users with Tracy permission (typically just superusers).

However if you notice any problems at all, just add this line to your config.php file to disable it.

$config->disableTracySHDBRedirectFix = true;

And, of course let me know if you have problems so I can revisit my decision on incorporating this fix.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
  • adrian pinned and locked this topic
  • adrian unpinned and pinned this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...