{"action":"opened","issue":{"url":"https://api.github.com/repos/jobbyphp/jobby/issues/88","repository_url":"https://api.github.com/repos/jobbyphp/jobby","labels_url":"https://api.github.com/repos/jobbyphp/jobby/issues/88/labels{/name}","comments_url":"https://api.github.com/repos/jobbyphp/jobby/issues/88/comments","events_url":"https://api.github.com/repos/jobbyphp/jobby/issues/88/events","html_url":"https://github.com/jobbyphp/jobby/issues/88","id":264219047,"number":88,"title":"Serialization of closure failed: Serialization of 'Closure' is not allowed","user":{"login":"wujekbogdan","id":533954,"avatar_url":"https://avatars1.githubusercontent.com/u/533954?v=4","gravatar_id":"","url":"https://api.github.com/users/wujekbogdan","html_url":"https://github.com/wujekbogdan","followers_url":"https://api.github.com/users/wujekbogdan/followers","following_url":"https://api.github.com/users/wujekbogdan/following{/other_user}","gists_url":"https://api.github.com/users/wujekbogdan/gists{/gist_id}","starred_url":"https://api.github.com/users/wujekbogdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wujekbogdan/subscriptions","organizations_url":"https://api.github.com/users/wujekbogdan/orgs","repos_url":"https://api.github.com/users/wujekbogdan/repos","events_url":"https://api.github.com/users/wujekbogdan/events{/privacy}","received_events_url":"https://api.github.com/users/wujekbogdan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-10-10T13:02:01Z","updated_at":"2017-10-10T13:02:01Z","closed_at":null,"author_association":"NONE","body":"I'm having a strange issue. I'm getting a:\r\n`Notice: Serialization of closure failed: Serialization of 'Closure' is not allowed in /path/to/php/file.php` error.\r\n\r\nThis happens only when I use the `use` statement. So this code is causing the issue: \r\n\r\n```\r\n$jobby->add('export-all', [\r\n    'schedule' => $config->get(\"cron:export-all\"),\r\n    'closure'  => function () use ($app, $logger, $config) {\r\n        // Do something\r\n    },\r\n]);\r\n```\r\n\r\nBut this is fine:\r\n\r\n```\r\n$jobby->add('export-all', [\r\n    'schedule' => $config->get(\"cron:export-all\"),\r\n    'closure'  => function () {\r\n        $app = new App();\r\n        $config = $app->config();\r\n        $logger = $app->getLogger();\r\n        // Do something\r\n    },\r\n]);\r\n```\r\n\r\nBut, this is not a rule! Not always when I use the `use` statement I'm having this issue. But always when I'm getting this issue getting rid of the `use` statement solves the problem. \r\n\r\n---\r\nI know that Jobby is using SuperClosure internally, so it probably has something to to with SuperClosure not Jobby itself."}}
{"actor":{"display_login":"wujekbogdan"}}