{"action":"opened","issue":{"number":45,"created_at":"2011-10-17T15:44:49Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Scope of Change\n====\nIn case the same PHP error occurs multiple times, it will no longer be \nadded to the error registry on each occurence. Instead, a counter will \nkeep track how many times this error has occured.\n\n\nRationale\n====\nPrevent running out of memory in a situation where a loop is causing\nan error in each of its iterations.\n\n\nFunctionality\n====\n\nTake the following script:\n\n```php\n<?php\n  for ($i= 0; $i < 1000; $i++) {\n    $a.= '';    // E_NOTICE: Undefined variable:  a\n    unset($a);\n  }\n?>\n```\n\nAt the moment of writing this RFC, this will cause 1000 new elements to\nbe added to the xp error registry. When the changes this RFC suggests\nare implemented, this will result in 1 element being added to the error\nregistry and its occurrence counter being equal to 1000.\n\nNow if an exception is thrown from somewhere in this block, you'd get a \nreally long stacktrace containing all the E_NOTICEs from the loop:\n\n```\nException lang.Exception ()\n  at lang.Exception::__construct((0x0)'') [line 87 of StackTraceElement.class.php] \n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a\n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a\n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a\n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a\n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a\n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a\n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a\n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a\n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a\n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a\n\n```\n(shortened for brevity)\n\nWith this patch, the stacktrace will look like this:\n\n```\nException lang.Exception ()\n  at lang.Exception::__construct((0x0)'') [line 0 of StackTraceElement.class.php] \n  at php.<main>::<main>() [line 5 of st.php] Undefined variable:  a (... 999 more)\n\n```\nPlease note the \"... 999 more\" indicating this error has occured a total of 1000 \ntimes.\n\nSecurity considerations\n====\nn/a\n\n\nSpeed impact\n====\n- Possible slight decrease in error handler\n\nBut:\n- Memory footprint decrease in error handler at the same time\n\n- Performance increase in xp::errorAt() for the case file *and* line\n  number are passed in\n\n- Performance increase in lang.StackTraceElement's toString() method\n\nOver all, this should be slightly faster for the general case.\n\n\nDependencies\n====\nThis introduces a small BC break in lang.StackTraceElement: The member\n$messages (an array) is replaced by a member $message (a string).\n\n\nRelated documents\n====\n- http://xp-framework.net/class/net.xp_framework.unittest.core.ErrorsTest\n  Unittest that ensures new behaviour doesn't introduce any other \n  unwanted changes or side-effects\n\n- http://xp-framework.net/downloads/rfc0045.diff\n  Patch implementing this RFC\n\n\n","comments":0,"title":"Unique multiple occurrences of errors","updated_at":"2011-10-17T15:44:50Z","url":"https://api.github.com/repos/xp-framework/rfc/issues/45","id":1929992,"assignee":null,"milestone":null,"closed_at":"2011-10-17T15:44:50Z","user":{"gravatar_id":"26f07e3b262e9a80436f368cb11bd0c2","avatar_url":"https://secure.gravatar.com/avatar/26f07e3b262e9a80436f368cb11bd0c2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/thekid","id":696742,"login":"thekid"},"html_url":"https://github.com/xp-framework/rfc/issues/45","labels":[{"name":"framework","url":"https://api.github.com/repos/xp-framework/rfc/labels/framework","color":"118f5b"},{"name":"implemented","url":"https://api.github.com/repos/xp-framework/rfc/labels/implemented","color":"807370"}],"state":"closed"},"legacy":{"number":45,"action":"opened","issue":1929992}}