Version: 3.5.11 Reporter: Matt Johnson —
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 am converting an add-on from it’s EE2 version to EE3, and it uses the channel_form_entry_form_tagdata_start
hook. It appears that the ability to pass the $channel_form_object
variable as reference has been removed. I’m getting this error when attempting to get the variable as a reference variable:
CHANNEL_FORM_ENTRY_FORM_TAGDATA_START() EXPECTED TO BE A REFERENCE, VALUE GIVEN
I followed the error, and found the hook in ee/EllisLab/Addons/channel/libraries/channel_form/Channel_form_lib.php
where it says in a comment:
// -------------------------------------------
// 'channel_form_entry_form_tagdata_start' hook.
// - Developers, if you want to modify the $this object remember
// to use a reference on func call.
// -------------------------------------------
I followed the code, and in ee/legacy/libraries/Extensions.php
on line 245, it is calling the hook like this: call_user_func_array(array($obj, $method), $args)
where $args
needs to be an array of reference variables in order to work.
When I looked into the function in older versions of EE, I found that it used to do exactly this. It looped through the array, and made sure each variable was passed as reference, so a add-on developer could modify it. When I modified the $args
variable, it worked as intended again:
foreach ($args as $k => $v)
{
$args[$k] =& $args[$k];
}
I should also note that I have tested in the most recent versions of PHP 5.6, 7.0 and 7.1 with varying results. If I leave the core untouched, and request the variables as value instead of reference, I am getting mixed results. In PHP 5.6 and 7.0, this does exactly what I would expect: changing the object does not alter the actual channel form data at all. However, when testing in PHP 7.1, I noticed that I could receive the variables as value, not reference, and I could still alter them as reference variables. Either way, adding the foreach loop and requesting the variables as reference fixed the problem in every PHP version.
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); } ```