Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81028 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62349 invoked from network); 23 Jan 2015 07:46:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jan 2015 07:46:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=mails@thomasbley.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=mails@thomasbley.de; 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:57097] helo=dd15934.kasserver.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/A3-61273-65CF1C45 for ; Fri, 23 Jan 2015 02:46:31 -0500 Received: from dd15934.kasserver.com (dd0802.kasserver.com [85.13.143.1]) by dd15934.kasserver.com (Postfix) with ESMTPSA id 5F0CF2607D0; Fri, 23 Jan 2015 08:46:27 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-SenderIP: 178.2.18.135 User-Agent: ALL-INKL Webmail 2.11 In-Reply-To: References: <20150121043939.5129B26183A@dd15934.kasserver.com> To: yohgaki@ohgaki.net, reeze@php.net Cc: internals@lists.php.net Message-ID: <20150123074627.5F0CF2607D0@dd15934.kasserver.com> Date: Fri, 23 Jan 2015 08:46:27 +0100 (CET) Subject: Re: [PHP-DEV] Enable error_handler callback parameters to be passed by reference From: mails@thomasbley.de ("Thomas Bley") Thanks I'll draft a RFC during the weekend. Regards Thomas reeze wrote on 22.01.2015 17:01: > 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 > >