• Hi,

    I get a Fatal error when going to any Post Edit page like wp-admin/post.php?post=xxxx&action=edit

    Seems to be related to SCF …

    [29-Aug-2025 04:46:20 UTC] PHP Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in /home/u7xxxx/domains/xxxxxx.org/public_html/wp-content/plugins/secure-custom-fields/includes/api/api-helpers.php:2542

    WordPress 6.8.2
    Secure Custom Fields 6.5.7
    PHP 8.2.28

    Any idea ?

    Thank you

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter charlie67p

    (@charlie67p)

    Well, I understood it happens only when trying to edit Posts or CPT’s using a Repeater Field.
    I do not understand : everything was working fine 2 weeks ago. I did not change the SCF settings.
    Can it be related to last SCF updates ? Some changes with Repeater Field ? …

    Plugin Author Carlos Bravo

    (@cbravobernal)

    Hi there!

    Thanks for the report. The api-helpers file has not been touched since a while, so the last version should not be the cause of that fatal. Did you try to downgrade the plugin to 6.5.5?

    https://github.com/WordPress/secure-custom-fields/commits/trunk/includes/api/api-helpers.php

    I could not reproduce the error. Can you please share what fields are you adding to that repeater, are you using any additional option like pagination or something similar?

    Thanks again!

    Hi there,

    This is a conflict issue between SCF and Meta Field Block. In my plugin (Meta Field Block), I change the format of the REST value of fields, so when SCF reformats the REST value rather than formatting the original field value, it causes this error for some multiple value field types like select. Here’s the relevant code in SCF (line 225 in SCF\includes\rest-api\class-acf-rest-api.php):

    foreach ( $field_groups as $field_group ) {
    foreach ( $this->get_fields( $field_group, $object_id ) as $field ) {
    $value = acf_get_value( $post_id, $field );

    if ( $this->embed_links ) {
    $this->embed_links->prepare_links( $post_id, $field );
    }

    // Format the field value according to the request params.
    $format = $request->get_param( 'acf_format' ) ?: acf_get_setting( 'rest_api_format' );
    $value = acf_format_value_for_rest( $value, $post_id, $field, $format );

    // We keep this one for backward compatibility with existing code that expects the field value to be.
    $fields[ $field['name'] ] = $value;
    $fields[ $field['name'] . '_source' ] = array(
    'label' => $field['label'],
    'type' => $field['type'],
    'formatted_value' => acf_format_value( $value, $post_id, $field ),
    );
    }
    }

    I suggest changing it to this:

    foreach ( $field_groups as $field_group ) {
    foreach ( $this->get_fields( $field_group, $object_id ) as $field ) {
    $value = acf_get_value( $post_id, $field );

    if ( $this->embed_links ) {
    $this->embed_links->prepare_links( $post_id, $field );
    }

    // Format the field value according to the request params.
    $format = $request->get_param( 'acf_format' ) ?: acf_get_setting( 'rest_api_format' );
    $rest_value = acf_format_value_for_rest( $value, $post_id, $field, $format );

    // We keep this one for backward compatibility with existing code that expects the field value to be.
    $fields[ $field['name'] ] = $rest_value;
    $fields[ $field['name'] . '_source' ] = array(
    'label' => $field['label'],
    'type' => $field['type'],
    'formatted_value' => acf_format_value( $value, $post_id, $field ),
    );
    }
    }

    The formatted_value property of the {$name}_source key should come from the original value, not the REST value.

    Best, Phi.

    Thread Starter charlie67p

    (@charlie67p)

    Hi @cbravobernal , thank you for answering

    Where can I find the 6.5.5 Zip ?

    The only previous release I have in my folders is 6.4.2 .
    I downgraded and everything was working fine again.

    EDIT : here the full copy of the log (after click on EDIT POST in Admin) :

    WordPress version 6.8.2 Thème actif : MyBlockTheme (version 1.5.0) Extension actuelle : Secure Custom Fields (version 6.5.7) PHP version 8.2.28

    Une erreur de type E_ERROR a été causée dans la ligne 2542 du fichier /home/u733000010/domains/mywebsite.org/public_html/wp-content/plugins/secure-custom-fields/includes/api/api-helpers.php.

    Message d’erreur : Uncaught TypeError: Illegal offset type in isset or empty in /home/u733000010/domains/mywebsite.org/public_html/wp-content/plugins/secure-custom-fields/includes/api/api-helpers.php:2542

    Stack trace:
    0 /home/u733000010/domains/mywebsite.org/public_html/wp-content/plugins/secure-custom-fields/includes/fields/class-acf-field-select.php(660): acf_maybe_get()
    1 /home/u733000010/domains/mywebsite.org/public_html/wp-content/plugins/secure-custom-fields/includes/fields/class-acf-field-select.php(636): acf_field_select->format_value_single()
    2 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/class-wp-hook.php(324): acf_field_select->format_value()
    3 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/plugin.php(256): WP_Hook->apply_filters()
    4 /home/u733000010/domains/mywebsite.org/public_html/wp-content/plugins/secure-custom-fields/includes/acf-hook-functions.php(110): apply_filters_ref_array()
    5 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/class-wp-hook.php(324): _acf_apply_hook_variations()
    6 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters()
    7 /home/u733000010/domains/mywebsite.org/public_html/wp-content/plugins/secure-custom-fields/includes/acf-value-functions.php(191): apply_filters()
    8 /home/u733000010/domains/mywebsite.org/public_html/wp-content/plugins/secure-custom-fields/includes/rest-api/class-acf-rest-api.php(242): acf_format_value()
    9 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/rest-api/endpoints/class-wp-rest-controller.php(439): ACF_Rest_Api->load_fields()
    10 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(2098): WP_REST_Controller->add_additional_fields_to_object()
    11 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(655): WP_REST_Posts_Controller->prepare_item_for_response()
    12 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/rest-api/class-wp-rest-server.php(1292): WP_REST_Posts_Controller->get_item()
    13 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/rest-api/class-wp-rest-server.php(1125): WP_REST_Server->respond_to_request()
    14 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/rest-api.php(586): WP_REST_Server->dispatch()
    15 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/rest-api.php(2973): rest_do_request()
    16 [internal function]: rest_preload_api_request()
    17 /home/u733000010/domains/mywebsite.org/public_html/wp-includes/block-editor.php(754): array_reduce()
    18 /home/u733000010/domains/mywebsite.org/public_html/wp-admin/edit-form-blocks.php(114): block_editor_rest_api_preload()
    19 /home/u733000010/domains/mywebsite.org/public_html/wp-admin/post.php(187): require('/home/u73322901…')
    20 {main}
    thrown

    • This reply was modified 3 months, 1 week ago by charlie67p.
    Plugin Author Carlos Bravo

    (@cbravobernal)

    Hi @charlie67p,

    I think you’ll need version 6.5.1 or earlier; otherwise, the issue will still occur. Starting with 6.5.2, SCF added code to connect custom fields through the UI, which is where it conflicts with Meta Field Block.

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.