1

So I am using BjyAuthorize for route guards & rules for resources, I am using assertion in rule providers of BjyAuthorize but they seem to throw this error

Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in /home/haris/Glide/vcgca/vendor/zendframework/zend-stdlib/src/PriorityQueue.php on line 178

Exception: Serialization of 'Closure' is not allowed in /home/haris/Glide/vcgca/vendor/zendframework/zend-stdlib/src/PriorityQueue.php on line 178

Here is my config for rule provider:

'bjyauthorize' => array(
        'resource_providers' => array(
            'BjyAuthorize\Provider\Resource\Config' => array(
                'Page' => array(),
            ),
        ),
        'rule_providers' => array(
            'BjyAuthorize\Provider\Rule\Config' => array(
                'allow' => array(
                    array(array('user', 'user1'), 'Page', array('edit'), 'assertion.CheckManager'),
                ),
            ),
        ),
    ),

Here is my assertion class factory:

class PageManagerAssertionFactory implements FactoryInterface {

    public function createService(ServiceLocatorInterface $serviceLocator) {
        $authentication = $serviceLocator->get('zfcuser_auth_service');
        $entityManager = $serviceLocator->get('doctrine.entitymanager.orm_default');
        return new PageManagerAssertion($authentication, $entityManager);
    }

}

This is my assertion class:

class PageManagerAssertion implements AssertionInterface {

    protected $authentication;
    protected $entityManager;

    public function __construct($authentication, EntityManager $entityManager) {
        $this->authentication = $authentication;
        $this->entityManager = $entityManager;
    }

    public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null) {

        if ($resource instanceof Page) {
            return false;
        } else {
            return true;
        }
    }

}

I have included this class in service service_manager config in module.config.php

'service_manager' => array(
        'factories' => array(
            //ASSERTIONS
            'assertion.CheckManager' => 'AlphaPage\Assertion\PageManagerAssertionFactory',
            //OTHERS
            ......
        ),
    ),

I have no idea why am I getting this error, I followed all the steps to use the modules, I have assertions in other modules that are working totally fine.

Any help in this regard will be highly appreciated.

Community
  • 1
  • 1
Haris Mehmood
  • 854
  • 4
  • 15
  • 26
  • I assume you haven't used any anonymous functions as factories in module.config.php that has not been included in the question? – Purple Hexagon Feb 08 '17 at 12:42
  • Also was there not a stack trace included with the exception? – Purple Hexagon Feb 08 '17 at 12:44
  • @PurpleHexagon yes your assumption is correct --yes no stacktrace included – Haris Mehmood Feb 08 '17 at 12:54
  • Perhaps it would be worth stepping through the code using xdebug and seeing what PriorityQueue::items is set to when the serialize function call fails. Or wrapping the serialize func call in PriorityQueue::serialize method with a try catch and var_dump out PriorityQueue::items if you don't have xdebug setup – Purple Hexagon Feb 08 '17 at 13:15
  • @PurpleHexagon When all the app modules (Project + Vendor) are passed to the Queue with their onBootstrap callbacks this is where I get this error obviously my module in which I defined this rule is loaded, this is when I get this error -- I took your advice and used var_dump, other than Closure I got one more error and that is "'Serialization of 'SimpleXMLElement' is not allowed'" – Haris Mehmood Feb 08 '17 at 13:47
  • @PurpleHexagon By any chance do you have anyidea what is causing this issue – Haris Mehmood Feb 08 '17 at 13:47
  • Sadly not currently – Purple Hexagon Feb 08 '17 at 13:59

0 Answers0