adrian

Tracy Debugger

Recommended Posts

1 hour ago, bernhard said:

But I cannot enable the console for my non-superuser?

So sorry @bernhard - I didn't read that bit of your question - my apologies!

I have purposely prevented the Console, File Editor and Adminer panels and some others from working for non-superusers. Perhaps this could be made optional, but it seemed like a good default security setting. I can work on this later for you, but for now, just remove this line: https://github.com/adrianbj/TracyDebugger/blob/b225975afdad1c86ecb7ac7d4a724b46dcbcd0f0/TracyDebugger.module.php#L1444

and this conditional: https://github.com/adrianbj/TracyDebugger/blob/b225975afdad1c86ecb7ac7d4a724b46dcbcd0f0/includes/CodeProcessor.php#L20

I think those should get you going.

  • Thanks 1

Share this post


Link to post
Share on other sites

Thx adrian, I see your intention now 🙂 I just tried the user switcher and I have everything I need there. 

Is there a reason for the guest user not being selectable in this panel? It might be helpful to switch to a guest user as well and have tracy for debugging (console, dumps, etc)?

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, bernhard said:

Is there a reason for the guest user not being selectable in this panel?

All you have to do is start a User Switcher session and then click the logout button - that is the same as selecting guest.

Oh yeah, and good idea about using the User Switcher - sorry, too rushed to think of that this morning 🙂

Share this post


Link to post
Share on other sites
On 2/8/2019 at 8:03 AM, adrian said:

I have purposely prevented the Console, File Editor and Adminer panels and some others from working for non-superusers. Perhaps this could be made optional, but it seemed like a good default security setting.

I'd be keen to have an option to enable the Console for non-superusers on localhost. If it's limited to localhost then there's not really a security risk I think. It would be handy for checking things like $page->addable(), $page->publishable(), etc from the perspective of a non-superuser role. When testing I typically keep an incognito window open with an editor role logged in rather than work with the User Switcher.

  • Like 3

Share this post


Link to post
Share on other sites

@Robin S - I haven't ignored your request - it will be in the next version.

Speaking of the next version, I have been looking at the poll from @teppo's PW Weekly and wondering what you guys would think about Tracy dropping support for PHP < 7.1 ?

The new core Tracy 3.0-dev version requires PHP version 7.1 or newer and looking at the changes since the 2.5 version we are currently using, it won't be practical to support two versions of the core like I have done previously. So, the question is, can I make 7.1 a requirement for the new version?

Not sure how to really get your feedback on this, but maybe a "like" means your OK with it, or a "sad" if you're not happy either sticking with the current version of this module (to maintain 5.x support), or otherwise don't want to lose 5.x support just yet.

The new Tracy core comes with much faster rendering of dumped objects with a lot of depth, so we might be able to increase the default and big dump options significantly.

There have also been improvements to live dumping that I still need to experiment with, but both sound very useful to have so I would like to upgrade.

Thanks for your thoughts.

image.thumb.png.2f818fdef1679dde462e9664fb08d0b8.png

 

  • Like 5

Share this post


Link to post
Share on other sites

Just another update to the Tracy core - apparently LIVE dumps now work more reliably and are now the default when calling barDump(), so it looks like we'll be able to ditch our custom bdl() method and probably even our bdb() and db() and integrate the LIVE option into standard d() and bd() calls. 

As you can tell, I am excited about the new version 🙂

  • Like 2

Share this post


Link to post
Share on other sites

I'm biased, and probably not the biggest user of Tracy either, but in my opinion support for PHP < 7.1 should be safe to drop by now. For the folks stuck with those versions, current Tracy version still works – right?

That's what I've been doing with my modules and code recently: splitting a separate "legacy" branch for those who need it, but only focusing new development for current PHP versions. And by "current" I mean the officially supported ones.

  • Like 3

Share this post


Link to post
Share on other sites

+1 for dropping support. Maybe adding a check before upgrade and showing a warming/hint that older php versions can use the old tracy module (that is already great) with a link where to download it?

  • Like 2

Share this post


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

Maybe adding a check before upgrade and showing a warming/hint that older php versions can use the old tracy module (that is already great) with a link where to download it?

+1 one for this!

