Jump to content

Feature Requests


adrian
 Share

Recommended Posts

While reading my other post of the 5 most used features I thought: A one-click download of a DB dump would be nice! That could then be restored on local dev easily (maybe also as one-click).

Using Adminer is not a problem at all. But it would be handy to have that in the tracy bar. But on the other hand I'm not sure if that should really be a tracy feature or a separate module. I'd love to have a better CI/CD workflow. Also coupled with RockMigrations. But in the meantime it would be nice to have a good workaround.

If you guys have any other good suggestions I'd also be happy to use those so that adrian does not waste his time ? 

Link to comment
Share on other sites

6 hours ago, adrian said:
13 hours ago, Robin S said:

What do you think about adding a Shortcuts panel?

We sort of have this already - take a look at the Custom Links section of the settings for the Processwire Info panel. You can add links to any page on the site, including items under Admin > Setup. Of course this doesn't allow for external links. For external links, I could add an additional settings field for storing these, or we could go with a separate Shortcuts Panel. Semantically it would be strange having external links under the PW Info panel, but maybe that's OK? Any thoughts?

I use the Custom PHP code panel for such a thing ? eg.:

return '
<a href="/admin/module/edit?name=ProcessPageAdd&collapse_info=1" target="_blank">Disable automatic publishing conf</a><br>
<a href="/admin/module/edit?name=ProcessPageEditImageSelect&collapse_info=1" target="_blank">Image handling conf</a><br>
<a href="/admin/module/edit?name=ProcessPageEditLink&collapse_info=1" target="_blank">Link generation of InputFields conf</a><br>
<a href="/admin/module/edit?name=FieldtypePage&collapse_info=1" target="_blank">Orphaned page references check</a>
';

 

  • Like 2
Link to comment
Share on other sites

6 hours ago, adrian said:

We sort of have this already - take a look at the Custom Links section of the settings for the Processwire Info panel. You can add links to any page on the site, including items under Admin > Setup. Of course this doesn't allow for external links.

I didn't know about adding custom links here, thanks. ?

It's somewhat limited though because it can't handle URL segments or GET variables which are widely used in the admin, so you can't link to a module config for instance. My preference would be for a separate panel just for shortcut links, internal and external. The PageListSelect works well for pages but I think inputing URLs would be better because then it's one interface for entering any kind of link. Example:

2021-01-16_105810.png.57ef6f6c4e89a1abc5ad879447ab479f.png

Just thinking out loud here, but when a link is added or changed it would be cool if...

  • The root URL is removed from internal links so link becomes relative.
  • If a URL is submitted without a label...
    • For internal URLs, $pages->getByPath($url) is used, and if a Page object is returned the page title is used as the link label.
    • For external URLs and internal URLs for which getByPath($url) returns a NullPage, attempt to get the title element using DomDocument and use it as the link label.
libxml_use_internal_errors(true);
$dom = new \DOMDocument();
$dom->loadHTMLFile($url);
$list = $dom->getElementsByTagName('title');
$label = $list->length ? $list->item(0)->textContent : $url;

These latter features aren't crucial, they're just so we have the option of being lazy and adding a URL only. ?

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

@Pete - your "allowed superuser" option is now available in the latest version.

@Robin S - I implemented your quicklinks filtering - I think it's a really nice improvements - thanks! Also, I haven't forgotten about your shortcut links panel idea - it's next on my list.

 

  • Like 3
Link to comment
Share on other sites

  • 1 month later...

Hey @adrian

I have lots of hooks firing in one project and I cant seem to find which one is causing a page name to change after save. The hooks debug panel is really helpful, but not in this case:

sIs06xR.png

Would it be possible to add links to that table so that if I click on "anonymous function" for example the file would open exactly at the place where this hook was added so we can inspect the code of the hook and quickly see what they are doing?

edit:

Ok, that was the "problem" - you might know this module ?? 

faFKmcL.png

So my problem seems to be solved, but my request might still be helpful if it is easy to implement? ? 

  • Like 1
