sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: array_merge(): Argument #2 is not an array #4681

Closed lucciano closed 4 years ago

lucciano commented 6 years ago

Sonata packages

$ composer show --latest 'sonata-project/*'

sonata-project/admin-bundle 3.23.0 3.23.0 The missing Symfony Admin Generator
sonata-project/block-bundle 3.2.0 3.4.0 Symfony SonataBlockBundle sonata-project/cache 1.0.0 1.0.7 Cache library sonata-project/core-bundle 3.4.0 3.5.1 Symfony SonataCoreBundle sonata-project/datagrid-bundle 2.2 2.2.1 Symfony SonataDatagridBundle sonata-project/doctrine-orm-admin-bundle 3.1.0 3.1.7 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle sonata-project/exporter 1.7.0 1.7.1 Lightweight Exporter library

Symfony packages

$ composer show --latest 'symfony/*'

symfony/monolog-bundle v3.1.0 v3.1.1 Symfony MonologBundle
symfony/phpunit-bridge v3.3.0 v3.3.9 Symfony PHPUnit Bridge symfony/polyfill-apcu v1.1.0 v1.5.0 Symfony polyfill backporting apcu_* functions to lower PHP versions symfony/polyfill-intl-icu v1.0.0 v1.5.0 Symfony polyfill for intl's ICU-related data and classes symfony/polyfill-mbstring v1.0.0 v1.5.0 Symfony polyfill for the Mbstring extension symfony/polyfill-php56 v1.0.0 v1.5.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions symfony/polyfill-php70 v1.0.0 v1.5.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions symfony/polyfill-util v1.0.0 v1.5.0 Symfony utilities for portability of PHP codes symfony/security-acl v3.0.0 v3.0.0 Symfony Security Component - ACL (Access Control List) symfony/swiftmailer-bundle v2.3.10 v3.0.3 Symfony SwiftmailerBundle symfony/symfony v3.3.0 v3.3.9 The Symfony PHP framework

PHP version

$ php -v
PHP 7.1.10-1+0~20170929170818.9+stretch~1.gbp501135 (cli) (built: Sep 29 2017 17:08:20) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.10-1+0~20170929170818.9+stretch~1.gbp501135, Copyright (c) 1999-2017, by Zend Technologies

Subject

PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: array_merge(): Argument #2 is not an array

core23 commented 6 years ago

Can you please provide a little more information instead of all technical details.

greg0ire commented 6 years ago

Can you please provide a full stack trace?

lucciano commented 6 years ago
PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: array_merge(): Argument #2 is not an array in /drone/src/bitbucket.org/ikflowdat/ftth/vendor/sonata-project/admin-bundle/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php:362
Stack trace:
#0 /drone/src/bitbucket.org/ikflowdat/ftth/vendor/sonata-project/admin-bundle/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php(338): Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass->fixTemplates(Object(Symfony\Component\DependencyInjection\ContainerBuilder), Object(Symfony\Component\DependencyInjection\Definition), Array)
#1 /drone/src/bitbucket.org/ikflowdat/ftth/vendor/sonata-project/admin-bundle/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php(67): Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass->applyDefaults(Object(Symfony\Component\DependencyInjection\ContainerBuilder), 'ftth.admin.onu', Array)
#2 /drone/src/bitbucket.org/ikflowdat/ftth/vend in /drone/src/bitbucket.org/ikflowdat/ftth/vendor/sonata-project/admin-bundle/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php on line 362
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception
greg0ire commented 6 years ago

Link for the lazy: https://github.com/sonata-project/SonataAdminBundle/blob/d796658ee47f36abe9f910b9b96dd74d94966772/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php#L354-L362

jlamur commented 6 years ago

@lucciano Please check you've passed an array (and not a scalar) as the first parameter of the setTemplates method call in your ftth.admin.onu service definition.

dmarkowicz commented 6 years ago

Not covered by tests https://coveralls.io/builds/13529726/source?filename=DependencyInjection%2FCompiler%2FAddDependencyCallsCompilerPass.php#L362

lucciano commented 6 years ago

@jlamur I don't call setTemplate directlly, it get called when the admin is wired with the tag "sonata.admin"

greg0ire commented 6 years ago

Please var_dump($method[1][0]);die();

lucciano commented 6 years ago

@greg0ire string(38) "%sonata.admin.configuration.templates%"

lucciano commented 6 years ago

I patch the Line 362, with a cast and it looks ok, https://github.com/lucciano/SonataAdminBundle/commit/691217d41231c1b2e43279d51b4ca6fec410140b

greg0ire commented 6 years ago

Probably related to #4580 EDIT: now sure how though, unless fixTemplates is called several times?

lucciano commented 6 years ago

The other option is to change L 393 to $definition->addMethodCall('setTemplates', array(array('%sonata.admin.configuration.templates%')));

greg0ire commented 6 years ago

This makes a lot more sense.

greg0ire commented 6 years ago

Or does it? I'm not sure anymore...

greg0ire commented 6 years ago

That would mean the first argument of setTemplates would be array('%sonata.admin.configuration.templates%'), which should result into a 2-dimensional array... pretty weird.

greg0ire commented 6 years ago

Maybe the right solution would be to resolve the parameter before merging it

greg0ire commented 6 years ago

Or maybe: just don't merge if it's not an array.

stale[bot] commented 4 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.