{"action":"created","issue":{"url":"https://api.github.com/repos/joomla-framework/di/issues/4","repository_url":"https://api.github.com/repos/joomla-framework/di","labels_url":"https://api.github.com/repos/joomla-framework/di/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/joomla-framework/di/issues/4/comments","events_url":"https://api.github.com/repos/joomla-framework/di/issues/4/events","html_url":"https://github.com/joomla-framework/di/issues/4","id":31221103,"number":4,"title":"Container::buildObject may result in infitite loop","user":{"login":"piotr-cz","id":612953,"avatar_url":"https://avatars2.githubusercontent.com/u/612953?v=4","gravatar_id":"","url":"https://api.github.com/users/piotr-cz","html_url":"https://github.com/piotr-cz","followers_url":"https://api.github.com/users/piotr-cz/followers","following_url":"https://api.github.com/users/piotr-cz/following{/other_user}","gists_url":"https://api.github.com/users/piotr-cz/gists{/gist_id}","starred_url":"https://api.github.com/users/piotr-cz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piotr-cz/subscriptions","organizations_url":"https://api.github.com/users/piotr-cz/orgs","repos_url":"https://api.github.com/users/piotr-cz/repos","events_url":"https://api.github.com/users/piotr-cz/events{/privacy}","received_events_url":"https://api.github.com/users/piotr-cz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2014-04-10T07:41:21Z","updated_at":"2018-02-25T16:35:26Z","closed_at":"2018-02-25T16:35:26Z","author_association":"CONTRIBUTOR","body":"The `buildObject` method [uses](https://github.com/joomla-framework/di/blob/master/src/Container.php#L142) `set` method at the bottom.\n\nIn specific case this may lead to infinite loop of\n`Joomla\\DI\\Container->buildObject()` and `Joomla\\DI\\Container->getMethodArgs()` methods resulting in \n`Fatal error: Maximum function nesting level of '100' reached, aborting!`\n\nBecause same key is being set in two places at a time:\n\n``` PHP\n$fqcn = '\\\\Extension\\\\vendor\\\\FooComponent\\\\FooComponent';\n$data = array();\n\n$container->set(\n    $fqcn,\n    function (Container $c) use ($fqcn, $data)\n    {\n        $instance = $c->buildObject($fqcn);\n        $instance->setData($data);\n\n        return $instance;\n    }\n);\n```\n\nI'm not sure if this is a bug (I'd say the `set` method shouldn't be part of the `buildObject`) or I misunderstood the functionality.\n"},"comment":{"url":"https://api.github.com/repos/joomla-framework/di/issues/comments/368323515","html_url":"https://github.com/joomla-framework/di/issues/4#issuecomment-368323515","issue_url":"https://api.github.com/repos/joomla-framework/di/issues/4","id":368323515,"user":{"login":"mbabker","id":368545,"avatar_url":"https://avatars2.githubusercontent.com/u/368545?v=4","gravatar_id":"","url":"https://api.github.com/users/mbabker","html_url":"https://github.com/mbabker","followers_url":"https://api.github.com/users/mbabker/followers","following_url":"https://api.github.com/users/mbabker/following{/other_user}","gists_url":"https://api.github.com/users/mbabker/gists{/gist_id}","starred_url":"https://api.github.com/users/mbabker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbabker/subscriptions","organizations_url":"https://api.github.com/users/mbabker/orgs","repos_url":"https://api.github.com/users/mbabker/repos","events_url":"https://api.github.com/users/mbabker/events{/privacy}","received_events_url":"https://api.github.com/users/mbabker/received_events","type":"User","site_admin":false},"created_at":"2018-02-25T16:35:26Z","updated_at":"2018-02-25T16:35:26Z","author_association":"OWNER","body":"Fixed via https://github.com/joomla-framework/di/commit/33c66e4091e4433f33ddf4a0ac36604cf3b73c41 for 1.x (by backporting appropriate changes from #16)."}}
{"actor":{"display_login":"mbabker"}}