Macrura Posted August 13, 2019 Share Posted August 13, 2019 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. 1 Link to comment Share on other sites More sharing options...
adrian Posted August 13, 2019 Author Share Posted August 13, 2019 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. Link to comment Share on other sites More sharing options...
Macrura Posted August 14, 2019 Share Posted August 14, 2019 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! 1 Link to comment Share on other sites More sharing options...
adrian Posted August 14, 2019 Author Share Posted August 14, 2019 Thanks @Macrura - that got me on the right track - should be fixed in the latest version. 1 Link to comment Share on other sites More sharing options...
Macrura Posted August 15, 2019 Share Posted August 15, 2019 Great, thanks! 1 Link to comment Share on other sites More sharing options...
a-ok Posted September 2, 2019 Share Posted September 2, 2019 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... Link to comment Share on other sites More sharing options...
bernhard Posted September 2, 2019 Share Posted September 2, 2019 You can just dump() or barDump() the $row object: You have the "debug info" and the "full object" options. Link to comment Share on other sites More sharing options...
bernhard Posted September 12, 2019 Share Posted September 12, 2019 @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). Link to comment Share on other sites More sharing options...
adrian Posted September 12, 2019 Author Share Posted September 12, 2019 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! Link to comment Share on other sites More sharing options...
bernhard Posted September 13, 2019 Share Posted September 13, 2019 Thx that helped! I just deleted the exceptions.txt logfile which had some base64 encoded string in it. I guess this was the culprit 🙂 Link to comment Share on other sites More sharing options...
adrian Posted September 13, 2019 Author Share Posted September 13, 2019 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? Link to comment Share on other sites More sharing options...
bernhard Posted September 14, 2019 Share Posted September 14, 2019 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! 1 Link to comment Share on other sites More sharing options...
Robin S Posted September 28, 2019 Share Posted September 28, 2019 (edited) 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. 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'); Edited September 28, 2019 by Robin S Shorter way to dump variable on Wire object 5 Link to comment Share on other sites More sharing options...
adrian Posted September 28, 2019 Author Share Posted September 28, 2019 Really great idea @Robin S ! You can make it even less work by using d($td_host) in the Console panel: 4 Link to comment Share on other sites More sharing options...
adrian Posted September 28, 2019 Author Share Posted September 28, 2019 @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 🙂 2 Link to comment Share on other sites More sharing options...
Robin S Posted September 28, 2019 Share Posted September 28, 2019 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. 1 Link to comment Share on other sites More sharing options...
adrian Posted September 29, 2019 Author Share Posted September 29, 2019 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: 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. 5 Link to comment Share on other sites More sharing options...
bernhard Posted October 12, 2019 Share Posted October 12, 2019 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 🙂 Link to comment Share on other sites More sharing options...
Robin S Posted October 15, 2019 Share Posted October 15, 2019 (edited) 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: 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 October 15, 2019 by Robin S Post got duplicated on submit. Weird. Link to comment Share on other sites More sharing options...
adrian Posted October 15, 2019 Author Share Posted October 15, 2019 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? 1 Link to comment Share on other sites More sharing options...
Robin S Posted October 15, 2019 Share Posted October 15, 2019 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. Link to comment Share on other sites More sharing options...
adrian Posted October 15, 2019 Author Share Posted October 15, 2019 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. 1 Link to comment Share on other sites More sharing options...
adrian Posted October 15, 2019 Author Share Posted October 15, 2019 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. Link to comment Share on other sites More sharing options...
Robin S Posted October 15, 2019 Share Posted October 15, 2019 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! 1 Link to comment Share on other sites More sharing options...
adrian Posted October 16, 2019 Author Share Posted October 16, 2019 @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. Link to comment Share on other sites More sharing options...
Recommended Posts