Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81285 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98269 invoked from network); 28 Jan 2015 06:30:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2015 06:30:49 -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:56328] helo=dd15934.kasserver.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/88-45774-61288C45 for ; Wed, 28 Jan 2015 01:30:46 -0500 Received: from dd15934.kasserver.com (dd0802.kasserver.com [85.13.143.1]) by dd15934.kasserver.com (Postfix) with ESMTPSA id 9071D26187F; Wed, 28 Jan 2015 07:30:42 +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 To: laruence@php.net Cc: yohgaki@ohgaki.net, internals@lists.php.net, nicolas.grekas+php@gmail.com, reeze@php.net Message-ID: <20150128063042.9071D26187F@dd15934.kasserver.com> Date: Wed, 28 Jan 2015 07:30:42 +0100 (CET) Subject: Re: [PHP-DEV][RFC] Enable error_handler callback parameters to be passed by reference From: mails@thomasbley.de ("Thomas Bley") >> Request-Uri: /custom/foobar >> Request-Params: {"action":"edit"} > actually, this should already be in access.log(the last 500 error > one)...... I don't see why you need it in error log.... Sorry, my example is not precise enough. Normally, $_POST, $_SESSION['username'] and php://input are not part of access.log. So having ajax requests with all kinds of inputs makes things more difficult. Parsing complete access logs can be quite slow and logging php://input for every request might not be possible in most cases. Regards Thomas Xinchen Hui wrote on 28.01.2015 07:15: > On Wed, Jan 28, 2015 at 2:11 PM, Thomas Bley wrote: >> 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: >> >> > ini_set('error_reporting', E_ALL); >> ini_set('display_errors', 0); >> ini_set('log_errors', 1); >> ini_set('error_log', 'php_error.log'); >> ini_set('date.timezone', 'Europe/Berlin'); >> ini_set('memory_limit', '16M'); >> >> $_SERVER['HTTP_HOST'] = 'mywebsite.com'; >> $_SERVER['REQUEST_URI'] = '/custom/foobar'; >> $_REQUEST = array('action' => '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"} > actually, this should already be in access.log(the last 500 error > one)...... I don't see why you need it in error log.... > > thanks >> >> >> 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/