Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86935 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36734 invoked from network); 29 Jun 2015 07:49:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jun 2015 07:49:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=anatol.php@belski.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=anatol.php@belski.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain belski.net from 85.214.73.107 cause and error) X-PHP-List-Original-Sender: anatol.php@belski.net X-Host-Fingerprint: 85.214.73.107 klapt.com Received: from [85.214.73.107] ([85.214.73.107:39810] helo=h1123647.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 64/77-29555-478F0955 for ; Mon, 29 Jun 2015 03:49:08 -0400 Received: by h1123647.serverkompetenz.net (Postfix, from userid 1006) id 8BAEA23D629F; Mon, 29 Jun 2015 09:49:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on h1123647.serverkompetenz.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.5 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable version=3.3.2 Received: from w530phpdev (pD9FE88C1.dip0.t-ipconnect.de [217.254.136.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by h1123647.serverkompetenz.net (Postfix) with ESMTPSA id 2FC4123D615B; Mon, 29 Jun 2015 09:49:03 +0200 (CEST) To: "'Nikita Popov'" , "'PHP internals'" , "'Dmitry Stogov'" References: In-Reply-To: Date: Mon, 29 Jun 2015 09:49:01 +0200 Message-ID: <020a01d0b240$12c42580$384c7080$@belski.net> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQHCfTnrlby6lsQua/jCkme7ZShgBZ3fgmNg Content-Language: en-us Subject: RE: [PHP-DEV] Allow exceptions in __toString() From: anatol.php@belski.net ("Anatol Belski") Hi Nikita, > -----Original Message----- > From: Nikita Popov [mailto:nikita.ppv@gmail.com] > Sent: Thursday, June 25, 2015 2:53 PM > To: PHP internals; Dmitry Stogov > Subject: [PHP-DEV] Allow exceptions in __toString() >=20 > Hi internals! >=20 > Currently it's not possible to throw an exception from __toString() - = instead you > will get a (real) fatal error. This is becoming more and more = problematic as time > goes on, e.g. with PHP 7 an exception can be triggered as a result of = a VM error > or even a parse error. >=20 > I'd like to lift this restriction. A patch can be found here: > https://github.com/php/php-src/pull/1364 >=20 > Apart from allowing exceptions, the patch also converts two leftover > recoverable fatal errors relating to __toString() into Error = exceptions. >=20 > Furthermore the patch makes sure that we correctly (i.e. without leaks = and > without superfluous notices or other side-effects) handle __toString() = exceptions > in the engine. This includes concatenation and interpolation, but also = things like > writing $foo->$object or ${$object}. > zend_parse_parameters() and Fast ZPP also deal with exceptions = correctly. >=20 > However what it doesn't do, and what I wouldn't consider feasible to = do, is > ensure that every single string conversion in library functions is = exception safe. > Personally I don't think this is a blocking issue, as the worst that = can happen is > usually an additional superfluous warning to be thrown, or something = similar. If > cases like this turn up, we can specifically target them. >=20 > It should also be noted that whatever issues with exceptions-safety = may remain, > they already exist now (plus those the patch fixes), because the two > aforementioned recoverable fatal errors can be converted to exceptions = (and > anyone doing blanket ErrorException conversions will do this). >=20 > So basically the question here is, is this partial solution acceptable = for us? >=20 Given the expressed concerns, despite the change itself is a good thing = when working properly, IMHO we shouldn't urge it into 7.0. If having it = now can lead to subtle improper behavior and even worse bugs, preferable = were to have a complete patch in 7.1. Regards Anatol