Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81283 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94902 invoked from network); 28 Jan 2015 06:11:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2015 06:11:46 -0000 Authentication-Results: pb1.pair.com header.from=mails@thomasbley.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=mails@thomasbley.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain thomasbley.de from 85.13.137.24 cause and error) X-PHP-List-Original-Sender: mails@thomasbley.de X-Host-Fingerprint: 85.13.137.24 dd15934.kasserver.com Received: from [85.13.137.24] ([85.13.137.24:55880] helo=dd15934.kasserver.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/D7-45774-C9D78C45 for ; Wed, 28 Jan 2015 01:11:41 -0500 Received: from dd15934.kasserver.com (dd0802.kasserver.com [85.13.143.1]) by dd15934.kasserver.com (Postfix) with ESMTPSA id CCF9726187F; Wed, 28 Jan 2015 07:11:37 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-SenderIP: 95.90.232.102 User-Agent: ALL-INKL Webmail 2.11 In-Reply-To: References: <20150127024521.3689F2618FD@dd15934.kasserver.com> To: yohgaki@ohgaki.net, laruence@php.net Cc: internals@lists.php.net, nicolas.grekas+php@gmail.com, reeze@php.net Message-ID: <20150128061137.CCF9726187F@dd15934.kasserver.com> Date: Wed, 28 Jan 2015 07:11:37 +0100 (CET) Subject: Re: [PHP-DEV][RFC] Enable error_handler callback parameters to be passed by reference From: mails@thomasbley.de ("Thomas Bley") There are some workarounds with register_shutdown_function to extend E_ERROR messages, but I think that's quite dirty in a system with many parallel requests. Here is an example: 'edit'); function check_for_fatal() { $error = error_get_last(); if ($error['type'] == E_ERROR) { $errstr = ''; if (!empty($_SERVER['REQUEST_URI'])) { $errstr .= ' Request-Uri: '.$_SERVER['REQUEST_URI'].PHP_EOL; } $errstr .= ' Request-Params: '.json_encode($_REQUEST); file_put_contents('php_error.log', $errstr. PHP_EOL, FILE_APPEND); } } register_shutdown_function('check_for_fatal'); $str = str_repeat('##########', 2*1024*1024); gives: [28-Jan-2015 07:00:53 Europe/Berlin] PHP Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 20971521 bytes) in test.php on line 27 Request-Uri: /custom/foobar Request-Params: {"action":"edit"} Regards Thomas Xinchen Hui wrote on 27.01.2015 13:26: > Hey: > > On Tue, Jan 27, 2015 at 11:08 AM, Yasuo Ohgaki wrote: >> Hi Thomas, >> >> On Tue, Jan 27, 2015 at 11:45 AM, Thomas Bley wrote: >> >>> Here is the rfc: >>> >>> https://wiki.php.net/rfc/error_handler_callback_parameters_passed_by_reference >>> >>> Thanks to reeze for coding and putting it on the wiki. >>> >> >> It looks good to me. >> >> Future Scope >> set_error_handler() callback might be able to handle E_ERROR to be able to >> append additional information to memory_limit exhaustions (or others). >> >> I really want to catch E_RROR by user defined error handler. The only >> reason why this was disabled is abuse of error handler. We may document >> abuse of error handler with E_ERROR may result in undefined behavior >> including memory leak/crash and allow it. > I feel it's kindof wrong direction. > > if you want custom logs, maybe you should use custom logger. > > thanks >> >> Regards, >> >> -- >> Yasuo Ohgaki >> yohgaki@ohgaki.net > > > > -- > Xinchen Hui > @Laruence > http://www.laruence.com/ >