Support » Plugin: Advanced Custom Fields: Typography Field » [Warning] PHP warning when no fields are defined for a post

  • Resolved jolifanto

    (@jolifanto)


    Hey,

    First of all great plugin, thank you!

    One thing i noticed while using the plugin which you may want to fix:

    array_merge_recursive in acft\includes\functions.php on line 97 produces a warning as its arguments may not be arrays if no fields are defined for a specific post or no option fields are present. An easy fix would be to exchange lines 91 and 92

    $all_post_fields = get_fields($post->ID, false);
    $all_option_fields = get_fields('option', false);
    

    with

    $all_post_fields = get_fields($post->ID, false) ?: array();
    $all_option_fields = get_fields('option', false) ?: array();
    
    • This topic was modified 1 year, 3 months ago by jolifanto.
    • This topic was modified 1 year, 3 months ago by jolifanto.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mujahid Ishtiaq

    (@mujahid158)

    Thank you for pointing out this bug @jolifanto . This will be patched up in the next release.

    ProServ

    (@proserv19)

    I’ve a same error on line 88

    Warning: array_merge_recursive(): Expected parameter 1 to be an array, bool given in /wp-content/plugins/acf-typography-field/includes/functions.php on line 88

    This is line 88
    $all_fields = array_merge_recursive( $all_post_fields, $all_option_fields );

    @jolifanto give a good solution. Tried this one, it’s work fine.

    Plugin Author Mujahid Ishtiaq

    (@mujahid158)

    @jolifanto @proserv19
    This is patched in v3.2.0. Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Warning] PHP warning when no fields are defined for a post’ is closed to new replies.