Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
You are experiencing increased server side response times after updating WPML plugins, particularly noticing a spike in time spent on the

acf/load_field

hook.
Solution:
We recommend modifying the ACFML plugin to improve performance. Here's a step-by-step guide:
1. Navigate to

\ACFML\Helper\Fields::iterate

in

\wp-content\plugins\acfml\classes\Helper\Fields.php

.
2. Change the code from:

public static function iterate( $fields, $transformField, $transformLayout, $fieldBasePattern = '' ) {<br />    foreach ( $fields as &$field ) {

To:

public static function iterate( $fields, $transformField, $transformLayout, $fieldBasePattern = '' ) {<br />    foreach ( $fields as &$field ) {<br />        if ($field["value"] == NULL ){<br />            continue;<br />        }

NOTE: Always ensure you have a recent and working backup before making any changes.

If this solution does not resolve your issue or seems irrelevant due to updates or different circumstances, please check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. If needed, do not hesitate to open a new support ticket at WPML support forum for further assistance.

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 5 replies, has 2 voices.

Last updated by Bobby 7 months, 3 weeks ago.

Assisted by: Bobby.

Author Posts
June 4, 2024 at 5:51 pm #15704000

peterL-60

Background of the issue:
I am trying to maintain server side site performance while using ACF + WPML.

We have previously had performance issues with the ACFML companion plugin, documented here:
https://wpml.org/forums/topic/performance-issues-with-acfml-string-translation/
https://wpml.org/forums/topic/performance-issues-with-acfml-string-translation-again/

In the past we were able to manually edit the plugin files to work around the issue while we waited for an official resolution. However the old workaround is no longer valid.

Symptoms:
Average server side response time in the two weeks before our most recent updates of the WPML plugins was 1117.6 ms. After updating the WPML plugins, the average server side response time increased to 1956.31 ms.

Looking at the top most time consuming WordPress hooks before and after this update. There is a huge spike in the amount of time spent on the acf/load_field hook. It used to account for 12.58% of call time, but after the update it accounts for 56.25%. It went from around 90 million calls over 2 weeks, to over 61 billion calls. (see screenshots)

Questions:
What changes can I make to get us back to a more sustainable performance level with these plugins.

June 4, 2024 at 7:11 pm #15704118

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi there,

Please try this workaround and let me know your results:

go to \ACFML\Helper\Fields::iterate in \wp-content\plugins\acfml\classes\Helper\Fields.php

Change:

public static function iterate( $fields, $transformField, $transformLayout, $fieldBasePattern = '' ) {
		foreach ( $fields as &$field ) {

To:

public static function iterate( $fields, $transformField, $transformLayout, $fieldBasePattern = '' ) {
		foreach ( $fields as &$field ) {
			if ($field["value"] == NULL ){
							continue;
			}

NOTE: Always have a recent and working backup before making any changes recommended by our team or a 3rd party

June 4, 2024 at 7:24 pm #15704140

peterL-60

First of all, thank you for the quick response!

I've gone ahead and implemented the potential workaround outlined above. It will take a little time before there is enough performance monitoring data accumulated to know if it made a difference or not. I will be keeping an eye on the monitors over the next 24 hours and I'll report back here with what I find.

June 4, 2024 at 7:31 pm #15704146

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

You are welcome! I worked on this before with you so I do remember this case 🙂

Let me know your results once ready.

June 5, 2024 at 6:19 pm #15708505

peterL-60

Hey Bobby,

That workaround is doing good things for us. It looks like performance is returning to approximately previous values since we've enabled it. (screenshot attached)

The next big thing I'd really love your support on is moving this from a workaround we are manually applying, to something more permanent. We've been manually apply one fix or another to every ACFML update since March of 2023 to keep performance normal. Is this fix something that will be applied to the ACFML plugin for all users?

Screenshot 2024-06-05 at 2.17.10 PM.png
June 6, 2024 at 6:12 pm #15713045

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

I'm glad to hear that it helped!

This is in our development cycle to do and will be implemented in a future version of ACFML.

I can't share an exact timeline yet but it will be included in future releases.

June 6, 2024 at 8:45 pm #15713291

peterL-60

I am going to close this for now, our issue is at least temporarily resolved pending a further future update to ACFML that will more permanently fix this. Thank you.