Jump to content
adrian

Tracy Debugger

Recommended Posts

Hey @adrian, thanks for the update.

At the moment  Tracy doesnt check whether ready.php and finished.php exists or not, and gives this error.

599f2e3f07dfe_ClipboardImage(2).thumb.jpg.3707f3ebb8d98ce55c3bfcea7b985829.jpg

  • Like 2

Share this post


Link to post
Share on other sites
7 minutes ago, abdus said:

Hey @adrian, thanks for the update.

At the moment  Tracy doesnt check whether ready.php and finished.php exists or not, and gives this error.

599f2e3f07dfe_ClipboardImage(2).thumb.jpg.3707f3ebb8d98ce55c3bfcea7b985829.jpg

Sorry about that - should be fixed in the latest version.

  • Like 3

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
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?

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

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.

  • Like 4

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

would be nice to have in tracy :)

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

  • Like 2

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
6 minutes ago, bernhard said:

version 4.3.22 does not work :(

Do you mean that you are still getting the out of memory error, or something else?

 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Hi @adrian,

Might be a silly question, but just wondering why the dump output doesn't appear in the same order that the dumps occur in. So if I do...

 2017-09-26_183741.png.4acb0f939c4be146152bc5961399a186.png

...how come the output order is reversed?

2017-09-26_183720.png.b8ee4269fbcd5476b36279c8603a0644.png

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      A community member raised a question and I thought a new sanitizer method for the purpose would be useful, hence...
      Sanitizer Transliterate
      Adds a transliterate method to $sanitizer that performs character replacements as defined in the module config. The default character replacements are based on the defaults from InputfieldPageName, but with uppercase characters included too.
      Usage
      Install the Sanitizer Transliterate module.
      Customise the character replacements in the module config as needed.
      Use the sanitizer on strings like so:
      $transliterated_string = $sanitizer->transliterate($string);
       
      https://github.com/Toutouwai/SanitizerTransliterate
      https://modules.processwire.com/modules/sanitizer-transliterate/
       
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version to 2.10, add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "http://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


    • By thomasaull
      I created a little helper module to trigger a CI pipeline when your website has been changed. It's quite simple and works like this: As soon as you save a page the module sets a Boolean via a pages save after hook. Once a day via LazyCron the module checks if the Boolean is set and sends a POST Request to a configurable Webhook URL.
      Some ideas to extend this:
      make request type configurable (GET, POST) make the module trigger at a specified time (probably only possible with a server cronjob) trigger manually Anything else? If there's interest, I might put in some more functionality. Let me know what you're interested in. Until then, maybe it is useful for a couple of people 🙂
      Github Repo: https://github.com/thomasaull/CiTrigger
    • By Robin S
      I created this module a while ago and never got around to publicising it, but it has been outed in the latest PW Weekly so here goes the support thread...
      Unique Image Variations
      Ensures that all ImageSizer options and focus settings affect image variation filenames.

      Background
      When using methods that produce image variations such as Pageimage::size(), ProcessWire includes some of the ImageSizer settings (height, width, cropping location, etc) in the variation filename. This is useful so that if you change these settings in your size() call a new variation is generated and you see this variation on the front-end.
      However, ProcessWire does not include several of the other ImageSizer settings in the variation filename:
      upscaling cropping, when set to false or a blank string interlace sharpening quality hidpi quality focus (whether any saved focus area for an image should affect cropping) focus data (the top/left/zoom data for the focus area) This means that if you change any of these settings, either in $config->imageSizerOptions or in an $options array passed to a method like size(), and you already have variations at the requested size/crop, then ProcessWire will not create new variations and will continue to serve the old variations. In other words you won't see the effect of your changed ImageSizer options on the front-end until you delete the old variations.
      Features
      The Unique Image Variations module ensures that any changes to ImageSizer options and any changes to the focus area made in Page Edit are reflected in the variation filename, so new variations will always be generated and displayed on the front-end.
      Installation
      Install the Unique Image Variations module.
      In the module config, set the ImageSizer options that you want to include in image variation filenames.
      Warnings
      Installing the module (and keeping one or more of the options selected in the module config) will cause all existing image variations to be regenerated the next time they are requested. If you have an existing website with a large number of images you may not want the performance impact of that. The module is perhaps best suited to new sites where image variations have not yet been generated.
      Similarly, if you change the module config settings on an existing site then all image variations will be regenerated the next time they are requested.
      If you think you might want to change an ImageSizer option in the future (I'm thinking here primarily of options such as interlace that are typically set in $config->imageSizerOptions) and would not want that change to cause existing image variations to be regenerated then best to not include that option in the module config after you first install the module.
       
      https://github.com/Toutouwai/UniqueImageVariations
      https://modules.processwire.com/modules/unique-image-variations/
    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      ProcessWire-Module: http://modules.processwire.com/modules/page-access-releasetime/
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      Usage
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      Limitations
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
×
×
  • Create New...