Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80976 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20247 invoked from network); 22 Jan 2015 16:01:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jan 2015 16:01:52 -0000 Authentication-Results: pb1.pair.com header.from=reeze.xia@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=reeze.xia@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.182 as permitted sender) X-PHP-List-Original-Sender: reeze.xia@gmail.com X-Host-Fingerprint: 209.85.212.182 mail-wi0-f182.google.com Received: from [209.85.212.182] ([209.85.212.182:59015] helo=mail-wi0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9F/69-61273-EEE11C45 for ; Thu, 22 Jan 2015 11:01:51 -0500 Received: by mail-wi0-f182.google.com with SMTP id n3so4394005wiv.3 for ; Thu, 22 Jan 2015 08:01:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=oh3jmkdgjjD8OcDaFpFjHgQUb0Ktvn/NZZnW5REUcaI=; b=B1wU0z04ns548wf3KCi49g6aPLJgnCfaq2BlfQ6ss9jspkJqDXllmDfcRLxW+doc3g 0aC5efJFFLbYDon0H6vLKttBEvjJPk4iTOrz9MPcopJcoU+pebGC8KYGjCDcFOqzisL5 hMCN05trPo8dyTJI4yXpbl+Lr0KLMAaLn2lI4QPb/xgzPguYPaxUCqkd78jWle7cfMRv ZcXplqLiCmxr12sd3WpgBh9qVsWaMQeVz/uw6NF5oFdcjw8jIxKFdv6QHU5LAbL+ZwyT VJZAh4sx8+jDa4k5EDqfRRnnc30pq28KG3wlwUJwsIaB/kBvW9SzGi021Rq54zPv/0Ku ZFfQ== X-Received: by 10.180.182.72 with SMTP id ec8mr6555378wic.53.1421942507762; Thu, 22 Jan 2015 08:01:47 -0800 (PST) MIME-Version: 1.0 Sender: reeze.xia@gmail.com Received: by 10.195.12.163 with HTTP; Thu, 22 Jan 2015 08:01:27 -0800 (PST) In-Reply-To: References: <20150121043939.5129B26183A@dd15934.kasserver.com> Date: Fri, 23 Jan 2015 00:01:27 +0800 X-Google-Sender-Auth: 9NQNARbJ8LS0SCXAbXHPyMou76c Message-ID: To: Yasuo Ohgaki Cc: Thomas Bley , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7b62494210fb91050d3fca86 Subject: Re: [PHP-DEV] Enable error_handler callback parameters to be passed by reference From: reeze@php.net (reeze) --047d7b62494210fb91050d3fca86 Content-Type: text/plain; charset=ISO-8859-1 I like the idea, we have the similar scenario, we need to print request log id to the log, so I just made a PR to implement this: https://github.com/php/php-src/pull/1018 the PR is against master, but I think this could also been in 5.5. On 22 January 2015 at 18:41, Yasuo Ohgaki wrote: > Hi Thomas, > > On Wed, Jan 21, 2015 at 1:39 PM, Thomas Bley wrote: > > > In userland it is sometimes necessary to extend PHP's notices/warnings > > with additional information (e.g. username from session, stack trace, > etc.) > > I'm proposing to enable error_handler callback parameters to be passed by > > reference to be able to append additional data to error messages. > > > > Example: > > > > > ini_set('error_reporting', E_ALL); > > ini_set('display_errors', 0); > > ini_set('log_errors', 1); > > ini_set('error_log', 'php_error.log'); > > > > function myErrorHandler($errno, &$errstr, $errfile, $errline) { > > if (!empty($_SESSION['username'])) { > > $errstr .= ', username: '.$_SESSION['username']; > > } > > return false; // continue normal error handler > > } > > > > set_error_handler("myErrorHandler"); > > > > function test() { > > echo tests; // Use of undefined constant tests > > } > > > > test(); > > > > Gives in php_error.log: > > [21-Jan-2015 04:32:26 UTC] PHP Notice: Use of undefined constant tests - > > assumed 'tests', username: ... in error.php on line 17 > > > > Instead of: > > [21-Jan-2015 04:32:26 UTC] PHP Notice: Use of undefined constant tests - > > assumed 'tests' in error.php on line 17 > > > > This would be very useful for accounting! > If you cannot send pull requests, please file this to bugs.php.net as > request. > > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > --047d7b62494210fb91050d3fca86--