Link to comment
Share on other sites

@adrian thx a lot, this is a brilliant update ?

I have some follow up questions:

This is how my panel looks like:

W7edBJH.png

And this is where the hook is attached:

<?php namespace GemeindeGuru;
use ProcessWire\HookEvent;
class Headline extends \RockMatrix\Block {

  public function info() {
    return parent::info()->setArray([
      'icon' => 'header',
      'title' => 'Überschrift',
      'description' => 'Fügt eine Überschrift auf der Seite ein.',
    ]);
  }

  public function init() {
    $this->addHookAfter("Pages::saveReady", $this, "saveReady");
  }

  public function saveReady(HookEvent $event) {
    $page = $event->arguments(0);
    if($page->template !== $this->getTpl()) return;
    if(!$page->id) $page->title = "New Headline";
  }
}

Any ideas why it shows 0::saveReady instead of Headline::saveReady or even better \GemeindeGuru\Headline::saveReady ?

---

Another question - this line:

NuYmzrH.png

Is this hook:

$wire->addHookAfter("Pages::saveReady(template=newsitem)", function(HookEvent $event) {
  $page = $event->arguments(0);
  if(!$page->date) $page->date = $page->created;
});

So I already see that anonymous functions seem to be harder to debug, so I might better use the object notation $this->addHookAfter("Foo::bar", $this, "myDescriptiveHookMethod") in the future.

But in the example above, would it be hard to make tracy show "Pages::saveReady(template=newsitem)" instead of just "Pages::saveReady()" ? Not sure if that makes sense? Other opinions welcome ? 

---

ytOS37k.png

I just clicked the saveModuleConfigData hook and landed in site\assets\cache\FileCompiler\site\modules\TracyDebugger\TracyDebugger.module.php

I wonder if it was possible to link to the non-compiled version of the file?

---

And last but not least: Does the order of the table give me any additional information? Like does it represent the order in which the hooks where attached? Or does it represent the order when they where fired? Or do we even see when/if the hooks where fired? If not, would that be possible?

It seems that I'm getting quite long lists of hooks that are attached... not sure what to do about this, because on the one hand many of them do seem necessary (for example a saveReady hook needs to be present so that it can do its magic whenever a page is saved), on the other hand on a request where I want to debug other things that are not related to a page save at all it might be more helpful to get a list of hooks that have actually been triggered on that request. Or maybe just print them bold to be different.

Hope that makes sense - thx again, I'm quite sure that this update will already save me a lot of headache in the future ? 

Link to comment
Share on other sites

@bernhard - I'm in a bit of a rush this morning, but please try the attached version and see if it fixes the 0::SaveReady() issue.

It should also fix the issue with taking the filecompiler out of the linked path.

I'll have to look at the other things later, but keep in mind that most of this functionality comes from:

https://github.com/processwire/processwire/blob/dev/wire/core/WireDebugInfo.php

 

TracyDebugger.zip

  • Like 1
Link to comment
Share on other sites

Quote

Undefined variable: toObjectName in \site\assets\cache\FileCompiler\site\modules\TracyDebugger\panels\DebugModePanel.php:213

Adding the namespace makes it a little more bloated but that's helpful information sometimes and therefore should not be missing, thx! ? 

3tjzpyH.png

Link to comment
Share on other sites

@bernhard - please try the latest committed version.

I have removed the namespace when it's ProcessWire but it shows for all others, so hopefully that reduces the clutter without losing the useful information.

Hopefully the undefined $rc is now fixed.

Regarding the order, it's by priority and the name. This is how the PW core debug info handles it so I assume that means it's not possible to show in the order they are triggered, but maybe a question for Ryan.

Anything else I've missed?

  • Thanks 1
Link to comment
Share on other sites

nope, sorry, now the zeros are back in my list:

2KbPVSX.png

That seems to happen on all hooks inside non-PW namespaced files. But not only. There are also zeros in the PW namespace.

