Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60872 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83543 invoked from network); 17 Jun 2012 21:31:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jun 2012 21:31:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=john.lesueur@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=john.lesueur@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: john.lesueur@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:56378] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2F/E5-49496-1CC4EDF4 for ; Sun, 17 Jun 2012 17:31:46 -0400 Received: by werm13 with SMTP id m13so3870675wer.29 for ; Sun, 17 Jun 2012 14:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=kpZV9OPlCbr8u62E1qj+WHEk5rh+2wcI/qOogieWfF0=; b=BAlMXmSLds6IIdqB0NXLVX37tek3TdHeapCIGagpgj4VjdosZ5ifL8CL4dzgJiJ8qJ N1+Bfto3jkp5OaZasBnG75sMJLgVSFMbg1CH4b3yj5aCJQVbcZyjmx7Y/r4Qdu7Vvxkj 8U9pPrLRL8zidKe5ebdAIu7MSZzZLPL+OO2Wx5gyzTsLtiDqFqESOPXIwJvN+p9hnxjv QE48ZVECEKhnf1ZYjlNleSl8gj3GJNNfxY5+7WEnTN90gm734BFDo8dKJ/1JxPcyaQa4 eFNczgjyvn8iIjjEEe18m3/tXsLXOULLOG4kBrc58KVIR3a+NiZjIuhtmg7moROCRqow VnoQ== MIME-Version: 1.0 Received: by 10.180.100.2 with SMTP id eu2mr19091778wib.10.1339968703144; Sun, 17 Jun 2012 14:31:43 -0700 (PDT) Received: by 10.216.133.37 with HTTP; Sun, 17 Jun 2012 14:31:43 -0700 (PDT) In-Reply-To: References: Date: Sun, 17 Jun 2012 15:31:43 -0600 Message-ID: To: Karoly Negyesi Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d044283d48fa3d204c2b1c6f0 Subject: Re: [PHP-DEV] How hard should PHP try to finish a script? From: john.lesueur@gmail.com (John LeSueur) --f46d044283d48fa3d204c2b1c6f0 Content-Type: text/plain; charset=ISO-8859-1 On Sun, Jun 17, 2012 at 1:06 PM, Karoly Negyesi wrote: > Hi, > > PHP often throws fatal errors when it could throw an exception. > > Take PHP Fatal error: Non-abstract method foo::bar() must contain > body this error for example. It would be possible to mark this class > as 'invalid' instead and when doing a new foo , throw an exception. Or > if you try really hard then only the method call should throw an > exception. > > Or, I was extending ReflectionClass and got Fatal error: > ReflectionClass::getFileName(): Internal error: Failed to retrieve the > reflection object (same happens if you try serialzie / unserialzie on > ReflectionClass as a comment in the manual points out). I could argue > this is an exception and not a fatal. > > Let me quote documentation: > > Fatal run-time errors. These indicate errors that can not be recovered > from, such as a memory allocation problem. Execution of the script is > halted. > > I do not see the above or , indeed , most of fatals I see this sort of > error. Sure, if a malloc call fails, the world has ended and it's time > to die. Otherwise, could we just get an exception so that it can be > handled ? > > Thanks > > Karoly "chx" Negyesi > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > This kind of thing has come up before, without resolution. There are two separate issues in your proposal: 1. Fatal errors that mean the script should stop executing, but don't actually reflect instability in the engine. 2. Throwing exceptions from PHP core. It seems to me that #2 is strongly opposed by a lot of people. I think most people here sympathize with #1, but it hasn't been important enough for anyone to actually do the work, and there hasn't been a proposal about how it should be done. In general, it requires an audit of every E_FATAL error thrown. Some can be changed to E_RECOVERABLE_ERROR. Some however, really should kill the script, but don't need to skip error handlers. These would need some new E_ constant, and a rule that when thrown, an error handler can be called, but the script will die after the error handler has finished. There's probably more to it than that, which is why there would need to be a RFC. I'm guessing that if someone wrote an RFC, and had a patch, it would be received well. Thanks, John LeSueur --f46d044283d48fa3d204c2b1c6f0--