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

Catchable Fatal Error: Argument 1 passed to AttributeBag::initialize() #23175

Closed
anacona16 opened this issue Jun 14, 2017 · 23 comments
Closed

Catchable Fatal Error: Argument 1 passed to AttributeBag::initialize() #23175

anacona16 opened this issue Jun 14, 2017 · 23 comments

Comments

@anacona16
Copy link

anacona16 commented Jun 14, 2017

Q A
Bug report? yes
Feature request? no
Symfony version v3.3.2

Sometimes I'm getting this errors, it started happen after update to Symfony 3.3.2.

(2/2) ContextErrorException
Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::initialize() must be of the type array, object given, called in /var/www/vhosts/site.com/httpdocs/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php on line 412 and defined

$ composer show

swiftmailer/swiftmailer                       v5.4.8             Swiftmailer, free feature-rich PHP mailer
symfony/monolog-bundle                        v3.1.0             Symfony MonologBundle
symfony/phpunit-bridge                        v3.3.2             Symfony PHPUnit Bridge
symfony/polyfill-apcu                         v1.4.0             Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu                     v1.4.0             Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring                     v1.4.0             Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                        v1.4.0             Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70                        v1.4.0             Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util                         v1.4.0             Symfony utilities for portability of PHP codes
symfony/security-acl                          v3.0.0             Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle                    v2.6.2             Symfony SwiftmailerBundle
symfony/symfony                               v3.3.2             The Symfony PHP framework
tecnickcom/tcpdf                              6.2.12             TCPDF is a PHP class for generating PDF documents and barcodes.
twig/extensions                               v1.5.1             Common additional features for Twig that do not directly belong in core
twig/twig     
@stof
Copy link
Member

stof commented Jun 14, 2017

Well, Sometimes I'm getting this errors does not help us debugging. Can you provide more info about when it happens ?

@anacona16
Copy link
Author

anacona16 commented Jun 14, 2017

This is an snippet for apache_error.log

[Wed Jun 14 10:34:07.053505 2017] [:error] [pid 17926] [client xxx.xx.xxx.xx:51822] PHP Fatal error:  Uncaught exception 'ErrorException' with message 'Catchable Fatal Error: Argument 1 passed to Symfony\\Component\\HttpFoundation\\Session\\Attribute\\AttributeBag::initialize() must be of the type array, object given, called in /var/www/vhosts/site.com/httpdocs/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php on line 412 and defined' in /var/www/vhosts/site.com/httpdocs/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php:57

Stack trace:

#0 /var/www/vhosts/site.com/httpdocs/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php(412): Symfony\\Component\\HttpFoundation\\Session\\Attribute\\AttributeBag->initialize(Object(Symfony\\Component\\VarDumper\\Cloner\\Stub))

#1 /var/www/vhosts/site.com/httpdocs/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php(144): Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionSt in /var/www/vhosts/site.com/httpdocs/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php on line 57

@stof the only weird thing that I did, was get logged in with the same user in another browser. If I open the site in an incognito window, it works

@stof
Copy link
Member

stof commented Jun 14, 2017

@nicolas-grekas looks like we have another case where a Stub is leaked to the original value (and I don't think this one involves ProxyManager, unlike #23110)

@nicolas-grekas nicolas-grekas self-assigned this Jun 14, 2017
@nicolas-grekas
Copy link
Member

@anacona16 can you post the full stack trace please?

@nicolas-grekas
Copy link
Member

And also the first exception (your excerpt says 2/2. What is 1/2?)

@anacona16
Copy link
Author

anacona16 commented Jun 14, 2017

@nicolas-grekas let me know if this help you. Thanks

(1/2) ContextErrorException

Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::initialize() must be of the type array, object given, called in /var/www/vhosts/site/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php on line 412 and defined
in AttributeBag.php (line 57)

at AttributeBag->initialize(object(Stub))
in NativeSessionStorage.php (line 412)

at NativeSessionStorage->loadSession()
in NativeSessionStorage.php (line 144)

at NativeSessionStorage->start()
in NativeSessionStorage.php (line 278)

at NativeSessionStorage->getBag('attributes')
in Session.php (line 259)

at Session->getAttributeBag()
in Session.php (line 87)

at Session->get('_security_main')
in ContextListener.php (line 83)

at ContextListener->handle(object(GetResponseEvent))
in Firewall.php (line 69)

at Firewall->onKernelRequest(object(GetResponseEvent))
in FirewallListener.php (line 48)

at FirewallListener->onKernelRequest(object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))

