Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90490 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17595 invoked from network); 11 Jan 2016 14:00:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jan 2016 14:00:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=markus@fischer.name; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=markus@fischer.name; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fischer.name from 62.179.121.35 cause and error) X-PHP-List-Original-Sender: markus@fischer.name X-Host-Fingerprint: 62.179.121.35 fep15.mx.upcmail.net Solaris 10 (beta) Received: from [62.179.121.35] ([62.179.121.35:43322] helo=fep15.mx.upcmail.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1C/87-64385-B65B3965 for ; Mon, 11 Jan 2016 09:00:12 -0500 Received: from edge03.upcmail.net ([192.168.13.238]) by viefep15-int.chello.at (InterMail vM.8.01.05.18 201-2260-151-151-20140610) with ESMTP id <20160111140008.YERX29385.viefep15-int.chello.at@edge03.upcmail.net> for ; Mon, 11 Jan 2016 15:00:08 +0100 Received: from mail02.home ([213.47.8.56]) by edge03.upcmail.net with edge id 4e081s00g1CY7x901e081Z; Mon, 11 Jan 2016 15:00:08 +0100 X-SourceIP: 213.47.8.56 Received: from mail02.home ([192.168.1.14] helo=[IPv6:::1]) by mail02.home with esmtp (Exim 4.72) (envelope-from ) id 1aId0w-0005Co-Q8 for internals@lists.php.net; Mon, 11 Jan 2016 15:00:08 +0100 To: internals@lists.php.net References: Message-ID: <5693B566.6060908@fischer.name> Date: Mon, 11 Jan 2016 15:00:06 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam_report: Spam detection software, running on the system "scanner01.home", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Dear Giovanni, I brought this up last July, see https://bugs.php.net/bug.php?id=70050 ; because in a few code bases I tested back then, this was the first issue I hit. Unfortunately, it was only deemed a "Documentation Problem" back then. AFAIK this is the most up to date information. Sorry I don't have further news. [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: php.net] -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: Re: [PHP-DEV] Throwable and Error exceptions break existing PHP 5.x code From: markus@fischer.name (Markus Fischer) Dear Giovanni, I brought this up last July, see https://bugs.php.net/bug.php?id=70050 ; because in a few code bases I tested back then, this was the first issue I hit. Unfortunately, it was only deemed a "Documentation Problem" back then. AFAIK this is the most up to date information. Sorry I don't have further news. cheers, - Markus On 11.01.16 14:31, Giovanni Giacobbi wrote: > Greetings, > > Short premise before I get flamed: I know PHP 7 is rolling and it is way > too late for this, that I should've tested the RCs, follow the mailing list > and so on, but I'm a dev like you guys and struggle with the time to do > everything by the book, including reading the previous threads because I'm > pretty sure this was brought up by somebody, but as there are hundreds of > message under the "Throwable" topic and I can't read all of them. > > In short I have this situation: > > class SpecificHandler { > public function exception(Exception $e) { > .. do something very useful... > } > } > > function global_handler($e) { > SpecificHandler::exception($e); > } > > set_exception_handler("global_handler"); > ?> > > This happens because the specific handler will output the exception > according to the expected format (HTML, JSON, or even an image). > > Now after upgrading to PHP7 when one of the new Error exception is thrown, > I get the following error: > > PHP Fatal error: Uncaught TypeError: Argument 1 passed to > SpecificHandler::exception() must be an instance of Exception, instance of > Error given, called in [...] > > Having been a PHP dev for 10 years now I know that the policy is to try to > break as little as possible while implementing new features, and I like > that. I know that sometimes things must be broken to progress, but in this > case maybe there is a very simple fix that I can suggest to avoid breaking > existing code, change set_handler_exception like this: > > set_exception_handler(callback function, bool also_throwables = false); > > The new parameter "also_throwables" defaults to false, so the same > behaviour as before is preserved. If you want it to catch also the new PHP7 > Error exceptions, you can just set it to true. > > What is your take on this? I know I can easily fix my code to work on both > PHP 5.x and PHP 7.x, but I really disliked this kind of BC. > > Kind regards > Giovanni >