Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80970 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94474 invoked from network); 22 Jan 2015 10:42:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jan 2015 10:42:30 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.173 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.216.173 mail-qc0-f173.google.com Received: from [209.85.216.173] ([209.85.216.173:33330] helo=mail-qc0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 19/06-61273-514D0C45 for ; Thu, 22 Jan 2015 05:42:29 -0500 Received: by mail-qc0-f173.google.com with SMTP id m20so532004qcx.4 for ; Thu, 22 Jan 2015 02:42:26 -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=Gitpt5sAmie5a8M73ZGSKvj0AfNPsvTp9JuY7mJ8ceQ=; b=eDH8cU1Fy3xdBDPyt8vNr75dq1740l8ttFplb3EAv0D+njkz5vCNPuoS9C40mD06pz 97cnu5GpFaJRhshzMD+84/vM4Z+SGVrUW7Jq4nnvAF+SlXQNHoTGl3nY6Gp9Tkg6eIjR 8BiT5xl6ozKBw+9FyWZrecTNeOjN1gQrPrwqKY8R+giWWGTTU6HaMGvQWYqUX0CGqQO7 SniFqvXTeeXl8YZsg/fAU/nCP8Q39id8V4Za56AbZtxt89e2kQkBMur9aId3JGOsfJ5g etjM1vtdEzwAdopardtKEI1BwLvBxIw9IMQKpHzQIjMa7Y+p0jzpEFY+2Ezaqd3em/vM XZRg== X-Received: by 10.140.90.112 with SMTP id w103mr968001qgd.65.1421923346614; Thu, 22 Jan 2015 02:42:26 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.93.70 with HTTP; Thu, 22 Jan 2015 02:41:46 -0800 (PST) In-Reply-To: <20150121043939.5129B26183A@dd15934.kasserver.com> References: <20150121043939.5129B26183A@dd15934.kasserver.com> Date: Thu, 22 Jan 2015 19:41:46 +0900 X-Google-Sender-Auth: 10t3BpOIkcDc7IghGqehoCRQvS8 Message-ID: To: Thomas Bley Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c11a98f913d7050d3b5332 Subject: Re: [PHP-DEV] Enable error_handler callback parameters to be passed by reference From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c11a98f913d7050d3b5332 Content-Type: text/plain; charset=UTF-8 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 --001a11c11a98f913d7050d3b5332--