• Resolved janrenn

    (@janrenn)


    From ACFE 0.8.9.1 the acfe_code_editor field saves return_format (when none of HTML Entities nor New Lines to <br> checked) as empty string, which causes PHP fatal error in method acfe_field_code_editor->format_value where in_array('htmlentities', $field['return_format']) receives the string as second parameter.

        /**
         * format_value
         *
         * @param $value
         * @param $post_id
         * @param $field
         *
         * @return string
         */
        function format_value($value, $post_id, $field){
            
            if(in_array('htmlentities', $field['return_format'])){
                $value = htmlentities($value);
            }
        
            if(in_array('nl2br', $field['return_format'])){
                $value = nl2br($value);
            }
            
            return $value;
            
        }

    Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in www\wp-content\plugins\acf-extended\includes\fields\field-code-editor.php on line 218.

    • This topic was modified 2 years, 1 month ago by janrenn.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback and the detailed report.

    In fact, I was able to reproduce the issue. I’m adding a fix in the upcoming update. It should come out soon.

    In the meantime, you can fix it by yourself by adding this code in your theme’s functions.php file:

    // acfe 0.8.9.1 fix return format in code editor
    add_filter('acf/load_field/type=acfe_code_editor', 'my_code_editor_fix_return_format');
    function my_code_editor_fix_return_format($field){
        
        // force array
        if(isset($field['return_format'])){
            $field['return_format'] = acf_get_array($field['return_format']);
        }
        
        // return field
        return $field;
        
    }

    Sorry for the inconvenience.

    Have a nice day!

    Regards.

    Thread Starter janrenn

    (@janrenn)

    Thanks a lot!

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Just a heads up to let you know that this issue has been fixed in the latest 0.8.9.2 patch. Please ugrade your version.

    Note that you can remove the hotfix I provided in my previous answer.

    Thanks again for the report.

    Have a nice day!

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[BUG] v0.8.9.1: format_value of acfe_field_code_editor causes PHP fatal error’ is closed to new replies.