EtonDigital / EDBlogBundle

EDBlogBundle is extensive and user friendly blog bundle for Symfony2. It provides a lot of interesting features that makes a serious bloging platform from your Symfony2 application. It is very intuitive and flexible, you can easily fit it to your own needs.
MIT License
35 stars 20 forks source link

Type error: Argument 1 passed to ED\BlogBundle\Security\Authorization\Voter\ArticleVoter::__construct() must be an instance of ED\BlogBundle\Security\ACL\ArticlePermissionMap, none given #15

Closed PBXg33k closed 8 years ago

PBXg33k commented 8 years ago

After following the install instructions i am presented with the following exception when trying to login.

meh

Any idea where i might have made a mistake?

Here's the plain text stack trace: ` [1] Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to ED\BlogBundle\Security\Authorization\Voter\ArticleVoter::__construct() must be an instance of ED\BlogBundle\Security\ACL\ArticlePermissionMap, none given, called in /srv/mikudb-symfony2-dev/vendor/ed/blog-bundle/Security/Authorization/Voter/ArticleVoter.php on line 37 at n/a in /srv/mikudb-symfony2-dev/vendor/ed/blog-bundle/Security/Authorization/Voter/ArticleVoter.php line 22

at ED\BlogBundle\Security\Authorization\Voter\ArticleVoter->__construct()
    in /srv/mikudb-symfony2-dev/vendor/ed/blog-bundle/Security/Authorization/Voter/ArticleVoter.php line 37

at ED\BlogBundle\Security\Authorization\Voter\ArticleVoter->supportsClass('ED\BlogBundle\Security\Authorization\Voter\ArticleVoter')
    in /srv/mikudb-symfony2-dev/vendor/ed/blog-bundle/Security/Authorization/Voter/ArticleVoter.php line 59

at ED\BlogBundle\Security\Authorization\Voter\ArticleVoter->vote(object(AnonymousToken), null, array('IS_AUTHENTICATED_REMEMBERED'))
    in /srv/mikudb-symfony2-dev/app/cache/dev/classes.php line 2778

at Symfony\Component\Security\Core\Authorization\AccessDecisionManager->decideAffirmative(object(AnonymousToken), array('IS_AUTHENTICATED_REMEMBERED'), null)
    in /srv/mikudb-symfony2-dev/app/cache/dev/classes.php line 2754

at Symfony\Component\Security\Core\Authorization\AccessDecisionManager->decide(object(AnonymousToken), array('IS_AUTHENTICATED_REMEMBERED'), null)
    in /srv/mikudb-symfony2-dev/app/cache/dev/classes.php line 2884

at Symfony\Component\Security\Core\Authorization\AuthorizationChecker->isGranted(array('IS_AUTHENTICATED_REMEMBERED'), null)
    in /srv/mikudb-symfony2-dev/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php line 41

at Symfony\Bridge\Twig\Extension\SecurityExtension->isGranted('IS_AUTHENTICATED_REMEMBERED')
    in /srv/mikudb-symfony2-dev/app/cache/dev/twig/57/57e31b1f648ebc45e8bbb5a9acb178c633b310fbb6b1541059bc9fa3a0c5833a.php line 32

at __TwigTemplate_f055c9416ac9310e1f16143fea9518ff8882c67680064ec0601a214a5128d0bf->doDisplay(array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => true), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_media' => object(GlobalVariables)), array('fos_user_content' => array(object(__TwigTemplate_cdf546c3c587ffe8a6093fa806bf15161da414e5187764abfc225d061bcf35fd), 'block_fos_user_content')))
    in /srv/mikudb-symfony2-dev/app/cache/dev/classes.php line 4891

at Twig_Template->displayWithErrorHandling(array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => true), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_media' => object(GlobalVariables)), array('fos_user_content' => array(object(__TwigTemplate_cdf546c3c587ffe8a6093fa806bf15161da414e5187764abfc225d061bcf35fd), 'block_fos_user_content')))
    in /srv/mikudb-symfony2-dev/app/cache/dev/classes.php line 4872

