Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105719 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40044 invoked from network); 15 May 2019 21:54:48 -0000 Received: from unknown (HELO mail-lf1-f53.google.com) (209.85.167.53) by pb1.pair.com with SMTP; 15 May 2019 21:54:48 -0000 Received: by mail-lf1-f53.google.com with SMTP id n22so613731lfe.12 for ; Wed, 15 May 2019 12:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7vsORfjtYZ7XHWFXeClvDFjCXj4nbonaxE1nrFvlrCc=; b=NMNVKBs3uP9fZ0M0awS4u8YvQSVpvMHnAiCUyh1K/v8TikAXahgKxLBIQ67SwIV5ea 5z9GxQE4An4sdz/SSrGxzNmsAa2LCh4deVw4NjfhutHm/rIly1voUQjPbDJf1tDPZa33 l2UqEatp9LET37LpnQWZV7Sm7j0WH/6mfsAXuCa87UrGIos2UVKb0cbyFv8BqphhVPEB ZBWTE4PdOhFylFLZUJN7aWFISSHKoe1lrTI1oqUUXWaKOnUQVJab0JbH7aY1empjHzQD lg1gCt7ORdnewtrZAktiZDO9Xc5kL+m6wBkq9rDTgboH8LOr1TMBVSA4sKrR0IyT7DLn QUTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7vsORfjtYZ7XHWFXeClvDFjCXj4nbonaxE1nrFvlrCc=; b=pyBV+ueKRKsRW+vK8aK5dFv7kt7XFBgDahj5MqxOWBcctarsRmRg9vaZ7EwUVFMiuG ysJ+ZXywjMLFw/TRt/2HuqM5cxMT3lZt5M0SiyUfCBwTtMhh2BhivoPKAYASiUICyWL2 69HzLcm4H0gFt1SnhQqsS+hYnCiL9aCbb1T7ByO4b9L15KOnAfnDapNkePcFN0h5s9V8 2YjWifIu2VnSzWUb52emkt8BC3Nku0L1HrjjZxFR7mtHjYYCocAO4G3e1cQ0dZ3xcMCx oNC5lSgZX6qOIPgZCVSEqsMfjiB2ltRYR6X/dtGh0EThqdhA1wg/O+l2tl78onLwzbXT BNIw== X-Gm-Message-State: APjAAAXBC4DCKw4GJ2+F4qZh0Z001xpObmqY/Ay2TKFeiBc8FttFWfnY p+f32bgB2MMV0GIky7oEEwtKrpCzQH0vW+r0mvKGIRfXh48= X-Google-Smtp-Source: APXvYqxeM+uxPA4YWwJxvPEgsDhbgiX5gRdqrFdFw9Irqj3YZ0rx7rIGwI7MNPXuOz3jnYVFkQ3AZZireDlmUbmwEqs= X-Received: by 2002:ac2:5606:: with SMTP id v6mr19289796lfd.129.1557946845119; Wed, 15 May 2019 12:00:45 -0700 (PDT) MIME-Version: 1.0 References: <916eb56a-3336-9e65-0f70-f1557975544d@beccati.com> <79b7d381-e56e-441b-3436-d6f2024704c6@gmx.de> <0ee156e3-9e72-4ae0-417e-a506def5447f@beccati.com> In-Reply-To: <0ee156e3-9e72-4ae0-417e-a506def5447f@beccati.com> Date: Wed, 15 May 2019 21:00:28 +0200 Message-ID: To: Matteo Beccati Cc: Dan Ackroyd , PHP internals Content-Type: multipart/alternative; boundary="000000000000484b350588f1c4bf" Subject: Re: [PHP-DEV] Re: [RFC] Allow throwing exceptions from __toString() From: nikita.ppv@gmail.com (Nikita Popov) --000000000000484b350588f1c4bf Content-Type: text/plain; charset="UTF-8" On Wed, May 15, 2019 at 7:55 PM Matteo Beccati wrote: > Hi Dan, > > On 15/05/2019 03:15, Dan Ackroyd wrote: > > Immediately nothing. > > > > Eventually, when a __toString() method throws an exception, and the > > extension doesn't check for an exception being throw, bad things will > > happen. > > > > But in my opinion, if people don't understand the implications of the > > RFC even after reading the details in the RFC and this thread, then > > this probably is an RFC they should skip voting on. > > I don't agree. I've worked on a few bug fixes and features in php-src, > but never worked directly with exceptions, so I have to admit my > ignorance on the topic. I was expecting "bad things to happen", but I > wasn't quite sure about it. > > "Extension authors who would like to ensure that they handle exceptions > from string conversions gracefully" and "It is generally sufficient to > check whether an exception has been thrown" do not convey any sense of > urgency. > > Since there are many people who can vote and only do PHP userland, I > believe that clarifying impact on the RFC itself would surely benefit > everyone. Suggesting that they shouldn't vote is definitely not helping. > Quoting from the RFC: > While checking every single string conversion certainly puts you on the safe side, leaving out these checks will usually only result in some unneeded computation and possibly redundant warnings. The main thing you should watch out for are operations modifying persistent structures such as databases. Not explicitly handling exceptions from __toString() will not cause segfaults or memory corruption if you don't do anything. It only means that your function call will not abort at the earliest possible opportunity. If you have functions modifying persistent datastores it's a good idea to review them to make sure you handle exceptions right away, but otherwise I wouldn't be overly concerned. Nikita --000000000000484b350588f1c4bf--