Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87204 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34947 invoked from network); 16 Jul 2015 16:32:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2015 16:32:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.181 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.181 mail-wi0-f181.google.com Received: from [209.85.212.181] ([209.85.212.181:37421] helo=mail-wi0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 15/32-16799-7ACD7A55 for ; Thu, 16 Jul 2015 12:32:40 -0400 Received: by wibud3 with SMTP id ud3so21324001wib.0 for ; Thu, 16 Jul 2015 09:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=9vHq5nj90nIpcPEIKNomhn+d75/4l9SpS1NN07044Vo=; b=Sbl0Bce2lfxAGZeENq5zQzyJSLQU2+wybt+TxX0ePk93uKXca49MqOd70uJuXvz9nC MmPDPLnZmWAbQxkskixPjy6Lsk6ZWKm4FkPiYempzI42UYOK9B1vA2jKgoqtVHM4XHzW 91KpAANACJrq+F44C7kaA8AYxYKZsC3/tuQ0N8kdTcbvnW394dSGY1wc7K22ZUUw2Dyk P991AVAK+0Bh4oBs2PBqTMBu/qeP0DOcs8kgeZbjSIG6iKAxx+jwIoLtNo/SEkDLdDMI NYoXAoiDUESHhXiTcNlVUcrq//q8W1/5rZ/EuZbUCCOzjuv5k04v+vquZmHr2IdrB0Ym KXpw== X-Received: by 10.194.82.167 with SMTP id j7mr20633333wjy.123.1437064357345; Thu, 16 Jul 2015 09:32:37 -0700 (PDT) Received: from [192.168.0.136] ([62.189.198.114]) by smtp.googlemail.com with ESMTPSA id ho10sm13906655wjb.39.2015.07.16.09.32.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 09:32:36 -0700 (PDT) To: internals@lists.php.net References: <55A7D993.5000301@moonspot.net> Message-ID: <55A7DC8F.30606@gmail.com> Date: Thu, 16 Jul 2015 17:32:15 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55A7D993.5000301@moonspot.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Core functions throwing exceptions in PHP7 From: rowan.collins@gmail.com (Rowan Collins) Brian Moon wrote on 16/07/2015 17:19: > On the surface, this sounds like a good thing. Although, I question > that if a user is not checking $result === false, then will they end > up just wrapping this in an empty try/catch so their code does not > fail? There is a mechanism to detect the error now. > > I question why the cryptographic functions would not force an integer > to be passed. Those should not accept a boolean and evaluate it as > false. I am not sure what functions you are talking about though. > Maybe 3rd party user land code? Accepting a boolean in those cases is > a bug in that code IMO. > Scott provided an example elsewhere in the thread: > $max = strlen($alphabet) - 1; > for ($i = 0; $i < 32; ++$i) { > $password .= $alphabet[random_int(0, $max)]; > } That demonstrates both a situation where booleans can't be excluded, and where you'd have to try pretty hard to silently catch the exception in a way that left your code broken. I suppose you could forget to check if the generated password is empty, but that doesn't seem all that likely. If you've gone to the trouble of putting a try block in, you're at least aware that the function CAN fail. Regards, -- Rowan Collins [IMSoP]