gantry5 icon indicating copy to clipboard operation
gantry5 copied to clipboard

Error: During inheritance of Countable: Uncaught Whoops\Exception\ErrorException: Return type of Twig\Node\Node::count() should either be compatible with Countable::count()

Open csbalazs opened this issue 2 years ago • 8 comments

  1. I installed clean Joomla 4.2.3 under Wampserver (3.2.9), PHP 8.1.11
  2. I installed latest CI build (Gantry 5.5.16-dev-8885f9f4e) and Helium template (5.5.16-dev-8885f9f4e)
  3. I set default template to Helium, and got the following error (under Error Reporting of Joomla!: System Default):

Error: During inheritance of Countable: Uncaught Whoops\Exception\ErrorException: Return type of Twig\Node\Node::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\wamp64\www\joomla4\libraries\gantry5\compat\vendor\twig\twig\src\Node\Node.php:213 Stack trace: # 0 C:\wamp64\www\joomla4\libraries\gantry5\src\classes\Gantry\Component\Whoops\SystemFacade.php(119): Whoops\Run->handleError(8192, 'Return type of ...', 'C:\wamp64\www\j...', 213) # 1 C:\wamp64\www\joomla4\libraries\gantry5\compat\vendor\twig\twig\src\Node\Node.php(23): Gantry\Component\Whoops\SystemFacade->handleError(8192, 'Return type of ...', 'C:\wamp64\www\j...', 213) # 2 C:\wamp64\www\joomla4\libraries\vendor\composer\ClassLoader.php(571): include('C:\wamp64\www\j...') # 3

Helium template works under PHP version 8.0.13.

image

csbalazs avatar Oct 18 '22 10:10 csbalazs

I am getting this same error with two sites, one each running Hydrogen 5.5.14 and Helium 5.5.14 on Joomla! 4.2.5. I have one other site running the same version of Helium 5.5.15 that does NOT do this. So I upgraded the other two sites to 5.5.15 and it did not resolve this issue. But upgrading the Gantry package to 5.5.15 DID.

bascherz avatar Dec 03 '22 21:12 bascherz

After upgrading to Gantry 5.5.15 on all my sites, I can no longer use the administrator menu layout manager. That's kind of a big deal, though nowhere nearly as bad as the front end fatal errors. I get this error for every menu on all of my sites using Gantry 5.5.15.

image

bascherz avatar Dec 18 '22 18:12 bascherz

@bascherz since this is a new problem, please open a different issue for this so it can be properly tracked.

N8Solutions avatar Dec 18 '22 18:12 N8Solutions

It seems the issue has been reported elsewhere (https://github.com/gantry/gantry5/issues/3073), but similar to my posting is intermixed with other issues and this part seems to be getting overlooked/ignored.

I am happy to create a new issue for it, though.

bascherz avatar Dec 18 '22 18:12 bascherz

I would just comment on the other one rather than open a new issue. P.S. I'm just a volunteer/user like yourself but try to help out when I can.

N8Solutions avatar Dec 18 '22 18:12 N8Solutions

Already created a new issue (https://github.com/gantry/gantry5/issues/3103). I really like how this forum ties all these issues together when they are cited by link reference.

bascherz avatar Dec 18 '22 18:12 bascherz

I checked the source code and the Twig version (v1) used by Gantry is no longer supported under PHP 8.1. Temporary solution, download the version v2 of Twig and replace the version v1:

  1. Go to https://github.com/twigphp/Twig/tree/2.x
  2. Click the (green) Code button, then the Download ZIP link
  3. Go to \libraries\gantry5\compat\vendor\twig\twig and rename or delete the last twig folder
  4. Extract the contents of the downloaded ZIP file to the \libraries\gantry5\compat\vendor\twig\twig folder
  5. After that, the page will also work under the Error Reporting of Joomla!: System Default setting

csbalazs avatar Jan 30 '23 23:01 csbalazs

The solution suggested by csbalazs solved the problem for me. Bei mir hat der Lösungsvorschlag von csbalazs das Problem gelöst.

galvani66 avatar Nov 22 '23 10:11 galvani66