FluidTYPO3 / vhs

TYPO3 extension VHS: Fluid ViewHelpers
https://fluidtypo3.org
Other
190 stars 229 forks source link

<v:asset.style/> makes the page crash : "count(): Parameter must be an array" #1827

Open olinox14 opened 1 year ago

olinox14 commented 1 year ago

I uses the v:asset.style viewhelper to include my assets to my page, and this was working very well until I updated VHS from 6.1.2 => 6.1.3 Now, this viewhelper makes the page crash, and I got this error :

TYPO3\CMS\Core\Error\Exception

PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/typo3/public/typo3conf/ext/vhs/Classes/Service/AssetService.php line 217

To reproduce, simply add these lines to your page :

<v:asset.style name="fontAwesome"
           path="path/to/css/all.min.css"/>

Typo3 10.4.34 Php 7.4.11

NamelessCoder commented 11 months ago

I am not able to reproduce this problem.

I am even not sure I understand how this would be possible exclusively by using v:asset.style:

The error in question may be caused by something else - for example, another asset defined in TypoScript which has incorrectly defined the variables as something other than an array, e.g. variables = some string.

Either that, or I'm missing some additional context to help me reproduce this problem...

windups76 commented 1 month ago

I have a similar problem (Typo3 11.5.37, VHS 6.1.3, PHP 8.2.18)

Javascript file is integrated via . To correct the property "moveable" I wanted to change the assets settings via TypoScript plugin.tx_vhs.settings.asset.NAME_X {moveable = 1}.

The error is thrown under AssetService->placeAssetsInHeaderAndFooter. $asset instanceof AssetInterface is apparently not true. On the next line of code, $variables = $asset['variables'] ?? [] set to false. Another line later, the question count($variables) is asked. Of course this no longer works in PHP8 without Error Message. The problem persists until version VHS 7.0.3.

P.S. $asset['variables'] is declared as an optional property. P.S. Assets settings via TypoScript plugin.tx_vhs.settings.asset.NAME_X should reproduce this Problem.