at call_user_func(array(object(FirewallListener), 'onKernelRequest'), object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
in WrappedListener.php (line 106)

at WrappedListener->__invoke(object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))
at call_user_func(object(WrappedListener), object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))
in EventDispatcher.php (line 212)

at EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(GetResponseEvent))
in EventDispatcher.php (line 44)

at EventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
in TraceableEventDispatcher.php (line 146)

at TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
in HttpKernel.php (line 129)

at HttpKernel->handleRaw(object(Request), 1)
in HttpKernel.php (line 68)

at HttpKernel->handle(object(Request), 1, true)
in Kernel.php (line 171)

at Kernel->handle(object(Request))
in app_dev.php (line 27)
(2/2) ContextErrorException

Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::initialize() must be of the type array, object given, called in /var/www/vhosts/site/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php on line 412 and defined
in AttributeBag.php (line 57)

at AttributeBag->initialize(object(Stub))
in NativeSessionStorage.php (line 412)

at NativeSessionStorage->loadSession()
in NativeSessionStorage.php (line 276)

at NativeSessionStorage->getBag('attributes')
in Session.php (line 259)

at Session->getAttributeBag()
in Session.php (line 87)

at Session->get('product_id')
in FilterManager.php (line 68)

at FilterManager->onKernelRequest(object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))

at call_user_func(array(object(FilterManager), 'onKernelRequest'), object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
in WrappedListener.php (line 106)

at WrappedListener->__invoke(object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))

at call_user_func(object(WrappedListener), object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
in WrappedListener.php (line 106)

at WrappedListener->__invoke(object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))

at call_user_func(object(WrappedListener), object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))
in EventDispatcher.php (line 212)

at EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(GetResponseEvent))
in EventDispatcher.php (line 44)

at EventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
in TraceableEventDispatcher.php (line 146)

at TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
in HttpKernel.php (line 129)

at HttpKernel->handleRaw(object(Request), 2)
in HttpKernel.php (line 68)

at HttpKernel->handle(object(Request), 2, false)
in ExceptionListener.php (line 50)

at ExceptionListener->onKernelException(object(GetResponseForExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher))

at call_user_func(array(object(ExceptionListener), 'onKernelException'), object(GetResponseForExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher))
in WrappedListener.php (line 106)

at WrappedListener->__invoke(object(GetResponseForExceptionEvent), 'kernel.exception', object(ContainerAwareEventDispatcher))

at call_user_func(object(WrappedListener), object(GetResponseForExceptionEvent), 'kernel.exception', object(ContainerAwareEventDispatcher))
in EventDispatcher.php (line 212)

at EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.exception', object(GetResponseForExceptionEvent))
in EventDispatcher.php (line 44)

at EventDispatcher->dispatch('kernel.exception', object(GetResponseForExceptionEvent))
in TraceableEventDispatcher.php (line 146)

at TraceableEventDispatcher->dispatch('kernel.exception', object(GetResponseForExceptionEvent))
in HttpKernel.php (line 230)

at HttpKernel->handleException(object(ContextErrorException), object(Request), 1)
in HttpKernel.php (line 79)

at HttpKernel->handle(object(Request), 1, true)
in Kernel.php (line 171)

at Kernel->handle(object(Request))
in app_dev.php (line 27)

@morrunyo
Copy link

morrunyo commented Jul 4, 2017

Hi:

I have the same issue:

Symfony\Component\Debug\Exception\ContextErrorException:
Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::initialize() must be of the type array, object given, called in /home/ubuntu/workspace/var/cache/dev/classes.php on line 248 and defined

  at vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php:57
  at Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag->initialize(object(Stub))
     (var/cache/dev/classes.php:248)
  at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->loadSession()
     (var/cache/dev/classes.php:116)
  at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
     (var/cache/dev/classes.php:192)
  at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag('attributes')
     (var/cache/dev/classes.php:540)
  at Symfony\Component\HttpFoundation\Session\Session->getAttributeBag()
     (var/cache/dev/classes.php:459)
  at Symfony\Component\HttpFoundation\Session\Session->get('_security_main')
     (vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/ContextListener.php:83)
  at Symfony\Component\Security\Http\Firewall\ContextListener->handle(object(GetResponseEvent))
     (var/cache/dev/classes.php:4744)
  at Symfony\Component\Security\Http\Firewall->onKernelRequest(object(GetResponseEvent))
     (vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php:48)
  at Symfony\Bundle\SecurityBundle\EventListener\FirewallListener->onKernelRequest(object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
  at call_user_func(array(object(FirewallListener), 'onKernelRequest'), object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
     (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:106)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))
  at call_user_func(object(WrappedListener), object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))
     (var/cache/dev/classes.php:3464)
  at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(GetResponseEvent))
     (var/cache/dev/classes.php:3347)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
     (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:146)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
     (var/cache/dev/classes.php:4424)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (var/cache/dev/classes.php:4394)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:171)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/app_dev.php:32)

@abdfork
Copy link

abdfork commented Jul 6, 2017

I'm having the same issue, I did some research so just a bit more info in case it helps to fix it:

In my case, this can be replicated when assigning an undefined var (misspelt it) to 'choices' on a ChoiceType.

It crashes without printing an error, and I get on apache:

[Thu Jul 06 19:03:55.616948 2017] [:error] [pid 1992] [client 192.168.33.1:58692] PHP Warning:  call_user_func() expects parameter 1 to be a valid callback, cannot access private method Symfony\\Bridge\\Monolog\\Handler\\ServerLogHandler::nullErrorHandler() in /var/www/public/capsulesPanel-dev/vendor/symfony/symfony/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php on line 205
[Thu Jul 06 19:03:55.617142 2017] [:error] [pid 1992] [client 192.168.33.1:58692] PHP Fatal error:  Unsupported operand types in /var/www/public/capsulesPanel-dev/vendor/symfony/symfony/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php on line 43

Then, 3 keys are set in the session, and you get the message that @anacona16 posted.
_sf2_attributes, _sf2_flashes, _sf2_meta and of them an object(Symfony\Component\VarDumper\Cloner\Stub)

@thegobot
Copy link

Hi! Some errors...

print_r($_SESSION);
Array(
    [_sf2_attributes] => Array
        (
            [coupon] => 2
            [rec_views] => Array
                (
                    [0] => 31830
                    [1] => 31909
                    [2] => 29264
                    [3] => 31885
                    [4] => 31838
                    [5] => 31956
                    [6] => 31994
                    [7] => 32027
                    [8] => 32026
                    [9] => 32397
                )

        )

    [_sf2_flashes] => Array
        (
        )

    [_sf2_meta] => Symfony\Component\VarDumper\Cloner\Stub Object
        (
            [type] => ref
            [class] => 
            [value] => Symfony\Component\VarDumper\Cloner\Stub Object
                (
                    [type] => array
                    [class] => assoc
                    [value] => 3
                    [cut] => 0
                    [handle] => 0
                    [refCount] => 0
                    [position] => 136
                    [attr] => Array
                        (
                        )

                )

            [cut] => 0
            [handle] => 1
            [refCount] => 0
            [position] => 0
            [attr] => Array
                (
                )

        )

)

var_dump($session->all());

got error

/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php:71 Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpFoundation\Session\Storage\MetadataBag::initialize() must be of the type array, object given, called in /vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php on line 414 and defined

Symfony\Component\VarDumper\Cloner\Stub

@nataliaAznar
Copy link

Hi,

I have the same problem

request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::initialize() must be of the type array, object given, called in /var/www/html/var/cache/dev/classes.php on line 248 and defined" at /var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php line 57 {"exception":"[object] (Symfony\Component\Debug\Exception\ContextErrorException(code: 0): Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::initialize() must be of the type array, object given, called in /var/www/html/var/cache/dev/classes.php on line 248 and defined at /var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php:57)"} []

