Jump to content
adrian

Tracy Debugger

Recommended Posts

I'm having an issue with the Request Info panel randomly not showing various info at the bottom. Here are 2 pages, next to each other – one shows the edit pencil, the other doesn't; this has been happening on several sites.

without.jpg.09c378993c04f38ee53fbae32eef86aa.jpg

with.jpg.48ccbf03cf4149398570227a2a18afd1.jpg

  • Like 1

Share this post


Link to post
Share on other sites

Hey @Macrura - you gotta give me more than that 🙂

Seriously though, it looks like there is something breaking output for the Server Request section, or perhaps it's actually being broken in the preceding Field List & Values section. Could you please try disabling those two sections (in the config settings there are checkboxes) and see if that fixes things? Then perhaps you could narrow down what part of the section is failing please?

My gut feeling is that it is the Field List & Values section and there is some field that is breaking things.

Thanks.

Share this post


Link to post
Share on other sites

Ok thanks for the clue, so i have checked the Field List and Values accordion, which I hadn't used before, and i see that the table is corrupted.

There is a column outputting a RuntimeMarkup field which contains an admin data table. I have checked the HTML on that and it is all valid; But the existence of that table in the unformatted column of the RuntimeMarkup field's row is breaking the table and causing the next cell to contain the rest of the table inside it.

Now looking at the code in the bottom of the source view, i can see that my admin table markup is outputting table tags which are presumably breaking the panel's table markup. I wonder if there is any way to encode that to prevent this... I tried enabling/disabling the $table->setEncodeEntities(true/false) but did not fix the issue.

thanks!

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks @Macrura - that got me on the right track - should be fixed in the latest version.

  • Like 1

Share this post


Link to post
Share on other sites

Question.

Is there a way to see all the available properties on a module? I use RepeaterMatrix quite a bit and use the 'type' property within the loop but I also want to return the name/label of each type and I wondered if there was any way to see what else is available other than $row->type?

This is just one example, of course...

Share this post


Link to post
Share on other sites

You can just dump() or barDump() the $row object:

HqoKZvg.png

You have the "debug info" and the "full object" options.

Share this post


Link to post
Share on other sites

@adrian any idea what could be the cause for this: Error in ProcesswireLogsPanel

ProcessWire\WireException: Unable to encode array data for cache: TracyLogData.ProcessWire in C:\www\xxx\wire\core\WireCache.php:450
Stack trace:
#0 C:\www\xxx\site\assets\cache\FileCompiler\site\modules\TracyDebugger\panels\ProcesswireLogsPanel.php(44): ProcessWire\WireCache->save('TracyLogData.Pr...', false, '2010-04-08 03:1...')
#1 C:\www\xxx\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy-2.6.x\src\Tracy\Bar\Bar.php(147): ProcesswireLogsPanel->getTab()
#2 C:\www\xxx\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy-2.6.x\src\Tracy\Bar\Bar.php(121): Tracy\Bar->renderPanels('')
#3 C:\www\xxx\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy-2.6.x\src\Tracy\Bar\Bar.php(97): Tracy\Bar->renderHtml('main')
#4 C:\www\xxx\site\assets\cache\FileCompiler\site\modules\TracyDebugger\TracyDebugger.module.php(1713): Tracy\Bar->render()
#5 C:\www\xxx\wire\core\Wire.php(383): TracyDebugger->sessionHandlerDBAjaxFix(Object(ProcessWire\HookEvent))
#6 C:\www\xxx\wire\core\WireHooks.php(917): ProcessWire\Wire->_callMethod('sessionHandlerD...', Array)
#7 C:\www\xxx\wire\core\Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessWire), 'finished', Array)
#8 C:\www\xxx\wire\core\ProcessWire.php(609): ProcessWire\Wire->__call('finished', Array)
#9 C:\www\xxx\wire\core\ProcessWire.php(505): ProcessWire\ProcessWire->__call('finished', Array)
#10 C:\www\xxx\wire\modules\Process\ProcessPageView.module(258): ProcessWire\ProcessWire->setStatus(16)
#11 C:\www\xxx\wire\core\Wire.php(380): ProcessWire\ProcessPageView->___finished()
#12 C:\www\xxx\wire\core\WireHooks.php(813): ProcessWire\Wire->_callMethod('___finished', Array)
#13 C:\www\xxx\wire\core\Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessPageView), 'finished', Array)
#14 C:\www\xxx\index.php(56): ProcessWire\Wire->__call('finished', Array)
#15 {main}