If you tell me how that works and where I have to look maybe it's easier if I try to fix it? But the code is not that easy to grasp ? 

Link to comment
Share on other sites

Sorry, I haven't been able to reproduce the 0 issue and I have a module with a custom namespace and anonymous hooks. Perhaps it's because my dev setup is PHP8?

Anyway, if you're willing to take a look, that would be great. You can see the code I have been working on here: https://github.com/adrianbj/TracyDebugger/commit/a600310a62aed42c16d1079ffa11728e02336c60#diff-470f7296769058027980e4975f92bc567bb7cb7ae07bb1d238136759b913001d

It's all about PHP's reflection features. You just need to handle whether things are a closure, function, object etc. As I mentioned above, I was relying on the PW core's debug code which also does a lot of this, but I needed to recreate some of it to get the file and line number for closures.

Let me know if you have any questions and I'll try to help.

  • Like 1
Link to comment
Share on other sites

On 1/15/2021 at 12:10 AM, Robin S said:

What do you think about adding a Shortcuts panel?

@Robin S

Sorry it took me so long to get to this, but the latest version has a new "Links" panel that lets you easily add links as you described with automatic conversion to root relative links and grabbing the page title for use as the label if one isn't supplied.

Let me know if you have any problems with it.

  • Like 2
Link to comment
Share on other sites

4 hours ago, adrian said:

the latest version has a new "Links" panel that lets you easily add links as you described with automatic conversion to root relative links and grabbing the page title for use as the label if one isn't supplied.

Awesome, thanks for adding this!

The conversion to relative URLs is working great and grabbing the HTML page title is working for external links, but it looks like there's a problem getting the titles of pages in the PW admin.

2021-04-08_164848.png.0ecf0219624c9a64ca9eb68bd57e80a4.png

Not sure if there's an easy way to solve that - is it even possible to send WireHttp requests so they appear to come from a logged in superuser rather than guest?

  • Like 1
Link to comment
Share on other sites

2 hours ago, Robin S said:

is it even possible to send WireHttp requests so they appear to come from a logged in superuser rather than guest?

I believe the superusers session cookie has to be send with the WireHttp request for that?

Link to comment
Share on other sites

Hi Adrian, I'm not sure how to do it with wireHttp, means haven't used it until now. But the native header for sending cookies back to the server looks like this:

GET /processwire/page/ HTTP/2
Host: www.example.com
Cookie: key1=value1; key2=value2

Its a simple key=value pair list separated by semicolons send as a header. Maybe it can be done like this:

$http = new WireHttp();
$http->setHeader('Cookie', $cookieList);

References:
https://tools.ietf.org/html/rfc6265
https://chenhuijing.com/blog/understanding-browser-cookies/

 

  • Like 3
Link to comment
Share on other sites

Thanks for the tips @horst but I think I am being dumb. I tried with wireHttp and even plain curl with CURLOPT_COOKIE and in both cases sending wire or wire_challenge on their own doesn't work, but if I send both together, eg:

$http->setHeader('Cookie', 'wire='.$this->wire('input')->cookie->wire.';wire_challenge='.$this->wire('input')->cookie->wire_challenge);

then it just keeps loading until apache times out, but I don't get any errors. 

I don't have time to spend fiddling with this today. Maybe I'll revisit later, or if someone else can see what I am doing wrong, any tips would be greatly appreciated.

 

  • Like 2
Link to comment
Share on other sites

1 minute ago, horst said:

Https instead of http?

I am defining $http like this:

$http = new WireHttp();

2 minutes ago, horst said:

Then it should be wires_challenge  with s, not wire_challenge. ?

I am actually very confused by this - I always see "wire" in regular browser windows, but I see "wires" in private / incognito windows. Regardless, trying "wires" doesn't help.

 

Link to comment
Share on other sites

Sorry, I just realized what you were getting at regarding https. I am testing this locally, so it's http and therefore wire / wire_challenge, rather than wires / wires_challenge. Out of interest, I tried this on a https server and I still get the same timeout issue.

  • Like 1
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...