php - Getting error when trying to edit subpage in Grav
Get the solution ↓↓↓Whenever I try to add or edit a subpage (i.e. a child page of the main page),
I am getting this error:
count(): Parameter must be an array or an object that implements Countable
Offending line is:
<div data-grav-array-type="container"{% if field.value_only %}
data-grav-array-mode="value_only"{% endif %}
{{ value|length <= 1 ? ' class="one-child"' : '' }}>
This is happening in:/grav/templates/forms/fields/array/array.html.twig
.
I'm not familiar enough with Grav to understand the stack and debug it.
Answer
Solution:
It looks like you upgrade to PHP 7.2. PHP changed count() behavior in the following RFC: https://wiki.php.net/rfc/counting_non_countables
Since then, calling count() with a parameter that is a scalar, null, or an object that doesn't implement Countable raises PHP warning like Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d.
Thus, since PHP 7.2 this will be considered as a bug in the code.
Examples:
https://github.com/twigphp/Twig/blob/2.x/lib/Twig/Node/Module.php#L370 https://github.com/twigphp/Twig/blob/2.x/lib/Twig/Extension/Core.php#L1117
You may want to use length() or try to convert your variable to iterable
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: unable to determine current zabbix database version: the table "dbversion" was not found.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.