Latest version. Error seems to occur only on windows (but not sure).

Share this post


Link to post
Share on other sites
4 hours ago, bernhard said:

any idea what could be the cause for this: Error in ProcesswireLogsPanel

Note sure - would you mind finding out what contents of $logLinesData is just before line 44 of ProcesswireLogsPanel.php and also $data before and after the json_encode() on line 449 of wire/core/WireCache.php

Hopefully one/both of those will help to identify the problem. Thanks!

Share this post


Link to post
Share on other sites

Thx that helped! I just deleted the exceptions.txt logfile which had some base64 encoded string in it. I guess this was the culprit 🙂 

Share this post


Link to post
Share on other sites
8 hours ago, bernhard said:

Thx that helped! I just deleted the exceptions.txt logfile which had some base64 encoded string in it. I guess this was the culprit 🙂 

Glad you got things working again, but I can't imagine why a base64 encoded string would cause a problem. I just tried here and it looked ok. Maybe that wasn't really the issue but somehow the exceptions.txt was corrupted in some other way?

Share this post


Link to post
Share on other sites

I had some weird symbols in that file where the base64 encoded string was. No idea where they came from, but I will only investigate if the problem occurs again. Thx for your help!

  • Like 1

Share this post


Link to post
Share on other sites

Hi all,

Just wanted to share a tip that can be useful if you want to debug a core file before Tracy has been loaded.

Suppose you were debugging ProcessWire::getHttpHost() and for some reason wanted to dump the $host variable just before it is returned.

If you add the line...

bd($host, 'host');

...then you'll get a fatal error when the code runs because Tracy has not yet been loaded and so the bd() function is undefined.

2019-09-28_151822.png.b557b5d15c563e966215fe5d2e43c312.png

When debugging core files you'll find a number of places like this where the Tracy dump functions are not available.

A workaround for this is to set the variable that you want to dump as a custom property on the Wire object. You want to be careful not to use a property name that clashes with any existing Wire properties or API variables - adding a prefix like "td_" is a safe bet.

$this->wire()->set('td_host', $host);

Now in /site/ready.php you can dump the variable that you stored on the Wire object:

bd($wire->td_host, 'host');

...or shorter (thanks @adrian)...

bd($td_host, 'host');

2019-09-28_152538.png.73a83eb92622f387f5944ea93c7d830f.png

Edited by Robin S
Shorter way to dump variable on Wire object
  • Like 4

Share this post


Link to post
Share on other sites

Really great idea @Robin S !

You can make it even less work by using d($td_host) in the Console panel:

image.png.2965e39a2d0e6a0b0ed86ac05f4b0345.png

  • Like 3

Share this post


Link to post
Share on other sites

@Robin S - what do you think about this idea - I am contemplating having Tracy check $wire for any variables prefixed with "bd_" and automatically bd() them without the need to manually make a bd() or d() call. The title would be automatically set to the name of the variable after the "bd_" prefix.

PS - remember you can set $wire variables like this:

$this->wire('bd_host', $host);

The shorter the better when adding debug statements 🙂

  • Like 2

Share this post


Link to post
Share on other sites
7 hours ago, adrian said:

I am contemplating having Tracy check $wire for any variables prefixed with "bd_" and automatically bd() them without the need to manually make a bd() or d() call. The title would be automatically set to the name of the variable after the "bd_" prefix.

I like it! Not only is it easier but it makes it less likely that the setting of the $wire variable will be accidentally left behind after debugging is finished.

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, Robin S said:

I like it! Not only is it easier but it makes it less likely that the setting of the $wire variable will be accidentally left behind after debugging is finished.

Done!

$this->wire('bd_host', $host);

results in:
image.png.d419a31150ac9eff4911f31722d5557d.png

I decided to add the $ and keep the "bd_" prefix in the title to help better identify it as an automatically dumped wire variable.

