Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86865 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90813 invoked from network); 25 Jun 2015 14:32:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jun 2015 14:32:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.213.177 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.213.177 mail-ig0-f177.google.com Received: from [209.85.213.177] ([209.85.213.177:34898] helo=mail-ig0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/A1-16095-6F01C855 for ; Thu, 25 Jun 2015 10:32:23 -0400 Received: by igblr2 with SMTP id lr2so98279657igb.0 for ; Thu, 25 Jun 2015 07:32:20 -0700 (PDT) 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:date :message-id:subject:from:to:cc:content-type; bh=YkqZyldoxeYTZ+/7m7bl3+Jxxs/KCDrXxiMmCzIq4y0=; b=h8t0yp3K6AYuI1Fg+dPtH/0KIz2rvJgZHc0c66AX1cdgXgyDFG4SJ+G2pxlpLPl8SW Uoi8s5v/nm5K78mkHubVGIgiRjroIyg60gZnkzcZZ7qVy+YtdXzkAKwfO/1TmBRHKMJA BvjyXvb/HCu8ZBcJT0j0zUDB66N9r6EpzxrcBXYKdNyou/0K+f/wy3w9wOeI/NgpQPAM uk15cKsfIupfZQGBj3OIHSzHdGlx4oXr/afLQYsvPzv5Su9/y/ubnRi1H3QRR16IX1jz WF0UuGCUYxHQHKNctlTa/c+GDOJvO/AAsjFbAaxxaeaiFAmJFcTYhBzVP0kLD29ejrmb y5Hg== X-Gm-Message-State: ALoCoQnjMzcZPiQPdxiXn4qzIXLXmG4HRFtb6AESPKonEP5keOBnjKkBasR/M0VzkPxvTC2p18QPBlb9l+cw0vVEAb1bOYYtRxxOaANoey8J/icN0xjL+TuvchRIo7K6wJyKeiE3abKpOuDGLP4MrJZNoTxWRI5VZlIrqGCNcrbT6ybA4G+fvCs= MIME-Version: 1.0 X-Received: by 10.43.24.134 with SMTP id re6mr25021029icb.74.1435242740267; Thu, 25 Jun 2015 07:32:20 -0700 (PDT) Received: by 10.50.51.161 with HTTP; Thu, 25 Jun 2015 07:32:20 -0700 (PDT) In-Reply-To: <1435240516.15676.7.camel@kuechenschabe> References: <1435240516.15676.7.camel@kuechenschabe> Date: Thu, 25 Jun 2015 17:32:20 +0300 Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=bcaec51d2350b361650519587d05 Subject: Re: [PHP-DEV] Allow exceptions in __toString() From: dmitry@zend.com (Dmitry Stogov) --bcaec51d2350b361650519587d05 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Jun 25, 2015 at 4:55 PM, Johannes Schl=C3=BCter wrote: > On Thu, 2015-06-25 at 14:52 +0200, Nikita Popov wrote: > > 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 t= he > > worst that can happen is usually an additional superfluous warning to b= e > > thrown, or something similar. If cases like this turn up, we can > > specifically target them. > > I don't agree to the assesment that this isn'T a problem. Consider this > extension pseudo-code: > > > zval *data =3D get_data(); > convert_to_string(data); > store_into_database(Z_STRVAL_P(data)); > return TRUE; > > This will store wrong data in the database and report to the user that > there was an error before storing, so the user assumes nothing was > stored. > We have hundreds such cases :( > The only way we can do that imo is by bailing out if an exception is > thrown and introducing yet another set of string conversion functions > for marking exception safe uses. (i.e. convert_to_string_throwing()) > This may lead to memory and resource leaks. In general, we may throw exceptions, only from "safe" places, but this going to make a mesh. Thanks. Dmitry. > > johannes > > > > --bcaec51d2350b361650519587d05--