Version: 3.4.3 Reporter: Zeke Aasman —
This is an archived bug report. If you are experiencing a similar issue, upgrade to the latest release and if that does not solve the problem, submit a new bug report
I have a module function that iterates over a group of channel entries making some value changes. I’m using the ChannelEntry model to interface with the data, but I run into problems because of how the model is saving default fields.
At line 651 of EllisLab\ExpressionEngine\Model\Channel\ChannelEntry
, the model saves it’s default fields within the static variable $default_fields
in such a way that the variable is only set once (ie cached). The problem is that it also saves module tab fields, which include not just default values but the specific entry’s data as well. So, in my case, every subsequent instance of ChannelEntry references tab values from the first entry, and on ChannelEntry::save I end up overwriting any/all module tab values to that of the first instance.
The fix is simple: move the module tab block (lines 829 - 837) out of and below the if statement, effectively stopping those values from being cached. I’m hoping you agree and can incorporate this (or another fix) into a future release.
Thanks! Zeke
Fix, lines 829 - 838:
$module_tabs = $this->getTabFields();
foreach ($module_tabs as $tab_id => $fields)
{
foreach ($fields as $key => $field)
{
$default_fields[$tab_id . '__' . $key] = $field;
}
}
}
Becomes:
}
$module_tabs = $this->getTabFields();
foreach ($module_tabs as $tab_id => $fields)
{
foreach ($fields as $key => $field)
{
$default_fields[$tab_id . '__' . $key] = $field;
}
}
ExpressionEngine implements Markdown Extra and BBCode. Please see the Markdown Extra docs and the BBCode Wikipedia article for a full reference.
**bold**
, __bold__
, *italics*
, _italics_
, ~strike/del~
, `code()`
bold, italics, strike/del, code()
Link: [link title](https://example.com)
Image: ![alt text](https://example.com/image.jpg)
[blockquote]...[/blockquote]
, [quote]...[/quote]
, and Markdown style:
> Some quoted text. > > This is all one quote.
[code]...[/code]
, and you can also specify the language for syntax highlighting, [code=php]...[/code]
GitHub flavored Markdown code fences are also supported:
``` public function decoderRing($str) { return str_rot13($str); } ```