Otherwise this change forces me to bump my sites from PHP 7.0.x to 7.1.x which is great! Thanx 🙂 (I always play safe, so I'm reluctant to go higher than necessary...)

Share this post


Link to post
Share on other sites
18 minutes ago, szabesz said:

Otherwise this change forces me to bump my sites from PHP 7.0.x to 7.1.x which is great! Thanx 🙂 (I always play safe, so I'm reluctant to go higher than necessary...)

Probably worth pointing out that currently the "safe thing to do" is going with 7.1 or 7.2: 7.0 is no longer officially supported, so it's no longer receiving security updates, and even 7.1 will stop receiving (security) updates near the end of this year.

7.3 is currently the "cutting edge" version, so you might want to wait a while before going there.

In terms of security there are exceptions, such as Ubuntu, where distro maintainers have been backporting security-related fixes from new versions to old ones – but if you're already on 7.0, I would assume that it's not the one that you got with your operating system, and as such is likely that you're already using a (potentially) insecure version.

  • Like 3

Share this post


Link to post
Share on other sites

For those interested - looks like the Tracy core will be getting multiple AJAX bars in v3: https://github.com/nette/tracy/pull/336#event-2144817375

This will be great for many reasons and will also let me remove my additive approach to dumps in the AJAX bar because consecutive requests will show the dumps on separate bars, rather than overwriting the last one which is how the core currently works.

  • Like 2

Share this post


Link to post
Share on other sites
On 2/7/2019 at 8:22 PM, bernhard said:

Thx adrian, I see your intention now 🙂 I just tried the user switcher and I have everything I need there. 

Is there a reason for the guest user not being selectable in this panel? It might be helpful to switch to a guest user as well and have tracy for debugging (console, dumps, etc)?

Hi Adrian,

just tried your suggested method on another website where I only have guest + superuser. It does not work as expected, or I'm missing something. When I start a user switcher session and logout, I get the debug bar, but I still cannot open the console. So it is not possible on that site to do some quick console tests and dumps...

This would be really helpful on that setup. Or is there another hidden way how I could use the console as guest user?

Would be great to have the guest user available in the switcher! Thx

Share this post


Link to post
Share on other sites

Hey @bernhard - sorry about that - it didn't work as you expected. Please try the latest version which lets the Console panel work as a guest when you use the "logout" option via the User Switcher and also it now works on localhost when using the "Force guest users into DEVELOPMENT mode on localhost" which should take care of @Robin S's request above.

Hopefully the next version will include the new Tracy core features along with some other tweaks - just need to find some time 🙂

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
On 2/20/2019 at 11:36 AM, adrian said:

Please try the latest version which lets the Console panel work as a guest when you use the "logout" option via the User Switcher and also it now works on localhost when using the "Force guest users into DEVELOPMENT mode on localhost" which should take care of @Robin S's request above.

Thanks for adding this feature!

There seems to be a problem with the console output though. No matter what I dump the output consists of the entire rendered page.

2019-02-21_180609.png.08545b98d2706d79c10c7043800695db.png

This occurs when using the console as guest or logged-in non-superuser. 

  • Like 1

Share this post


Link to post
Share on other sites

Hey @Robin S - sorry about - I went through a few different iterations of things and looks like I messed up a couple of things on the last version. I just made a quick fix (no version bump) that fixes it for local guest users, but I think I need to do a bit more to get non-superusers working. Feel free to test the recent commit, but hopefully will have a complete fix shortly.

  • Like 1

Share this post


Link to post
Share on other sites

Actually, thinking about non-superusers - not quite sure what I want to do here.

Using the user switcher to switch to a non-superuser I think is OK for the console etc, but I don't actually think they should be available to non-superusers unless you're on local dev. Are you ok with that?

 

Share this post


Link to post
Share on other sites
1 minute ago, adrian said:

Are you ok with that?

Okay with me as I do almost all development on localhost.

  • Like 1

Share this post


Link to post
Share on other sites
Just now, Robin S said:

Okay with me as I do almost all development on localhost.

And I think the key thing is that on a remote server you can still use the user switcher to change to a non-superuser and it will work - it's just that I don't want actual non-superuser users that might have the tracy-debugger permission from using it.

I think that last version I just committed should be ok for this scenario. I am double checking here now, but could you confirm at your end also please?

 

  • Like 1

Share this post


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

I am double checking here now, but could you confirm at your end also please?

Thanks, working well for me as guest/non-superuser on localhost, and when using User Switcher on remote host.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks - I actually just committed one more change and did a version bump and updated modules directory. 

Share this post


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

I actually just committed one more change and did a version bump and updated modules directory

Cool, will update.

Something unrelated I'll just throw out there for the wishlist... it would be cool if the code window in the Console didn't resize proportionally when the panel is resized. So the code window would have a pixel height rather than a percentage height and the result window would have a height along the lines calc(100% - [console window pixel height]). I know you added a lot of neat stuff relating to the code window height (line snapping and keyboard shortcuts) and for all I know this request would complicate all of that, in which case don't worry because it's not that important. 🙂

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, Robin S said:

it would be cool if the code window in the Console didn't resize proportionally when the panel is resized

Yeah, I kinda agree with you - it's a bit annoying at times - I have gotten used to the keyboard shortcuts to increase/decrease as needed. Not sure how easy it would be to do what you want because I make use of the splitjs library (https://github.com/nathancahill/split) for that stuff and it's a percentage based setup and not sure how I would go about overriding that at the moment - it's certainly on my mind though.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Adrian,

Recent Tracy versions do not work in the backend (the issue also prevents admin login), the "errors" I get (PHP 7.1.22):

Spoiler

Warning: in_array() expects parameter 2 to be array, string given in .../TracyDebugger.module.php on line 1955
Warning: in_array() expects parameter 2 to be array, string given in .../TracyDebugger.module.php on line 1962
Warning: in_array() expects parameter 2 to be array, string given in .../TracyDebugger.module.php on line 971
Warning: in_array() expects parameter 2 to be array, string given in .../TracyDebugger.module.php on line 1032
Warning: in_array() expects parameter 2 to be array, string given in .../TracyDebugger.module.php on line 1049
Warning: Cannot modify header information - headers already sent by (output started at .../TracyDebugger.module.php:1955) in .../TracyDebugger.module.php on line 1201
Modules: Failed to init module: TracyDebugger - Tracy\Debugger::dispatch() called after some output has been sent. Output started at .../TracyDebugger.module.php:1955.

I tested a few old versions and TracyDebugger-4.17.10 is ok, while TracyDebugger-4.17.16 has this issue, so something between these two introduced the problem. I reverted back to v4.17.10 for the time being.

Share this post


Link to post
Share on other sites

No problems here with Tracy 4.10.23 / 4.17.23 + PHP 7.0.33 / 7.2.6.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   1 member

  • Similar Content

    • By Anssi
      A simple module to enable easy navigation between the public and the admin side of the site. After installation a green bar will appear to the upper side of the screen, containing a few navigation elements and displaying the PW version number.
      Heavily inspired by @apeisa's great AdminBar (Thanks!). I needed a bit simpler tool for my projects and as a result, this was made. Available on GitHub .

    • 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.
      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!
    • By David Karich
      Thanks to the great Pro module "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use this module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      With this proof of concept I have created a module which adds the feature to copy a repeater item to the clipboard so that you can paste this item to another page with the same repeater field. The module has been developed very rudimentarily so far. It is currently not possible to copy nested items. There is also no check of Min/Max. You can also only copy items that have the same field on different pages. And surely you can solve all this more elegantly with AJAX. But personally I lack the deeper understanding of the repeaters. Also missing on the Javascript side are event triggers for the repeaters, which would make it easier. Like e.g. RepeaterItemInitReady or similar.
      it would be great if @ryan would implement this functionality in the core of RepeaterMatrix. I think he has better ways to implement this. Or what do you think, Ryan?
      Everybody is welcome to work on this module and improve it, if it should not be integrated into the matrix core. Therefore I put it for testing and as download on GitHub: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDublicate
      You can best see the functionality in the screencast: 
       
    • By anderson
      Hi,
      Please take a look at this:
      https://templatemag.com/demo/Good/
      The upper nav bar, including dropdowns like "pages" and "portfolios", what do you call this whole thing? At first I guess it's called "dropdown nav bar", but seems not.
      AND of course, what's the simplest way/module to achieve this in PW?
      Thanks in advance.
    • By Sebi2020
      Hey, I'm new and I created a simple module for tagging pages because I didn't found a module for it (sadly this is not a core feature). This module is licensed under the GPL3 and cames with absolutly no warranty at all. You should test the module before using it in production environments. Currently it's an alpha release. if you like the module or have ideas for improvements feel free to post a comment. Currently this fieldtype is only compatible with the Inputfield I've created to because I haven't found  an Inputfield yet, that returns arrays from a single html input.
      Greetings Sebi2020
      FieldtypeTags.zip.asc
      InputfieldTagify.zip
      InputfieldTagify.zip.asc
      FieldtypeTags.zip