{"action":"opened","issue":{"url":"https://api.github.com/repos/silexphp/Silex/issues/1535","repository_url":"https://api.github.com/repos/silexphp/Silex","labels_url":"https://api.github.com/repos/silexphp/Silex/issues/1535/labels{/name}","comments_url":"https://api.github.com/repos/silexphp/Silex/issues/1535/comments","events_url":"https://api.github.com/repos/silexphp/Silex/issues/1535/events","html_url":"https://github.com/silexphp/Silex/issues/1535","id":238573743,"number":1535,"title":"In development env warnings occur in error logs","user":{"login":"validweb","id":3267289,"avatar_url":"https://avatars2.githubusercontent.com/u/3267289?v=3","gravatar_id":"","url":"https://api.github.com/users/validweb","html_url":"https://github.com/validweb","followers_url":"https://api.github.com/users/validweb/followers","following_url":"https://api.github.com/users/validweb/following{/other_user}","gists_url":"https://api.github.com/users/validweb/gists{/gist_id}","starred_url":"https://api.github.com/users/validweb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/validweb/subscriptions","organizations_url":"https://api.github.com/users/validweb/orgs","repos_url":"https://api.github.com/users/validweb/repos","events_url":"https://api.github.com/users/validweb/events{/privacy}","received_events_url":"https://api.github.com/users/validweb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-06-26T15:06:32Z","updated_at":"2017-06-26T15:06:32Z","closed_at":null,"body":"Hi,\r\n\r\nI have noticed that when using this code in a dev env I get a warning  in the error log with every call to the middlewarelistener:\r\n\r\n** I am not responsible for the silex stuff in my team, but found this quick fix, so thought I'd let you know, I have very little knowledge of this, so please disregard if not appropriate.\r\n \r\n PHP Warning:  call_user_func() expects parameter 1 to be a valid callback, no array or string given in /xxxxxx/xxxxx/xxxxx/xxx/common/vendor/silex/silex/src/Silex/EventListener/MiddlewareListener.php on line 54\r\n\r\nI have fixed this locally as follows:\r\n\r\n/**\r\n     * Runs before filters.\r\n     *\r\n     * @param GetResponseEvent $event The event to handle\r\n     */\r\n    public function onKernelRequest(GetResponseEvent $event)\r\n    {\r\n        $request = $event->getRequest();\r\n        $routeName = $request->attributes->get('_route');\r\n        if (!$route = $this->app['routes']->get($routeName)) {\r\n            return;\r\n        }\r\n\r\n        foreach ((array) $route->getOption('_before_middlewares') as $callback) {\r\n            if (function_exists($this->app['callback_resolver']->resolveCallback($callback))) {\r\n                $ret = call_user_func($this->app['callback_resolver']->resolveCallback($callback), $request, $this->app);\r\n                if ($ret instanceof Response) {\r\n                    $event->setResponse($ret);\r\n\r\n                    return;\r\n                } elseif (null !== $ret) {\r\n                    throw new \\RuntimeException(sprintf('A before middleware for route \"%s\" returned an invalid response value. Must return null or an instance of Response.', $routeName));\r\n                }\r\n            }\r\n        }\r\n        return;\r\n    }\r\n\r\nHope this helps"}}
{"actor":{"display_login":"validweb"}}