at Twig_Template->display(array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => true), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_media' => object(GlobalVariables)), array('fos_user_content' => array(object(__TwigTemplate_cdf546c3c587ffe8a6093fa806bf15161da414e5187764abfc225d061bcf35fd), 'block_fos_user_content')))
    in /srv/mikudb-symfony2-dev/app/cache/dev/twig/ed/ed78adc16e6afe28480cbdc14a5f587335a629923ffbe5b390865a4f7f5c3286.php line 27

at __TwigTemplate_cdf546c3c587ffe8a6093fa806bf15161da414e5187764abfc225d061bcf35fd->doDisplay(array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => true), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_media' => object(GlobalVariables)), array('fos_user_content' => array(object(__TwigTemplate_cdf546c3c587ffe8a6093fa806bf15161da414e5187764abfc225d061bcf35fd), 'block_fos_user_content')))
    in /srv/mikudb-symfony2-dev/app/cache/dev/classes.php line 4891

at Twig_Template->displayWithErrorHandling(array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => true), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_media' => object(GlobalVariables)), array('fos_user_content' => array(object(__TwigTemplate_cdf546c3c587ffe8a6093fa806bf15161da414e5187764abfc225d061bcf35fd), 'block_fos_user_content')))
    in /srv/mikudb-symfony2-dev/app/cache/dev/classes.php line 4872

at Twig_Template->display(array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4'))
    in /srv/mikudb-symfony2-dev/app/cache/dev/classes.php line 4879

at Twig_Template->render(array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4'))
    in /srv/mikudb-symfony2-dev/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 50

at Symfony\Bridge\Twig\TwigEngine->render('FOSUserBundle:Security:login.html.twig', array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4'))
    in /srv/mikudb-symfony2-dev/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigEngine.php line 72

at Symfony\Bundle\TwigBundle\TwigEngine->render('FOSUserBundle:Security:login.html.twig', array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4'))
    in /srv/mikudb-symfony2-dev/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigEngine.php line 97

at Symfony\Bundle\TwigBundle\TwigEngine->renderResponse('FOSUserBundle:Security:login.html.twig', array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4'), object(Response))
    in /srv/mikudb-symfony2-dev/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php line 176

at Symfony\Bundle\FrameworkBundle\Controller\Controller->render('FOSUserBundle:Security:login.html.twig', array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4'))
    in /srv/mikudb-symfony2-dev/vendor/friendsofsymfony/user-bundle/Controller/SecurityController.php line 79

at FOS\UserBundle\Controller\SecurityController->renderLogin(array('last_username' => null, 'error' => null, 'csrf_token' => '8jDOo-Uxk_wf8UVFE2p4G1T8fEKXrqZV0jMhGtf4Dl4'))
    in /srv/mikudb-symfony2-dev/vendor/friendsofsymfony/user-bundle/Controller/SecurityController.php line 65

at FOS\UserBundle\Controller\SecurityController->loginAction(object(Request))
    in  line 

at call_user_func_array(array(object(SecurityController), 'loginAction'), array(object(Request)))
    in /srv/mikudb-symfony2-dev/app/bootstrap.php.cache line 3110

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
    in /srv/mikudb-symfony2-dev/app/bootstrap.php.cache line 3072

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
    in /srv/mikudb-symfony2-dev/app/bootstrap.php.cache line 3223

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
    in /srv/mikudb-symfony2-dev/app/bootstrap.php.cache line 2442

at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
    in /srv/mikudb-symfony2-dev/web/app_dev.php line 29

`

PBXg33k commented 8 years ago

Ok, i traced the error back to a design change introduced in PHP7.

The error is caused by a "TypeError", which extends the "Error" base class. Since Error doesn't extends Exception it doesn't get catched.

Updating the supports() method in ArticleVoter.php from


        }
        catch(\Exception $e)
        {
            return false;
        }

to


        catch(\Exception $e)
        {
            return false;
        }
        catch(\Error $e)
        {
            return false;
        }
PBXg33k commented 8 years ago

16

Created a quick PR with my change that worked on my local development server (Debian, PHP 7.0.2)

inri13666 commented 7 years ago

As possible solution https://gist.github.com/inri13666/fcdcf58a6678d07f0c47c5f707c782c5