Home›Support›English Support›[Resolved] Save origin language give error when i'm having true/false fields
[Resolved] Save origin language give error when i'm having true/false fields
This thread is resolved. Here is a description of the problem and solution.
Problem: If you're experiencing a 'Uncaught TypeError' when saving a page in the original language with ACFML version 2.1.0 or above, and you have true/false fields or Google location fields on it, you're not alone. Solution: We recommend trying the following steps: 1. Turn off the option 'Keep repeater and flexible sub-fields in the same order as the default language' and update the post. 2. If the error persists, edit the
\plugins\acfml\classes\Helper\HashCalculator.php
file. On line 25, replace:
return self::hashArray( $value );
with:
return self::hashArray( (array) $value );
Please ensure you backup your database before making any changes. This should resolve the error.
Please note that this solution might be irrelevant due to being outdated or not applicable to your case. If the issue persists, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please don't hesitate to open a new support ticket in the WPML support forum.
0% of people find this useful.
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.
When i'm saving a page in the original language i'm getting an error from Version 2.1.0 or above and having true/fale fields or Google location fields on it.
The error is 'Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /data/sites/web/gaatbijnaonline02nl/subsites/epona.gaatbijnaonline.nl/wp-content/plugins/acfml/classes/Helper/HashCalculator.php:65 Stack trace: #0' See also the screenshot.
When i downgrade to ACFML v 2.0.5 it works perfectly
I'm sorry to hear that you encountered some trouble with this.
Unfortunately, I haven't been able to replicate the problem on my end.
Would you mind helping me out with this? I've included a link to the staging site in the following message so that you can activate and install anything you need if missing. Thank you!
I did the installation and added two pages.
Home and Home with check
For both pages i made a translation to dutch
On the page home i have a checkbox unchecked and i can add extra partials to that page. On the page 'Home with check' i have checked the checkbox and than i cant edit the page anymore. After deleting the dutch translation is possible to edit the page again.
- Edit page 'Home with check'
- Add new line underneath 'Pageheader' -> 'Intro'
- Add some text in the fields
- Update the page
- Refresh the page
- The Intro blok is gone
- This has to do with the checked/true value within the 'Pageheader' and if there is a second language for this page
If you do exactly the same with the page 'Home' (the checkbox is false) it works fine
Could you please try the following workaround on your site and let me know?
Turn off "Keep repeater and flexible sub-fields in the same order as the default language." and update the post. If this is not the option then edit \plugins\acfml\classes\Helper\HashCalculator.php line 25 replace
return self::hashArray( $value );
with
return self::hashArray( (array) $value );
Please backup your database before making any changes. This should resolve the error you reported.
Turn off "Keep repeater and flexible sub-fields in the same order as the default language." does the trick and then i get no error. But i want to keep the same order for all languages.
So maybe you can take this to the develop team.
But for now can i set this option global? So i don't have to do this for all pages
We have already reported it to our development team. If you do not want to turn it off, you can also apply the workaround by replacing the line of the code I shared above. This should do the trick as well.
You can enable enable the debug.log. You can do this by adding a few lines to the site’s wp-config.php file. With the error log enabled, you will see what the actual problem is.
To enable it, open your wp-config.php file and look for define(‘WP_DEBUG’, false);. Change it to:
define('WP_DEBUG', true);
In order to enable the error logging to a file on the server you need to add yet one more similar line:
define( 'WP_DEBUG_LOG', true );
In this case, the errors will be saved to a debug.log log file inside the /wp-content/directory.
I'm seeing the exact same error, caused by true/false fields. The solution posted by @Andrey to change the line 25 of HashCalculator.php causes a different line to fail, and doesn't seem like a solution. This is what worked instead:
But the same problem is also with location field (lat, lon) So you solution maybe is the fix for true / false fields. I will try it tomorrow. Otherwise i hope acfml will come with a bugfix soon