-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.x]: Entry title formats containing element queries with custom select statement breaks in unexpected ways #13392
Comments
Search for that |
@brandonkelly Sure:
|
Are you sure you’re on 4.4.15? Have you made any changes to For example, this line:
refers to this line in Line 2413 in 273dfd3
|
@brandonkelly Sorry, I tested this before and after the update to 4.4.15, I think I might've copied a stack trace from the earlier version. My bad! I'm still getting the error on 4.4.15, here's the correct stack trace:
|
Thanks! I see what’s going on now. The issue is that the overridden This sort of thing is usually not an issue anymore in Craft 4 due to #8781, but still applies in this case because the Title Format object template doesn’t pull field values in via the magic getter. You can solve it by cloning the category query via clone() from your Title Format template, before modifying it: {clone(course_category).select('title').column()|join(' / ')} |
@brandonkelly Thanks for the explanation! Yeah, cloning is one option, as is the unoptimized query (the overhead doesn't really matter in that context). But shouldn't this be fixed in core, or at least mentioned in the docs? This error is going to be insanely hard to find the cause of if someone encounters it … |
We discussed this today and decided to update |
Craft 4.4.16 is out with that fix. |
@brandonkelly Sounds great, thanks! |
What happened?
Description
I just fixed a very curious issue with the
Title Format
setting for entry types. I had a title format defined like this (course_category
is a categories field):This worked, but was causing curious validation errors when the entry was saved:
Switching to an unoptimized query fixes this:
Not quite sure what's going on here – I'm guessing because of the overwritten query, the
Entry
object will containCategory
objects that are missing some properties? Or something involving the query cache?Maybe this can be fixed by rendering the template format with a copy of the Entry object? Or execute it in a way that won't cause any queries executed inside it to 'leak' or be cached?
If this can't be fixed, this should probably be mentioned in the docs.
Craft CMS version
4.4.15
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
The text was updated successfully, but these errors were encountered: