Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lucciano opened this issue Oct 3, 2017 · 18 comments

Comments

@lucciano
Copy link
Contributor

lucciano commented Oct 3, 2017

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
Copy link
Member

core23 commented Oct 3, 2017

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

@greg0ire
Copy link
Contributor

greg0ire commented Oct 3, 2017

Can you please provide a full stack trace?

@lucciano
Copy link
Contributor Author

lucciano commented Oct 3, 2017

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
Copy link
Contributor

greg0ire commented Oct 3, 2017

Link for the lazy:

public function fixTemplates(ContainerBuilder $container, Definition $definition, array $overwrittenTemplates = array())
{
$definedTemplates = $container->getParameter('sonata.admin.configuration.templates');
$methods = array();
$pos = 0;
foreach ($definition->getMethodCalls() as $method) {
if ($method[0] == 'setTemplates') {
$definedTemplates = array_merge($definedTemplates, $method[1][0]);

@jlamur
Copy link
Contributor

jlamur commented Oct 3, 2017

@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
Copy link
Contributor

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

@lucciano
Copy link
Contributor Author

lucciano commented Oct 3, 2017

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

@greg0ire
Copy link
Contributor

greg0ire commented Oct 3, 2017

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

@lucciano
Copy link
Contributor Author

lucciano commented Oct 3, 2017

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

@lucciano
Copy link
Contributor Author

lucciano commented Oct 3, 2017

I patch the Line 362, with a cast and it looks ok, lucciano@691217d

@greg0ire
Copy link
Contributor

greg0ire commented Oct 3, 2017

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

@lucciano
Copy link
Contributor Author

lucciano commented Oct 3, 2017

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

@greg0ire
Copy link
Contributor

greg0ire commented Oct 3, 2017

This makes a lot more sense.

@greg0ire
Copy link
Contributor

greg0ire commented Oct 3, 2017

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

@greg0ire
Copy link
Contributor

greg0ire commented Oct 3, 2017

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
Copy link
Contributor

greg0ire commented Oct 3, 2017

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

@greg0ire
Copy link
Contributor

greg0ire commented Oct 3, 2017

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

@stale
Copy link

stale bot commented Jan 31, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants