Undeclared arguments passed to ViewHelper


I have created a custom image view helper which works as intended in Development mode. When I switch the application to Production, the image won’t render and an error is logged to Data/Logs/Exceptions “Exception in line 196 of …/Packages/Libraries/typo3fluid/fluid/src/Core/Parser/SyntaxTree/ViewHelperNode.php: Undeclared arguments passed to ViewHelper …\ViewHelpers\ResponsiveImageViewHelper: image, width, maximumWidth, height, maximumHeight, allowUpScaling, allowCropping, srcsetWidths”

I have traced the bug to the method Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper::getRenderMethodArgumentDefinitions. When the context is set to Development an array is returned with all arguments from the render method. In production the array is empty.

If I remove the flow annotation (@Flow\CompileStatic) from getRenderMethodArgumentDefinitions the view helper works as expected in Production. My first guess would be that the Framework is right and I have missed something, but I’m having a hard time figuring out what that could be.

Any tips are much appreciated. Thanks,

Neos v3.0.0
Neos.Flow v4.0.0
Neos.FluidAdaptor v4.0.0

Did you re-compile your production environment? Also could there be any reason your ViewHelper doesn’t get proxied? Eg. Flow\Proxy(false) annotation or package is not a Flow/Neos type package?

Thanks for the super fast response.

After each change I do “export FLOW_CONTEXT=Production && ./flow neos.flow:cache:flush”, sometimes with an additional warmup. Is there another command I need to execute?

No additional annotations (basically a copy of Neos.Media/ImageViewHelper with some different arguments, updated the namespace) and the viewhelper is part of my site package, which shows up in the backend (neos/administration/packages).

This is really strange. To give you an idea what happens with the CompileStatic:

For development the method (that fetches the render method arguments) is run every time and calls the ReflectionService. In production we call this method once during compile time and store the resulting array hardcoded in the compiled proxy class, so a call to that method will instantly return the array. Now the question is, why is (apparently) your VH not correctly proxied? It’s hard to say, the package type seems to be correct. And flushing these caches should be enough. Can you share the VH code maybe there is something in there…

You can see the viewhelper at: https://jsfi.io/share/ResponsiveImageViewHelper.php.txt

I tested again, dumping $this->argumentDefinitions after the foreach in AbstractViewHelper#registerRenderMethodArguments, with the only difference being the @Flow\CompileStatic annotation.

With the annotation I get only two arguments (additionalAttributes, data), without the annotation the 10 render parameters are returned too (so 12 arguments).

Hey @martinsachse,

this sounds like a strange issue indeed. Can you post your “composer.json” of your package? It’s a long shot, but maybe the package type is somehow messed up…

All the best,

Hi @sebastian,

I have uploaded the file to https://jsfi.io/share/composer.json.

The view helper is part of the site package which I created during setup. I don’t notice any other issues.

I also tried the example from the docs. First way throws the “Undeclared arguments” error, the second (initializeArguments) works fine.

Thanks a lot for your time,