{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/39705100","id":39705100,"diff_hunk":"@@ -46,21 +44,23 @@ public function dispatch($eventName, Event $event = null)\n         $event->setDispatcher($this);\n         $event->setName($eventName);\n \n-        if (!isset($this->listeners[$eventName])) {\n-            return $event;\n+        if ($listeners = $this->getListeners($eventName)) {\n+            $this->doDispatch($listeners, $eventName, $event);\n         }\n \n-        $this->doDispatch($this->getListeners($eventName), $eventName, $event);\n-\n         return $event;\n     }\n \n     /**\n-     * @see EventDispatcherInterface::getListeners()\n+     * {@inheritdoc}\n      */\n     public function getListeners($eventName = null)\n     {\n         if (null !== $eventName) {\n+            if (!isset($this->listeners[$eventName])) {\n+                return array();","path":"src/Symfony/Component/EventDispatcher/EventDispatcher.php","position":34,"original_position":34,"commit_id":"a7b7f5479eabfe00c462fc7640d712ec99fdda5f","original_commit_id":"a7b7f5479eabfe00c462fc7640d712ec99fdda5f","user":{"login":"Tobion","id":610090,"avatar_url":"https://avatars.githubusercontent.com/u/610090?v=3","gravatar_id":"","url":"https://api.github.com/users/Tobion","html_url":"https://github.com/Tobion","followers_url":"https://api.github.com/users/Tobion/followers","following_url":"https://api.github.com/users/Tobion/following{/other_user}","gists_url":"https://api.github.com/users/Tobion/gists{/gist_id}","starred_url":"https://api.github.com/users/Tobion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tobion/subscriptions","organizations_url":"https://api.github.com/users/Tobion/orgs","repos_url":"https://api.github.com/users/Tobion/repos","events_url":"https://api.github.com/users/Tobion/events{/privacy}","received_events_url":"https://api.github.com/users/Tobion/received_events","type":"User","site_admin":false},"body":"without it, the `sorted` property would be initialized even for non-existing events. Getters should not leak infinite memory.","created_at":"2015-09-17T01:47:37Z","updated_at":"2015-09-17T01:47:37Z","html_url":"https://github.com/symfony/symfony/pull/15821#discussion_r39705100","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/15821","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/39705100"},"html":{"href":"https://github.com/symfony/symfony/pull/15821#discussion_r39705100"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/15821"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/15821","id":45243880,"html_url":"https://github.com/symfony/symfony/pull/15821","diff_url":"https://github.com/symfony/symfony/pull/15821.diff","patch_url":"https://github.com/symfony/symfony/pull/15821.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/15821","number":15821,"state":"open","locked":false,"title":"[EventDispatcher] fix memory in getListeners","user":{"login":"Tobion","id":610090,"avatar_url":"https://avatars.githubusercontent.com/u/610090?v=3","gravatar_id":"","url":"https://api.github.com/users/Tobion","html_url":"https://github.com/Tobion","followers_url":"https://api.github.com/users/Tobion/followers","following_url":"https://api.github.com/users/Tobion/following{/other_user}","gists_url":"https://api.github.com/users/Tobion/gists{/gist_id}","starred_url":"https://api.github.com/users/Tobion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tobion/subscriptions","organizations_url":"https://api.github.com/users/Tobion/orgs","repos_url":"https://api.github.com/users/Tobion/repos","events_url":"https://api.github.com/users/Tobion/events{/privacy}","received_events_url":"https://api.github.com/users/Tobion/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | yes\r\n| New feature?  | no\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets |\r\n| License       | MIT\r\n| Doc PR        | \r\n","created_at":"2015-09-17T01:43:56Z","updated_at":"2015-09-17T01:47:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cc770ff50bc4b5b909e706d8154d5a5563b34332","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/15821/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/15821/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/15821/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/a7b7f5479eabfe00c462fc7640d712ec99fdda5f","head":{"label":"Tobion:fix-memory-leak-event-dispatcher","ref":"fix-memory-leak-event-dispatcher","sha":"a7b7f5479eabfe00c462fc7640d712ec99fdda5f","user":{"login":"Tobion","id":610090,"avatar_url":"https://avatars.githubusercontent.com/u/610090?v=3","gravatar_id":"","url":"https://api.github.com/users/Tobion","html_url":"https://github.com/Tobion","followers_url":"https://api.github.com/users/Tobion/followers","following_url":"https://api.github.com/users/Tobion/following{/other_user}","gists_url":"https://api.github.com/users/Tobion/gists{/gist_id}","starred_url":"https://api.github.com/users/Tobion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tobion/subscriptions","organizations_url":"https://api.github.com/users/Tobion/orgs","repos_url":"https://api.github.com/users/Tobion/repos","events_url":"https://api.github.com/users/Tobion/events{/privacy}","received_events_url":"https://api.github.com/users/Tobion/received_events","type":"User","site_admin":false},"repo":{"id":2967822,"name":"symfony","full_name":"Tobion/symfony","owner":{"login":"Tobion","id":610090,"avatar_url":"https://avatars.githubusercontent.com/u/610090?v=3","gravatar_id":"","url":"https://api.github.com/users/Tobion","html_url":"https://github.com/Tobion","followers_url":"https://api.github.com/users/Tobion/followers","following_url":"https://api.github.com/users/Tobion/following{/other_user}","gists_url":"https://api.github.com/users/Tobion/gists{/gist_id}","starred_url":"https://api.github.com/users/Tobion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tobion/subscriptions","organizations_url":"https://api.github.com/users/Tobion/orgs","repos_url":"https://api.github.com/users/Tobion/repos","events_url":"https://api.github.com/users/Tobion/events{/privacy}","received_events_url":"https://api.github.com/users/Tobion/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Tobion/symfony","description":"The Symfony2 PHP framework","fork":true,"url":"https://api.github.com/repos/Tobion/symfony","forks_url":"https://api.github.com/repos/Tobion/symfony/forks","keys_url":"https://api.github.com/repos/Tobion/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Tobion/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Tobion/symfony/teams","hooks_url":"https://api.github.com/repos/Tobion/symfony/hooks","issue_events_url":"https://api.github.com/repos/Tobion/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/Tobion/symfony/events","assignees_url":"https://api.github.com/repos/Tobion/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/Tobion/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/Tobion/symfony/tags","blobs_url":"https://api.github.com/repos/Tobion/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Tobion/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Tobion/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/Tobion/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Tobion/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/Tobion/symfony/languages","stargazers_url":"https://api.github.com/repos/Tobion/symfony/stargazers","contributors_url":"https://api.github.com/repos/Tobion/symfony/contributors","subscribers_url":"https://api.github.com/repos/Tobion/symfony/subscribers","subscription_url":"https://api.github.com/repos/Tobion/symfony/subscription","commits_url":"https://api.github.com/repos/Tobion/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/Tobion/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/Tobion/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/Tobion/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/Tobion/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/Tobion/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Tobion/symfony/merges","archive_url":"https://api.github.com/repos/Tobion/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Tobion/symfony/downloads","issues_url":"https://api.github.com/repos/Tobion/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/Tobion/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/Tobion/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/Tobion/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Tobion/symfony/labels{/name}","releases_url":"https://api.github.com/repos/Tobion/symfony/releases{/id}","created_at":"2011-12-12T22:04:13Z","updated_at":"2015-03-19T19:30:34Z","pushed_at":"2015-09-17T01:42:39Z","git_url":"git://github.com/Tobion/symfony.git","ssh_url":"git@github.com:Tobion/symfony.git","clone_url":"https://github.com/Tobion/symfony.git","svn_url":"https://github.com/Tobion/symfony","homepage":"symfony.com","size":59026,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"symfony:2.3","ref":"2.3","sha":"4f9a411389efa940e6601c01860592f36d472f23","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","created_at":"2010-01-04T14:21:21Z","updated_at":"2015-09-16T21:05:53Z","pushed_at":"2015-09-17T01:43:56Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":241574,"stargazers_count":10791,"watchers_count":10791,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":4256,"mirror_url":null,"open_issues_count":926,"forks":4256,"open_issues":926,"watchers":10791,"default_branch":"2.8"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/15821"},"html":{"href":"https://github.com/symfony/symfony/pull/15821"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/15821"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/15821/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/15821/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/15821/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/a7b7f5479eabfe00c462fc7640d712ec99fdda5f"}}}}