Robin S Posted January 16, 2022 Share Posted January 16, 2022 Hi @adrian, I think this probably isn't a Tracy issue as such but I thought you might have some insight on it... If I edit a field's settings (in this case the headline field) and set it to Autojoin then when I get a page whose template has that field then I can see the field value loaded on the Page object. But if I don't set Autojoin in the field settings and instead I set the field to join for a specific find() operation then I don't see the field value loaded on the Page object. (I'm using $pages->get() here but I think it is the same behind the scenes and I also tried $pages->find() and found the same issue). Or the older way: If I request the field value before I dump the Page object then it is loaded. I'm puzzled about why this is. Surely if the field value is joined during the find() then it must be stored somewhere on the Page object? Do you know if PW is storing these joined values somewhere that is invisible to Tracy? Or is this maybe a sign that there's a core bug and the joined fields are not actually being preloaded as expected? 1 Link to comment Share on other sites More sharing options...
adrian Posted January 17, 2022 Share Posted January 17, 2022 Hi @Robin S - not completely sure, but here's a little more insight: This version shows that it is theoretically joining the "summary" field, and if I look at the Selector Queries section of the Debug Mode panel, I see: which shows that it is being joined as expected. Now if I do this same find operation in a template file, I get: Sorry for the rambling, but I am posting as I try new things :) I've noticed that if I run this via the Tracy console it actually does work as expected depending on what page you are on. It seems like it works anywhere on the frontend and anywhere on the backend, except when editing a page (which is what I was doing for my first test above). For example, you can see it working when viewing the page tree. Actually, it even seems to work when editing some page, but not all. What page / view are you on when testing and does that impact what you see? 1 Link to comment Share on other sites More sharing options...
Robin S Posted January 17, 2022 Author Share Posted January 17, 2022 10 minutes ago, adrian said: I've noticed that if I run this via the Tracy console it actually does work as expected depending on what page you are on. It seems like it works anywhere on the frontend and anywhere on the backend, except when editing a page (which is what I was doing for my first test above). You nailed it! I was trying that code from the Tracy Console while viewing the page in Page Edit, and so must have been getting the cached version of the page that was already loaded. If I use the Console on a different page or preceed the code with $pages->uncacheAll() then it works as expected. Thanks! 1 Link to comment Share on other sites More sharing options...
adrian Posted January 17, 2022 Share Posted January 17, 2022 Turns out with your "get" version, you can also use getFresh() and it will work. Although I actually think this is kind of a bug in the Console panel. What do you think about me replacing line 73 of CodeProcessor.php with: $setVars = '$page = $pages->get('.$page->id.'); $pages->uncacheAll();'; 1 Link to comment Share on other sites More sharing options...
Robin S Posted January 17, 2022 Author Share Posted January 17, 2022 58 minutes ago, adrian said: What do you think about me replacing line 73 of CodeProcessor.php with: $setVars = '$page = $pages->get('.$page->id.'); $pages->uncacheAll();'; Sounds good to me, because although the cached pages are expected when you know how PW goes to the cache first before loading pages from the DB this might not be common knowledge and the expectation is probably that the Console is a "blank slate". 1 Link to comment Share on other sites More sharing options...
adrian Posted January 17, 2022 Share Posted January 17, 2022 I've added it to the latest version. Thanks for noticing this - I think there might be other things that could have been confusing as it was, so I think this is a good improvement. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now