Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81284 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96400 invoked from network); 28 Jan 2015 06:15:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2015 06:15:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=xinchen.h@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.215.49 as permitted sender) X-PHP-List-Original-Sender: xinchen.h@zend.com X-Host-Fingerprint: 209.85.215.49 mail-la0-f49.google.com Received: from [209.85.215.49] ([209.85.215.49:56875] helo=mail-la0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A3/38-45774-48E78C45 for ; Wed, 28 Jan 2015 01:15:32 -0500 Received: by mail-la0-f49.google.com with SMTP id gf13so17120869lab.8 for ; Tue, 27 Jan 2015 22:15:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=JuCBLVv5lRNT1NBqKhw4Fer1KMJtsJ9wypOOFrWNuRI=; b=MWdNv/e2edCbBiy2YxRMbJ/HDTOakTTTR8757VpkTtaXfk8MlZKG36WrpSvcKgFl9z DLzUilPjAJ59b/W8vQU51c7Ku/Ha9Yd5ktqYNMeCuudZ+JsBgUIt1dmuQB/VtQaHF2cJ jjuSz4r1Rp0RNxi1mvGGgw8L3aG0GIbElVT7S8punRnAGjmo12KE7KjKKyDw1DUBe/av ZNIzf85neGxWUCQ3o2bbjwFV/jj/0Obnr2Jx5fsz3F30sbY7rAHYZ7MLdjfYLvHEb6gw 5X6NQsrIDh+ozRAaVSqpSg3G39vuknAo6Sx9eC7w8tJFFF+dXzVrLI6BovLUuwyV9486 4jRg== X-Gm-Message-State: ALoCoQmg+FhZpcZQXKinaSbaNvHZQEyrqt+SqYsF2vUwcnGw4uluC55EoZgrFpIBkS6Eb0SNOybO/G0S1IWVrIYV3yFYJgzOy734aL7IdGxJo1vghhcJMdrI7V9C6cNGETLRJ3dsl7X4O3+P702xMw8PEwpGxLf7Eg== X-Received: by 10.112.222.135 with SMTP id qm7mr5818903lbc.19.1422425728908; Tue, 27 Jan 2015 22:15:28 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPSA id pg3sm1057302lbb.8.2015.01.27.22.15.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 22:15:28 -0800 (PST) Received: by mail-lb0-f175.google.com with SMTP id 10so16941303lbg.6 for ; Tue, 27 Jan 2015 22:15:27 -0800 (PST) X-Received: by 10.152.28.37 with SMTP id y5mr5874256lag.55.1422425727042; Tue, 27 Jan 2015 22:15:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.114.28.193 with HTTP; Tue, 27 Jan 2015 22:15:06 -0800 (PST) In-Reply-To: <20150128061137.CCF9726187F@dd15934.kasserver.com> References: <20150127024521.3689F2618FD@dd15934.kasserver.com> <20150128061137.CCF9726187F@dd15934.kasserver.com> Date: Wed, 28 Jan 2015 14:15:06 +0800 Message-ID: To: Thomas Bley Cc: Yasuo Ohgaki , PHP Internals , nicolas.grekas+php@gmail.com, reeze@php.net Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV][RFC] Enable error_handler callback parameters to be passed by reference From: laruence@php.net (Xinchen Hui) 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/ >> > -- Xinchen Hui @Laruence http://www.laruence.com/