-
Posts
10,912 -
Joined
-
Last visited
-
Days Won
349
Everything posted by adrian
-
Just tested now and unfortunately it's logging me out again. I tried moving things to __destruct and removing the session_write_close but that just resulted in the timeout issue ?
-
Good point @horst about using getallheaders() to ensure the fingerprint matches. I have combined that with @Robin S's code and it looks like we have a winner. Your combined brilliance seems to have got us through. I'll test a bit more tomorrow, including on a production server with https, but hopefully we'll be good. Here is the version I am using: // make URLs in links panel root relative and get titles if not supplied $existingConfig = $this->wire('modules')->getModuleConfigData($this); $existingLinks = isset($existingConfig['linksCode']) ? $existingConfig['linksCode'] : ''; $savedLinks = isset($data['linksCode']) ? $data['linksCode'] : ''; if($savedLinks !== $existingLinks) { $this->addHookAfter('ProcessWire::finished', null, function($event) { // Make URLs in links panel root relative and get titles if not supplied $tracyConfig = $this->wire('modules')->getModuleConfigData($this); // Close existing session to avoid session blocking $allHeaders = getallheaders(); session_write_close(); $allLinks = array(); $http = new WireHttp(); foreach($allHeaders as $header => $value) { if('Host' == $header) continue; $http->setHeader($header, $value); } foreach(explode("\n", $tracyConfig['linksCode']) as $link) { $link_parts = explode('|', $link); $url = trim($link_parts[0]); $title = isset($link_parts[1]) ? trim($link_parts[1]) : ''; $url = str_replace($this->wire('config')->urls->httpRoot, '/', $url); if($title == '') { $fullUrl = strpos($url, 'http') === false ? $this->wire('config')->urls->httpRoot . $url : $url; $html = $http->get($fullUrl); libxml_use_internal_errors(true); $dom = new \DOMDocument(); $dom->loadHTML($html); $list = $dom->getElementsByTagName('title'); libxml_use_internal_errors(false); $title = $list->length ? str_replace('|', ':', $list->item(0)->textContent) : $url; } $finalLink = $url . ' | ' . $title; $allLinks[] = $finalLink; } $tracyConfig['linksCode'] = implode("\n", $allLinks); // Calling saveModuleConfigData with underscores because we don't need hooks to run again $this->wire('modules')->___saveModuleConfigData($this, $tracyConfig); }); }
-
Thank very much for figuring out the issue @Robin S - I have tried implementing your code but I keep getting logged out due to the session_write_close() and nothing happens after that. I tried testing with and without SessionHandlerDB and that made no difference. I tried to use $session->forceLogin() to log back in again after the curl request, but that didn't help either. Are you testing this on Windows? I wonder if that might be the difference?
-
Thanks for looking into improving the autodesc - much appreciated. Interesting - I haven't changed the default MySQL settings, so not sure what has changed there. The reason I am using it is that if I change to %= then a search for "stream banks" won't find instances of "streambanks" which I think is pretty important - sometimes it's hard to know whether these sorts of things are one word or two. Fair enough - I am not too worried about this at all - it's just what I thought made sense when I built that example 18 years ago, which BTW was still in production until a couple of weeks ago ?
-
@cb2004 - unfortunately Soma has left the building, but I still use that MarkupSocialShareButtons module and it works well. There is also this module (https://processwire.com/modules/video-or-social-post-embed/) which I haven't used - just in case you haven't seen it.
-
-
Oh sorry, I honestly haven't tried your module yet - probably should before I provide poor advice. In my experience there isn't a way to do this by relying on the same page IDs but maybe it's OK with the way you have things set up. I'll shut up for now ?
-
If you look at the code in Migrator you'll see that I store images in the migration zip package under a path that matches the path of the page they are associated with, so for example, an image asociated with a blog post might look something like this: Page path: /blog/my-latest-blog/ Images for that pos: zippackage/blog/my-latest-blog/image-1.jpg, zippackage/blog/my-latest-blog/image-2.jpg, etc Then when the migration package is installed on the other site and the new page ID for blog/my-latest-blog/ is determined, the images are then added to that page and installed into the /assets/files/xxxx that matches that new ID. There is so much to consider with all this stuff, but if you run through a full migration of a tree of pages using Migrator you'll see how it stores all this stuff in the zip and how it modifies the paths in RTE fields to match the path of the page and then back to the /assets/files path again.
-
@MarkE - also, just a reminder about updating the path to images embedded in RTE fields. You might find some useful code for that starting here: https://github.com/adrianbj/ProcessMigrator/blob/b327626606bcdc9cc6c74bd00f9e9d2bcd2cae50/ProcessMigrator.module#L2588
-
Thanks @Robin S and @horst - unfortunately I am still getting this timeout behaviour, even with your approach horst, so I have no idea ?
-
Thanks for showing those modules some love Ryan - much appreciated!
-
@teppo - Not sure if you can do anything about this easily, but take a look at this: https://ian.umces.edu/search/?q=Incised+stream+banks&t=blog_post Notice how there is no autodesc shown, but if you click on the second link, you'll see that there is "incised streambanks" in the main text. I know this is because I am using the "~=" operator, but it would be a great improvement if this could be improved. I feel like a relatively simple preg_match, looking for each separate word in the search term should do it. The other related thing that I think would be nice is if separate words were highlighted separately. This is something I have done previously like this.
-
Thanks @Robin S - new version looks good.
-
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.
-
I am defining $http like this: $http = new WireHttp(); 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.
-
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.
-
Horst - do you explain how to do that exactly. Should it be part of the $data array as described here: https://processwire.com/api/ref/wire-http/send/
-
@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.
-
@Robin S - Ryan's update to the HannaCode module yesterday has broken this. Looks like it's probably just because he namespaced it, so should be an easy fix. PS - @teppo - I wonder if your HannaCodeHelper module might suffer the same fate?
-
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.
-
@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?
-
Weird how you're getting these undefined errors and I am not. Must be a type that I don't have. Did it fix the 0::SaveReady issue?
-
@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
-
@teppo - something I just discovered is that if you uninstall this module it can result in the issue that @Ivan Gretsky was seeing where you can no longer access the page tree, or you can actually see everything (depending on what you have set for the "If no match, give all access or no access?" setting) because the settings for the "branch_parent" field are not reverted on uninstall. I have a feeling this won't matter if/when I implement Ivan's request for support multiple branches for edit restrictions in the core ARB module, but in the meantime, this may bite someone if they're not careful.
-
@bernhard - I've added editor links to those in the latest version.