Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97028 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82686 invoked from network); 19 Nov 2016 11:21:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2016 11:21:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.161.170 mail-yw0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:35981] helo=mail-yw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/E0-12687-A9530385 for ; Sat, 19 Nov 2016 06:20:59 -0500 Received: by mail-yw0-f170.google.com with SMTP id a10so180239359ywa.3 for ; Sat, 19 Nov 2016 03:20:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0XECkOaNbZuHeSYKMfM5YJ1wp2GfAQVoAXbagDtSaF4=; b=ClQgwmiDmSj0NcxHYS4CV3FF/X82Xu/o+qZi5wp4TubQIe1dZVS1bypw/ad0CwP0Z7 uVBrV40AF37NSQnjH3futSN9hb9H2LPBQWWJEsVbfBn8vUkmUc0iMywQVIxQm3azO3tf fqxslgCxPr+DenAo03Encjc0N9HIYlcM3As8NuEu64r6Z4vhfohOJNgk9IStq4AJVHtT +CedX+cgkJmczcmxaU9TvABPNh/B422Zb2VlWIn3b1X/kccopMMF5S+Cx4gic4QF9syD khUKcgFnO0SuCDvndL6DfVdPe/AXHYDsMGGaffybpEbrjH+w3FFDwrAVT9v0TXJ7sGAs XV9g== 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; bh=0XECkOaNbZuHeSYKMfM5YJ1wp2GfAQVoAXbagDtSaF4=; b=ZmBOTLZY4hhrCZt3oZ1x1xzQ0uZZoUP2QRa8oH5ZvS+AJvFG/Oyxb3P2D7WmXf5StT 9MYNdmwV/ptXZNcE2axiFJaWmTyRP3B0mPnRI2714nH3lH/LNAuwRwMkWBjLhvSP9Dj3 tuCZ3fF9gXdZuJ7ZGWhvuOUoN8X7vN2AsIkktHnMO3NiByN5lLb7UIfEYovmB8+LlTGI ZgWkU5kuvgCq5d5yadQQda8bpK6itzr+g5hn4ZIFAFZXZPZrPtji7z6fWLUj0iNqO3sR PSyAVE9ptL7TBbdQUUnSHZAfxz+sMI261ICelrneuOePJwMIuCLbqYQHHKgsw6dyarN+ 1liA== X-Gm-Message-State: AKaTC00g2qFMwnJGUuh1gZc2laQ9Za938AMEcD5DEq4Y3jfJyKADDGB7gyZdv+/AUOQn0HzZZTlD3l0QtTEs0A== X-Received: by 10.13.225.132 with SMTP id k126mr3918790ywe.40.1479554456214; Sat, 19 Nov 2016 03:20:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.83.67.21 with HTTP; Sat, 19 Nov 2016 03:20:55 -0800 (PST) In-Reply-To: <3B.50.06670.2F620385@pb1.pair.com> References: <3B.50.06670.2F620385@pb1.pair.com> Date: Sat, 19 Nov 2016 12:20:55 +0100 Message-ID: To: Tony Marston Cc: PHP internals Content-Type: multipart/alternative; boundary=94eb2c07709ac9e2930541a59dbf Subject: Re: [PHP-DEV] Re: [RFC] Deprecations for PHP 7.2 From: nikita.ppv@gmail.com (Nikita Popov) --94eb2c07709ac9e2930541a59dbf Content-Type: text/plain; charset=UTF-8 On Sat, Nov 19, 2016 at 11:18 AM, Tony Marston wrote: > "Nikita Popov" wrote in message news:CAF+90c8Wox0wadAVPsP83er= > G9jbW__26yBWOFAsjB09rYVFJA@mail.gmail.com... > > >> Hi internals! >> >> I've submitted this RFC for PHP 7.1 previously, but didn't follow through >> due to time constraints. Now I'd like to propose an extended version for >> PHP 7.2 and vote on it sooner rather than later to avoid a repeat >> performance. >> >> https://wiki.php.net/rfc/deprecations_php_7_2 >> >> The RFC combines a number of deprecation and removal proposals. Each one >> will get a separate 2/3 majority vote. The RFC overlaps with some recently >> discussed topics (each, binary strings) -- I'm fine with dropping these if >> someone has a more specific RFC. >> >> I expect some of these are no-brainers, while others are more >> controversial >> -- please share your specific concerns. >> >> Thanks, >> Nikita >> > > I am against the removal of the $errorcontext argument of error handler as > this has been a valuable part of my error handler for over ten years. > Whenever trigger_error() is called with a fatal error I write all available > details to a log file as well as sending an email. In order to obtain > additional data I use errorcontext to determine the following: > > a) Was it called from a function or an object? For this I use code such as > the following: > > if (isset($errcontext['this']) AND is_object($errcontext['this'])) { > > b) If it was called from an object, was it one of my database objects? If > yes, then obtain some extra information using code such as the following: > > // retrieve error details from DML object > if (method_exists($errcontext['this'], 'getQuery')) { > $query = $errcontext['this']->getQuery(); > } // if > if (method_exists($errcontext['this'], 'getErrorNo')) { > $errno = $errcontext['this']->getErrorNo(); > } // if > if (method_exists($errcontext['this'], 'getErrorString')) { > $errstr = $errcontext['this']->getErrorString(); > } // if > if (method_exists($errcontext['this'], 'getErrorString2')) { > $errstr2 = $errcontext['this']->getErrorString2(); > } // if > I'm afraid you're out of luck here :/ This usage will no longer be possible as of PHP 7.1 -- independently of the deprecation proposed in this RFC. See: https://3v4l.org/sQBL9 Prior to PHP 7.1 $this was *sometimes* included in the symbol table (to be more precise, whenever $this was used as a CV, rather than implicit UNUSED operand). As of PHP 7.1 $this is never included in the symbol table. This change is due to https://wiki.php.net/rfc/this_var. But! This functionality is still available through debug_backtrace(). That's the correct way of fetching the $this of a parent frame, which should always work (rather than *sometimes* on PHP < 7.1), and is independent of the error handling mechanism. So, to clarify: Is $this the only thing from the error context you're interested in? Or do you also use all the other variables? > Saying that I should stop using $errorcontext and instead use a debugger > is very short sighted. I *NEED* to have this data available in the error > log as soon as the error happens. In several cases I cannot use a debugger > as my application is running behind a client's firewall and their security > restrictions forbid the use of a debugger from outside of that firewall. > I notice that the reason for this recommendation is "because the > $errcontext can be used to modify all references and objects in the current > scope." If this is the case then why not make $errorcontext read-only so > that nothing can be changed. I can imagine lots of people reading from > $errorcontext, but how many actually write? I certainly don't. We can do this for references (i.e., dereference them for the provided symbol table), but not for objects, because we don't have any way of enforcing immutability on the language side. Thanks, Nikita --94eb2c07709ac9e2930541a59dbf--