@nicolas-grekas
Copy link
Member

Should be fixed by #23465

nicolas-grekas added a commit that referenced this issue Jul 11, 2017
…f (nicolas-grekas)

This PR was merged into the 3.3 branch.

Discussion
----------

[HttpKernel][VarDumper] Truncate profiler data & optim perf

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23415, #21547 and hopefully #23110 and #23175
| License       | MIT
| Doc PR        | -

Commits
-------

754d3a7 [HttpKernel][VarDumper] Truncate profiler data & optim perf
@utkarsh2k2
Copy link

I am getting the same error Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::initialize() must be of the type array, object given, called in C:\wamp64\www\FormEvents\vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage.php on line 412 and defined
Here is the stack trace:

`Symfony\Component\Debug\Exception\ContextErrorException:
Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::initialize() must be of the type array, object given, called in C:\wamp64\www\FormEvents\vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage.php on line 412 and defined

at vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag.php:57
at Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag->initialize(object(Stub))
(vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage.php:412)
at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->loadSession()
(vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage.php:144)
at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
(vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage.php:278)
at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag('attributes')
(vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Session.php:259)
at Symfony\Component\HttpFoundation\Session\Session->getAttributeBag()
(vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Session.php:87)
at Symfony\Component\HttpFoundation\Session\Session->get('_security_main')
(vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall\ContextListener.php:83)
at Symfony\Component\Security\Http\Firewall\ContextListener->handle(object(GetResponseEvent))
(vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall.php:69)
at Symfony\Component\Security\Http\Firewall->onKernelRequest(object(GetResponseEvent))
(vendor\symfony\symfony\src\Symfony\Bundle\SecurityBundle\EventListener\FirewallListener.php:48)
at Symfony\Bundle\SecurityBundle\EventListener\FirewallListener->onKernelRequest(object(GetResponseEvent))
(var\cache\dev\appDevDebugProjectContainer.php:806)
at appDevDebugProjectContainer->{closure}(object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
at call_user_func(object(Closure), object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
(vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\Debug\WrappedListener.php:112)
at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))
at call_user_func(object(WrappedListener), object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))
(vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\EventDispatcher.php:174)
at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(GetResponseEvent))
(vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\EventDispatcher.php:43)
at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
(vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher.php:146)
at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:129)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:68)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:171)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(web\app_dev.php:30)`

The given fix #23465 does not work for me. Also I am unable to understand the fix. I am on symfony 3.3. Can anyone help?

@nicolas-grekas
Copy link
Member

Are you on 3.3.8?
Can you provide a reproducer?

@utkarsh2k2
Copy link

Composer.json says "symfony/symfony": "3.3.*" . What do you mean by reproducer?

@nicolas-grekas
Copy link
Member

what does composer show say?
by reproducer, I mean a small app that has the issue.

@utkarsh2k2
Copy link

