Skip Navigation

[Resolved] count(): Parameter must be an array or an object that implements Countable

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

Problem:

Get some PHP errors when edit a layout:

https://toolset.com/forums/topic/count-parameter-must-be-an-array-or-an-object-that-implements-countable/#post-1126412

Solution:

This problem only exists in that one french page. you can try to create a new page to replace it, for example:

https://toolset.com/forums/topic/count-parameter-must-be-an-array-or-an-object-that-implements-countable/#post-1128082

Relevant Documentation:

This support ticket is created 6 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 3 voices.

Last updated by chrisL-13 6 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1126412
image002.jpg

I am trying to:
Edit a page using the layouts editor

Link to a page where the issue can be seen:
hidden link

I expected to see:
The layout editor screen where I can choose which block of content to edit.

Instead, I got:
Warning: count(): Parameter must be an array or an object that implements Countable in [path]/wp-content/plugins/layouts/inc/gui/editor/editor.php on line 910

#1126814

I see these errors when I try to edit the Content Layout for "Triangle Rose":

Warning: count(): Parameter must be an array or an object that implements Countable in .../plugins/layouts/inc/gui/editor/editor.php on line 910

Warning: Cannot modify header information - headers already sent by (output started at .../plugins/layouts/inc/gui/editor/editor.php:910) in .../wp-includes/option.php on line 919

Warning: Cannot modify header information - headers already sent by (output started at .../plugins/layouts/inc/gui/editor/editor.php:910) in .../wp-includes/option.php on line 920

I checked that line of code locally and I receive an empty array, but it's an array, hence the code does not throw the error here.

I cannot see the same error on your site either, if I repeat the steps when in the native default English language, or edit a Template Layout.

It seems to happen only if you try to edit the content layout from within the translated version of the post, and that is not suggested, as you would translate layouts like this, instead:
https://toolset.com/documentation/translating-sites-built-with-toolset/translating-layouts/
I do see that you follow a workflow that we do as well document, but as mentioned, it's not recommended:
https://toolset.com/documentation/translating-sites-built-with-toolset/translating-layouts/#editing-the-page-layout-for-other-languages

Now, I tried to replicate that scenario locally, but cannot see the error either with or without translating the content like this.

Could you test this with no other plugins but Toolset and WPML, and a native Theme?
I would recommend these tests on a staging site.
If the issue persists, please send me a copy of that site, if possible
https://toolset.com/faq/provide-supporters-copy-site/
If the issue's solved, please let me know what plugin's causing it (or theme).

#1127795
#1128082

Hello,

I can see the same problem with your website database dump file in my localhot, but it seems this problem only exists in that french page "Triangle Rose".

If it is, you can try to create a new page to replace it, for example:
1) Dashboard-> WPML-> Settings,
section "How to translate posts and pages" choose option "Create translations manually"

2) Edit the problem French page "Triangle Rose", in section "Language", option "This is a translation of ", choose "none" and save. it will disconnect it with the English version page

3) Edit the English version page "The Pink Triangle", and add a new French translation, and test again.

#1128232

Found a work-around but I fear the problem will recur.