Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 0 replies, has 0 voices.

Last updated by Pieter 2 hours, 38 minutes ago.

Assisted by: Lucas Vidal de Andrade.

Author Posts
January 9, 2025 at 12:21 pm

Pieter

Background of the issue:
I am trying to save my widgets on the page hidden link.

I've previously opened this ticket:
https://wpml.org/forums/topic/saving-widgets-shows-a-critical-error-message/

But the solution i was given is not acceptable, since it was to remove all my ACF blocks from the widgets.
The issue lies in the ACFML plugin and of course if i remove all ACF blocks it will work, but that's not what i want.

Symptoms:
I expected to see a saved widgets message, but instead, I got a critical error message.

Questions:
Why am I seeing a critical error message when saving widgets?
How can I resolve the critical error when saving widgets?

January 9, 2025 at 12:39 pm
January 9, 2025 at 8:17 pm #16579787

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

I'm checking your issue with our devs and will get back to you as soon as I have new information. Thank you.

January 13, 2025 at 5:57 pm #16590271

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Pieter,

I got feedback from our devs. Thank you for waiting.

The problem is a specific widget - "About us" which passes an ACF field which has multiple rows:

 array (
    'content' => '<!-- wp:acf/about-us {"name":"acf/about-us","data":{"field_6153243e2ccbc":"\u003cstrong\u003eBrightAnalytics\u003c/strong\u003e, geconsolideerde management rapportage\r\n\r\nIntuïtief, betrouwbaar en snel. Neem goede beslissingen met up-to-date financiële en operationele data. 02","field_615324502ccbd":{"row-0":{"field_615324562ccbe":{"title":"Contacteer ons","url":"<em><u>hidden link</u></em>","target":"","rel":""}},"row-1":{"field_615324562ccbe":{"title":"Vraag een demo aan","url":"<em><u>hidden link</u></em>","target":"","rel":""}}}},"align":"","mode":"auto","wpml_language":"nl-nl"} /-->',
    'title' => false,
  )

our code in \WPML_Register_String_Filter::save_string fails because we do 'strlen' and that does not allow an array, but strings only values.

The problem is in : wp-content/plugins/acfml/classes/class-wpml-acf-blocks.php in \WPML_ACF_Blocks::add_block_data_attribute_strings

Please change the method above to:

	public function add_block_data_attribute_strings( array $strings, WP_Block_Parser_Block $block ) {

		if ( $this->is_acf_block( $block ) && isset( $block->attrs['data'] ) ) {

			if ( ! is_array( $block->attrs['data'] ) ) {
				$block->attrs['data'] = array( $block->attrs['data'] );
			}

			foreach ( $block->attrs['data'] as $field_name => $text ) {

				if ( $this->must_skip( $field_name, $text ) ) {
					continue;
				}

				$type = $this->get_text_type( $text );

				if ( 'array' === $type ) {
					foreach ( $text as $inner_field_name => $inner_text ) {
						$inner_type = $this->get_text_type( $inner_text );
						if ( 'array' === $inner_type ) {
							foreach ( $inner_text as $inner_field_name_2nd => $inner_text_2nd ) {
								$inner_type2 = $this->get_text_type( $inner_text_2nd );
								if ( 'array' === $inner_type2 ) {
									foreach ( $inner_text_2nd as $inner_field_name_3rd => $inner_text_3rd ) {
										$inner_type3 = $this->get_text_type( $inner_text_3rd );
										$strings[] = $this->add_string( $block, $inner_text_3rd, $field_name . '/' . $inner_field_name_3rd, $inner_type3 );
									}
								}
							}
						} else {
							$strings[] = $this->add_string( $block, $inner_text, $field_name . '/' . $inner_field_name, $inner_type );
						}
					}
				} else {
					$strings[] = $this->add_string( $block, $text, $field_name, $type );
				}
			}
		}

		return $strings;
	}

I tested that in the staging environment you sent and I was able to save changes to widgets with no issues. Please implement the same solution on your website, after backing it up and let me know if that solves the issue.

January 14, 2025 at 2:31 pm #16593445

Pieter

This has fixed the issue, should we expect this fix to be applied on next ACFML update?