here is the output of composer show :
composer/ca-bundle 1.0.7 Lets you find a path to the system CA bundle, and includes a fallback...
doctrine/annotations v1.2.7 Docblock Annotations Parser
doctrine/cache v1.6.1 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.3.0 Collections Abstraction library
doctrine/common v2.6.2 Common Library for Doctrine projects
doctrine/dbal v2.5.12 Database Abstraction Layer
doctrine/doctrine-bundle 1.6.8 Symfony DoctrineBundle
doctrine/doctrine-cache-bundle 1.3.0 Symfony Bundle for Doctrine Cache
doctrine/inflector v1.1.0 Common String Manipulations with regard to casing and singular/plural...
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without in...
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Desc...
doctrine/orm v2.5.6 Object-Relational-Mapper for PHP
fig/link-util 1.0.0 Common utility implementations for HTTP links
incenteev/composer-parameter-handler v2.1.2 Composer script handling your ignored parameter file
jdorn/sql-formatter v1.2.17 a PHP SQL highlighting library
monolog/monolog 1.22.1 Sends your logs to files, sockets, inboxes, databases and various web...
paragonie/random_compat v2.0.10 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
psr/cache 1.0.1 Common interface for caching libraries
psr/container 1.0.0 Common Container Interface (PHP FIG PSR-11)
psr/link 1.0.0 Common interfaces for HTTP links
psr/log 1.0.2 Common interface for logging libraries
psr/simple-cache 1.0.0 Common interfaces for simple caching
sensio/distribution-bundle v5.0.20 Base bundle for Symfony Distributions
sensio/framework-extra-bundle v3.0.26 This bundle provides a way to configure your controllers with annotat...
sensio/generator-bundle v3.1.4 This bundle generates code for you
sensiolabs/security-checker v4.0.4 A security checker for your composer.lock
swiftmailer/swiftmailer v5.4.8 Swiftmailer, free feature-rich PHP mailer
symfony/monolog-bundle v3.1.0 Symfony MonologBundle
symfony/phpunit-bridge v3.3.0 Symfony PHPUnit Bridge
symfony/polyfill-apcu v1.3.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu v1.3.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring v1.3.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56 v1.3.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP vers...
symfony/polyfill-php70 v1.3.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP vers...
symfony/polyfill-util v1.3.0 Symfony utilities for portability of PHP codes
symfony/swiftmailer-bundle v2.6.2 Symfony SwiftmailerBundle
symfony/symfony v3.3.0 The Symfony PHP framework
twig/twig v1.33.2 Twig, the flexible, fast, and secure template language for PHP

@utkarsh2k2
Copy link

Here is my ProductType.php:

`<?php

namespace AppBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class ProductType extends AbstractType {

public function buildForm(FormBuilderInterface $builder, array $options) {
    $builder->add('price');

    $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
        $product = $event->getData();
        $form = $event->getForm();

        // check if the Product object is "new"
        // If no data is passed to the form, the data is "null".
        // This should be considered a new "Product"
        if (!$product || null === $product->getId()) {
            $form->add('name', TextType::class);
        }
    });
    $builder->add('save', SubmitType::class, array('label' => 'Submit'));
}

// ...

}
`

And my Controller:

/**
 * @Route("/product", name="productpage")
 */
public function productAction(Request $request) {
    $product = new Product();

    $form = $this->createForm(ProductType::class, $product);

    $form->handleRequest($request);
    //check for validation
    if ($form->isValid()) {
        $em = $this->getDoctrine()->getManager();
        //save the $candidate object into database
        $em->persist($product);
        $em->flush();
        //redirect to success page
        return $this->redirectToRoute('successpage');
    }

    return $this->render('default/product.html.twig', array(
                'form' => $form->createView(),
    ));
}

@nicolas-grekas
Copy link
Member

It would be great to read to output yourself...
symfony/symfony v3.3.0
so, yes, your version is buggy, you just need to update...

@abdfork
Copy link

abdfork commented Sep 1, 2017 via email

@utkarsh2k2
Copy link

ok will try that

@utkarsh2k2
Copy link

utkarsh2k2 commented Sep 1, 2017

ok I just ran composer update and it updated the symfony version to 3.3.8 . Problem is now my app won't load. No error message, the page never finish loading.

@pacid
Copy link

pacid commented Dec 8, 2017

Btw, clearing cookies help to get rid of this problem.

@suneelam758
Copy link

Hey, I have some errors in PHP database registration query.
"Catchable fatal error: Argument 1 passed to esc() must be an instance of String, string given, called in C:\wamp\www\complete-blog-php\admin\includes\admin_functions.php on line 44 and defined in C:\wamp\www\complete-blog-php\admin\includes\admin_functions.php on line 158"

Line 42 to 51 ->
function createAdmin($request_values){
global $conn, $errors, $role, $username, $email;
$username = esc($request_values['username']);
$email = esc($request_values['email']);
$password = esc($request_values['password']);
$passwordConfirmation = esc($request_values['passwordConfirmation']);

if(isset($request_values['role'])){
	$role = esc($request_values['role']);
}

Line 158-165
function esc(String $value){
// bring the global db connect object into function
global $conn;
// remove empty space sorrounding string
$val = trim($value);
$val = mysqli_real_escape_string($conn, $value);
return $val;
}

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