Let me know if you have any suggestions for improvements.

 

  • Like 5

Share this post


Link to post
Share on other sites

Hey @adrian

just doing some debugging and having a hard time finding out what's going on 😄 Is there a way to see the debug_backtrace easily? I mean something like the backtrace shown when an exception is thrown, but without throwing the exception and just showing the tracy in the debug bar. This could be extremely helpful in many situations. I've installed xdebug but it makes things so slow (~20s page load instead of <1s 😮 ).

An example:

In one of my modules a file is included twice instead of once. That's easy to find out via bd('fired') that will show 2 dumps in the bar. It's not so easy to find out WHY this happens and what triggered the call. When I throw an exception the trace is shown, but that's the first call. It would be nice to analyze both. It would be absolutely awesome if we could do something like

trace()

and get a collapsed backtrace that we can analyze step by step, click on the line of code, etc.

I guess that could be helpful for everyone! Thx 🙂 

Share this post


Link to post
Share on other sites

Hi @adrian,

I have a little problem with the User Switcher panel: there's a config option for limiting the list of users that appear in the panel, which is great because often there can be a lot of front-end-only users. But the problem for me is that the option gets defined in terms of roles that are excluded rather than included:

2019-10-15_163441.png.d0e5070ef33bc6063acbff5141945786.png

I'm not sure how common this is for others, but I often give back-end users (who I want to be able to switch to via the User Switcher) front-end roles because they can also be "members" as well as "administrators". So these kinds of users have multiple roles. What do you think about adding an "include only these roles" option for User Switcher as well as a "exclude these roles" option? Or maybe you have another idea of how this might be accommodated?

Edited by Robin S
Post got duplicated on submit. Weird.

Share this post


Link to post
Share on other sites

Hi @Robin S - happy to add this. Just playing around with it now and I guess the main issue is that when "including" we need to go with "OR" when matching users to roles, but I think we still want "AND" with "excluded (restricted) roles". Because you want to be able to include different admin roles but not require the users to have all these roles. But if you want to exclude/restrict like the current behavior, then you want to exclude all users with any of the selected rules. Does that seem like the correct behavior to you?

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, adrian said:

Does that seem like the correct behavior to you?

I'm sure you're right, but I'm not 100% clear on what you mean here. It seems like both include and exclude settings would use OR conditions:

  • exclude (role1 OR role2 OR role3)
  • include only (role1 OR role2 OR role3)

Or maybe you mean AND/OR in terms of combining the two settings? "exclude (roles) AND include (roles)" versus "exclude (roles) OR include (roles)"
I imagined using one setting or the other but not both, but maybe there are some situations where a user would want to combine them.

Share this post


Link to post
Share on other sites

I am noting that you can only use or the other - you can't combine exclude and include. So the AND/OR is within each option, not between.

I think it's the typical AND/OR issue when you're using the (!) NOT operator - you need to switch from OR to AND.

So, the selector for exclude is: roles!=1021, roles!=38

And the one for include is: roles=1021|38

Anyway, I have committed a new version with this functionality - please test and let me know how it goes.

  • Like 1

Share this post


Link to post
Share on other sites
On 10/12/2019 at 3:53 AM, bernhard said:

It would be absolutely awesome if we could do something like


trace()

and get a collapsed backtrace that we can analyze step by step, click on the line of code, etc.

I like the idea - just not sure if it's possible with the core of Tracy as it currently is because I think some of the methods I'd need to use are private. I had a quick attempt and came up against these, but I'll try again later.

Remember PW has a new bd(Debug::backtrace());  method you can use, but of course it returns an simply array, the same as PHP's debug_backtrace(), so I know it's not what you are looking for.

Share this post


Link to post
Share on other sites
10 minutes ago, adrian said:

Anyway, I have committed a new version with this functionality - please test and let me know how it goes.

Awesome, works great!

  • Like 1

Share this post


Link to post
Share on other sites

@bernhard -  can you please try adding these to a template file where you want to see a debug_backtrace() and let me know if it satisfies your needs:

$blueScreen = new Tracy\BlueScreen;
$blueScreen->render(new Exception);

If you think that works OK, I'll setup a trace() shortcut.

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 gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...