Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by ErikMH

  1. Thank you all very much for your suggestions for further research; I am consistently amazed by the high quality of responses here, as well as the high signal-to-noise ratio! I owe you an update: As I mockingly predicted to myself, the mere act of writing the OP seems to have fixed the problem. Of course, I know this *isn’t* really true, but in truth I have not been unexpectedly logged out even once since I posted here two days ago — astonishing, given that I’d gotten logged out at least 25 or 30 times in the two or three hours leading up to my post. In a perfect world, I would hunt this down ASAP *before* it bites me again. Pragmatically, though, I have to admit that I’m on deadline and there are more immediately pressing concerns. Again, I am very grateful for all of the various pointed questions; they will be the first place I turn when the problem returns. And I promise to update the thread with more info when that happens! In the meantime, thank you, @Jonathan Lahijani, @bernhard, & @flydev!
  2. I should add that I am now often (but not always) seeing an error dialog that says: > Unknown error, please try again later and then I’m shown a rather alarming (but, fortunately, totally spurious) empty listing of pages:
  3. There are quite a few threads here where users report ProcessWire repeatedly logging them out (see below). I, too, have had this problem intermittently over the two years I’ve been using PW. I was able to reduce the problem somewhat about a year ago by turning fingerprinting completely off — but the problem has never completely gone away. I’m now at my wits’ end: I was unexpectedly logged out a half-dozen times again earlier today, though I could never see a pattern. As of an hour ago, though, every single time I try to update a field definition, the change is discarded and I’m logged out. Using a different browser helped for a few minutes, but then it began having precisely the same predictable problem. Fingerprinting is off altogether ($config->sessionFingerprint = false;). CSRF protection is off ($config->protectCSRF = false;). I have installed the Session Handler Database, so my /assets/sessions/ folder is empty. This is my PW development environment, running on my MacBook Pro (M1 Max, current MacOS) via DDEV and Colima; restarting the environment has no effect. I do use Cloudflare WARP/ on my Mac, though that shouldn’t be relevant; turning it off has no effect. session.gc_maxlifetime is the default 1440 session.gc_divisor is the default 10001 I would like to fix this problem for good and never see it again, so that I can get back to far more important work. Does anyone have any ideas? --- Chronological (probably not comprehensive) list of relevant threads that I’ve read thoroughly:
  4. @teppo, it looks like this is precisely the module I was going to begin searching for on Monday. I’m wildly excited that you’re doing this, though I understand your warnings and cautions. My fingers are crossed!
  5. Fantastic little module, and I especially like the “magic” that happens when certain interpolated punctuation marks (“,”, “|”) are used between concatenated strings and one of the concatenated strings is blank: they’re left out! ? Would it be simple to add an ellipsis (“…”) to the list of characters so treated? My use case involves long paragraphs where I keep track of opening- and closing-words separately (in text fields), but I’d like to be able to represent the whole paragraph with Starting words … concluding words. Occasionally, there’s a very short paragraph, and I don’t want to imply that something has been left out (which an ellipsis, of course, does) — and in those unusual cases I include all of the text in the “starting words” field, leaving the “ending words” field empty. But (unlike with , and with |) the ellipsis shows up regardless.
  6. You just saved my bacon, @Robin S — thanks for this! For those searching, this is the secret sauce for presenting a subset of entries to select from, based on a previous selection. In my case: parent=page.refSection where refSection is a grosser-level selection in a hierarchy. I believe this also answers this question:
  7. Well, but that can’t be right. You posted this, with findMany() working just fine yesterday: So it looks like there’s something about getPage() (implicit or explicit), first(), and presumably last(), in combination with findMany(). I think.
  8. Excellent thought. I haven’t done this before, so hopefully I’ve got the details right: findMany() combined with getPage() gives pages whose parents are (incorrectly) NullPage
  9. OK, guys, it seems there was one more piece to the puzzle. Like @adrian, when I recreated the situation in a simple test environment running 3.0.192, I couldn’t recreate the problem. I should have tested this yesterday, but where I’d discovered that changing findMany() to find() in my code worked around the problem, I figured I’d found it. So, the following conditions are necessary but insufficient: PW 3.0.192 or greater (including the current version) page classes findMany() instead of find() I believe I’ve found the final ingredient. I have tested this in a simplified environment and recreated the problem: 4. getPage() In real life, I’ve rolled my own pagination (since I’d wanted to provide users with logarithmic-like controls for moving backwards and forwards through the site, and provide them with sign-post dates); this paginating has worked well. But it means that rather than a foreach loop I cycle through results in a for loop, and then assign the item with a getPage(). So, Adrian’s code looked like: foreach($pages->findMany('template-basic-page') as $p) { d($p->id . ' : ' . $p->returnParentId()); } but mine looks more like: $items = $pages->findMany('template=Test'); for ($idx = 0; $idx < 1; $idx++): $p = $items->getPage($idx); echo ($p->identify()); endfor; (Yes, that’s my test system, where I’ve hard-coded it to “loop” through just one test record; it’s sufficient to show the problem though: ProcessWire\TestPage #279 id: 1025 name: 'test-record-a' parent: '' template: 'Test' title: 'Test record A' data: array (1) 'title' => 'Test record A' parent there should = '1'. I see that I can do the same thing by removing getPage() altogether: $p = $items($idx); In the grand scheme of things, I don’t know which is better; however, this assignation — whether implicit or via getPage(), seems to be the final piece: add this, and $this->parent() becomes a NullPage. So, to sum up: all of this works fine in 3.0.150-or-so (where I developed it) on up through 3.0.191. As of .192, it breaks. Switching from findMany() to find() works around the problem. Sticking with findMany() and using the customary foreach() code pattern also works around the problem. Phew! @kongondo, I agree that the commit you link to looks relevant. Do you think the (implicit or explicit) getPage() may call any of that code?
  10. This is good to know about, @adrian — thanks for drawing my attention to it! No, though, 3.0.195 behaves just like everything else for me beginning with 3.0.192. If I use findMany(), I have the problem as outlined above; if I use find(), everything’s fine.
  11. Thank you, @adrian, for that pointer. I’d had no idea that JS hadn’t been running. I’ll look into your example soon! But the big news is that I’ve solved the problem! @ryan, @bernhard, & @kongondo — thanks to each of you, too, for your encouragement and good ideas! Essentially, there is a bug, but it only presents itself when using findMany() instead of find(). As of 3.0.192, if you assemble a batch of pages with findMany() , and then call a function defined in a page-class definition on one of those pages, the $this variable in that function will have an empty parent property. By contrast, in 3.0.191, the $this variable in that function will have the proper value in its parent property. And also by contrast, in both 3.0.191 and in 3.0.192, if you use find() instead of findMany(), the function will have the proper value in its parent property. So, the bug shows up only in 3.0.192 or later and you’re using findMany() and you’re trying to find any parent-based information from the perspective of $this within a function of a page-class definition. For my own use today, I’m perfectly OK using find() instead of findMany(), though there may come a time when I’m dealing with too many records for that to work gracefully. So I can upgrade beyond 3.0.184! Thanks again to everyone for your help; I’ve learned a lot through this process. If an admin would like to break all this out (it has nothing to do with Ryan’s original post — I meant to reply initially to his announcement of 3.0.192!), I’d be grateful
  12. Oh, bingo — you called it! sam.example.org/:1 Refused to load the script 'https://sam.example.org/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'nonce-MzlhOGMzOWY0OTdkMDIxMmZkZDRiNTE0ZDBiYTg3YzI=' 'strict-dynamic'". Note that 'strict-dynamic' is present, so host-based allowlisting is disabled. Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback. I’m out of my ken here, @adrian. I see that something is set to be more secure than optimal, but I’ve no idea where to make a change. Cloudflare is mentioned — do you think that’s because it’s really where rocket-loader is served from, or because I have Cloudflare guarding my cloud-based development machine too well? Or is that not a fruitful line of inquiry? This of course isn’t the serious problem that I need to resolve, but I’m glad to get these little points of friction worked out too. Thank you!
  13. Well now that’s very strange. I see exactly what I posted here, both in a WebKit browser and also in a Chromium-based browser — both of which have Javascript turned on. I thought perhaps there might be an invisible checkbox, but the pointer doesn’t change when I hover in that area, and clicking does nothing. But it doesn’t really matter for the problem at hand; I won’t worry about this for now. Thanks!
  14. Wow, I don’t see anything like this at all. Here’s the top of my screen: and here’s the bottom: [I’m also unsure as to why my posted images keep being magnified so much larger than everyone else’s. I apologize!]
  15. I’m not sure what you’re suggesting? I’ve backed up, made changes, tested, restored from backups countless times over the past eight weeks on my development installation. Whenever I need to update data in the live site, I’ve restored the development site to the last master release, added my new data, and then cloned everything over to the live site.
  16. No effect. ? BTW, I saw no way to “select all” the tables, so I clicked on each (there are 95) manually to select them all. Is there a better way? My future self thanks you!
  17. I’ve never run across that before! It looked likely, but has no effect.
  18. Ah. Well, my workaround doesn’t work around everything. It turns out that not only is $this->parent() a NullPage, but in fact $this->url and $this->httpURL don’t include the parent’s node of the URL. So, for example, if page “Parent” has a child page “Child”, the child’s URL ought to be https://example.tld/parent/child/, but as of 3.0.192 it’s instead giving me https://example.tld/child/. I could probably work around this too (finding the parent via the workaround I posted this morning, getting its URL, and appending the child’s URL node to it), but I suspect that I’d then just find something else that doesn’t work because my page’s parent isn’t identified. So I’m back to analyzing the problem....
  19. @adrian, thanks for trying. It really seems to be something unique to my development/production setup. Even when I try to re-create my own setup, I can’t re-create the problem! Most vexing....
  20. Well, I’ve revisited all the modules and made sure that even the core modules’ settings are all identical. And I’ve made the config.php file essentially the same. But I cannot reproduce the problem in the purpose-built “Nori” test environment. So to reiterate briefly in one place: on my development server, in page-class files in /classes/ in 3.0.191, $this->parent() properly points to $this’s parent page, and the parent property of $this also properly points to its parent page; upgrading to 3.0.192 causes no problems, except that in page-class files in /classes/, $this->parent() is a NullPage, and the parent property of $this is empty. I have found an inefficient but effective workaround, however — and given that no one else is seeing this problem and that I’ve easily spent 40 hours trying fruitlessly to track it down, I think I’ll just need to say “good enough” and move on: Awkward work-around Rather than refer to $this->parent(), I’ll instead use $this->wire('pages')->findOne("child=$this"). This works just fine, and @ryan’s code is so efficient that I see no appreciable difference in speed. Sometimes you just have to move on....
  21. Thanks for your interest, @kongondo! In fact, I was able right from the get-go to pin it down to the difference between 3.0.191 and 3.0.192; I mentioned 3.0.184 recently, though, because that’s the last master release before things break for me. Here are the 3.0.192 commits on GitHub, which I linked to above. @bernhard, I decided to go all in on your suggestion of a new project: I created a new server (“Ori”) running 3.0.191. There, I created two templates (“Parent” and “Child”), and set them up in their family tabs so that only “Child” could be the child of “Parent” and only “Parent” could be the parent of “Child.” I turned on page classes, and created ParentPage.php and ChildPage.php files in the site/classes/ directory, setting each up as a subclass of Page. I created a public function in each (identify()) which returns a small definition list that includes the template and the ID of $this. I then created a page of template type Parent, and gave it a child of template type Child; in each case, the template calls the page’s identify() function and echoes it into the HTML, and it checks whether its parent record has an identify() function and echoes its results out, too. As expected, when I load the parent page on the front-end, I see that its template is Parent and its ID is 43 — and no information is provided about its parent (which would be the home page, which doesn’t have an identify() function). Also as expected, when I load the child page on the front-end, I see that its template is Child and its ID is 44, and that its parent template is Parent with an ID of 43. So much for the “control” — it worked as expected. So then I cloned that entire “Ori” set-up as “Nori,” which I then upgraded (3.0.191 → 3.0.192), and loaded the same two pages. I had expected to see the same result for the Parent page, but only the Child information for the Child. Unfortunately for me (but probably fortunately for @ryan!), nothing broke in 3.0.192 on Nori: the Child page also (properly!) showed its parent’s information. So then I began installing each of the modules that I’m using one by one on Nori, and testing the results (still in 3.0.192). I have more modules than I thought! But none of them caused my 3.0.192 test to break the way it does to my system IRL. I guess my next step at this point would be to gradually change the config.php file to match my system, with tests after each change. And then, gosh, I guess gradually re-create the whole system until something breaks. I think I‘ll take this evening off before embarking on that tomorrow. I have no idea how I could create a gist to show this, but I‘d be very happy to give any of you access to a copy of my development system where everything works perfectly in 3.0.191 but not in 3.0.192. Please PM me if you‘d be willing; I‘ll treat you to a couple of beers if you can help me make headway on this!
  22. Thank you for replying, @bernhard! I do always run Tracy Debugger [on my development server], though tbh I really haven’t figured out how to use it other than to be aware of the helpful execution time figure which helps me keep my code comparatively lean. This is not called from a hook; rather, it’s a function in a class definition in the /classes/ directory. $this itself as a variable is working fine — referring to the instance of the subclass, which is of course a page. I added the bd commands you listed into one of the class functions attempting to find $parent, and discovered the little orange shopping-cart icon. (This is how Tracy denotes dumps? Interesting.) When loading my site’s home page in 3.0.184 I see 16 dumps, which makes perfect sense: I had added those bd commands to the “Post” page class, and currently eight posts are among the items listed on the home page. So each post dump is followed immediately by a dump of its parent. Though I’ve never seen this layout or used this portion of the tool, it all makes perfect sense and is exactly what I’d expect to see. Now, if I upgrade to 3.0.196 and reload the same page, I again see 16 dumps. Eight of these are the same eight posts — and they look exactly the same. Their parents, however, all look like this: ProcessWire\NullPage #??? id: 0 name: '' parent: '' template: '' where ??? is different in all eight parent records. This number is not the record’s ID — I really don’t know what it represents. It is not the same number that Tracy Debugger reports along with the good-looking parent data in 3.0.184. If I click on the disclosure triangle, there is lots more data — but almost everything is blank or 0 or null. I’m thrilled that I now know a little more about running Tracy Debugger — thank you for that! But I don’t think it’s telling me anything new: $this->parent() is null (or empty or something) instead of $this’s parent. Is there more sleuthing I can do?
  23. I’ve adjusted my code, hoping to find that $person = $this->wire('page')->parent(); would work better than $person = $this->parent(); — but the result is (unsurprisingly) identical: both of these work perfectly in all cases in 3.0.191, but consistently return an empty page whose id = 0 in 3.0.192 and later, no matter what $this’s page class is and no matter what $this->parent()’s page class is.
  24. OK, I’ve returned from business trips and have finally had some time to pursue this further. I made a slight error in my last post here. As of 3.0.192 (and all subsequent versions through 3.0.196, at least), $this->parent() (in the context of page-class PHP files in the “Classes” directory) isn’t actually null; rather, it’s always empty, with an ID of 0. It doesn’t matter what the class of $this is, and it doesn’t matter what class its parent really is within the system. $this->parent() always gives me an empty page with no template and an ID of zero. Somehow, getting $this->parent() was broken with 3.0.192. I can build lots of checks into my code so that I can render a page without errors (and I am, in fact, doing that) — but I still need the original functionality restored. Is there some alternative way I should be referring to the instance’s parent? Or is there some way we can restore the functionality that we had up through 3.0.191? I’d be very happy to help, but I’m utterly unable to pursue this any further alone.
  • Create New...