Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62009 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80549 invoked from network); 3 Aug 2012 15:50:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2012 15:50:26 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:57467] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D5/1C-09659-F33FB105 for ; Fri, 03 Aug 2012 11:50:24 -0400 Received: by vbbfs19 with SMTP id fs19so902458vbb.29 for ; Fri, 03 Aug 2012 08:50:21 -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=8V5A8CgjWe0e7JGQitu3GM/BOwqwm8YYDXkZcsHhNnI=; b=0+NULhR3dloVKuYs5F/NPkiSy+TRmvXDYHm1CR6/KYKbnl7VktebFCu5Jv9L6QrGr1 GC0WZwRCf0yjoCzIK28Bzxd1kWzM+VDlkbguxQn/nA1F8po3twTDk7jp30Dl7z63QBYX wvwN734hcixFJMmVXCe+5H1kzHnB8KFZ0W4/8TRbi2nacYXahW7NRKUAZdWcG9bWofU4 RwML0kZjnn/mROY2JRnStt7VADqrg5tFk6sVpEpYsrdx7KX7l2fLMyn7Tpna5yTwMJqg R2YF94Q8w+JdykJerUJqTLFqXk1efnqDmvmFJu5gtyXIXz7+8A47f9CbDPFGYKe+KvrF RMHQ== MIME-Version: 1.0 Received: by 10.58.169.16 with SMTP id aa16mr1920093vec.33.1344009020634; Fri, 03 Aug 2012 08:50:20 -0700 (PDT) Received: by 10.58.216.166 with HTTP; Fri, 3 Aug 2012 08:50:20 -0700 (PDT) In-Reply-To: <3F2B7A4F937D4FA9A1CE88818CBCEB1D@pc> References: <3F2B7A4F937D4FA9A1CE88818CBCEB1D@pc> Date: Fri, 3 Aug 2012 17:50:20 +0200 Message-ID: To: Stan Vass Cc: Leigh , internals@lists.php.net Content-Type: multipart/alternative; boundary=047d7b6d7bec3ff60f04c65e7c72 Subject: Re: [PHP-DEV] Why do disabled functions / classes generate a WARNING. From: tyra3l@gmail.com (Ferenc Kovacs) --047d7b6d7bec3ff60f04c65e7c72 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Aug 3, 2012 at 4:19 PM, Stan Vass wrote: > Hi all, >> >> Can anyone explain to me the reason that when a function or class is >> disabled via the ini setting, an attempt to access the disabled item >> generates a non-fatal error? >> >> I'm looking at a segfault in the SPL caused by the blind creation of a >> class, which seems to only fail when the class is disabled. I'm >> wondering in how many other places this could occur. >> >> The obvious solution is to be more careful and check return values, >> but a FATAL would also have prevented execution continuing. >> >> Thanks, >> >> Leigh. >> > > PHP has a long history of issuing errors of the wrong type at the wrong > time. My experience shows it's best to have an error handler convert all > errors to catchable exceptions, with some error types (like E_STRICT, > E_ERROR etc.) to become instant fatal errors (can't be caught). > > This would also solve your use case since the warning will become an > exception with a stack trace clearly pointing to the origin of your > problem. Additionally you can handle an exception on a higher level in th= e > stack once instead of doing it for every function/class call. > > I'm afraid fixing the default behavior is a big hopeless since it'll brea= k > BC and require a major rethinking of the way PHP issues errors. > > See: set_error_handler(). > > a php function/operation can raise more than one warning, how would you handle that? with exceptions you would only get the first one. another issue is that with the current error handling model a call can trigger a non-fatal error and still return some data. with exeptions you can't do that. so changing our internal error handling isn't as easy to start throwing ErrorException-s, it would require much more workthan that. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --047d7b6d7bec3ff60f04c65e7c72--