-
Notifications
You must be signed in to change notification settings - Fork 118
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
Calling the ChannelEntry model within a ft file while editing an entry causes havoc #2117
Comments
Any chance you happen to know if this came up in a specific version or anything along those lines? |
I don't have specifics. I just know that I'm pretty confident this wasn't an issue when I first created at the add-on, then recently it was very easy to replicate. I upgraded to 6.3.4 just a couple weeks ago. I don't recall the version I had before 6.3.4, but I might have skipped a few versions. I have not gotten around to trying to replicate this in a fresh EE install either. |
Solid, thank you! Was it EE 6 before the upgrade to 6.3.4 though? |
I tested this in a separate EE environment in 6.3.4 with the following code. If I'm editing entry #80678, the second var_dump has null values for all the keys. If I choose another random entry id, such as #80682, as the parameter in the get() function while still viewing #80678, the second var_dump is identical to the first. So by calling ChannelEntry model with the same ID as the currently viewed entry, seems to cause the problem.
|
I tried the same thing in a 6.2.2 version of the same environment, and the issue didn't happen. So something changed between 6.2.2 and 6.3.4 to introduce this behavior. |
In my Advanced Categories field I need to figure out what categories are assigned to the current channel, so I end up making this call within an ft file:
$entry = ee('Model')->get('ChannelEntry', $entryId)->first();
but in doing so, it really messes up the current context of
$this
, as it in nullifies basically everything if I try to reference something like$this->content_id
- it's just null. I'm having to capture relevant properties from the ft file in an array, make the ChannelEntry model call, then reset the properties on$this
just so it would work.I don't know what the root issue is here, probably something deep in the Model classes, but it would be nicer if the ft file actually knew what entry it was being loaded in, and better yet, have a reference to the current channel. For example, these would be a really helpful property to have in ft files:
For full context, here is some code from my ft file:
The text was updated successfully, but these errors were encountered: