Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109021 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62644 invoked from network); 14 Mar 2020 22:48:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Mar 2020 22:48:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2A3781804DF for ; Sat, 14 Mar 2020 14:10:50 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 14 Mar 2020 14:10:49 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 591312230E for ; Sat, 14 Mar 2020 17:10:48 -0400 (EDT) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Sat, 14 Mar 2020 17:10:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=yhqIYz 2UAQ/k7b1S6QMrAAXVxlGYjlHPtlBa3N/YCHY=; b=1JhBcgy2HS7Oamh15ODAf3 8+5OFzPOo7i7fqCpxOgoC3mfshTeyqZzrbmgIa49JnYeo0bw1E6/vB0kO5tJ9jgb x+4QqyUDhpW6fsFF8FS4RPZOvzIosEZV3RBZNm8Pmh1ZHpnDUMmFkioTi72/kT9m tZ+QDMAi+b+8h5LWrF2d1HSJtrE5hKeOhWRR/xB/LvchZFhl20wMGtS6HXAKwflV f99FYJLGOxvPxCvMFE9VL5Hk84FTbVEJliki3weivaUyS2IdsQaukTwgPU5+i7Fg tLErdQtMS6FPXQihAKl9BAXR33SfZrJ0tpHW7q0HPQ1OKMneuZMwSsK9VFRxzzTQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedruddvledgudegjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep lhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id B9EFD14200A2; Sat, 14 Mar 2020 17:10:47 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-991-g5a577d3-fmstable-20200305v3 Mime-Version: 1.0 Message-ID: <782751cf-0058-4dae-9f5a-40648a79986d@www.fastmail.com> In-Reply-To: <99c00084-c212-ad23-628e-87f35e2de849@allenjb.me.uk> References: <99c00084-c212-ad23-628e-87f35e2de849@allenjb.me.uk> Date: Sat, 14 Mar 2020 16:10:27 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Changing the default PDO error mode From: larry@garfieldtech.com ("Larry Garfield") On Sat, Mar 14, 2020, at 10:40 AM, AllenJB wrote: > Hi all, > > A regular problem that new users run into is error handling with PDO. > The current default error mode for PDO is "silent". This leads to the > situation where code doesn't work and returns no obvious errors unless > PDO specific error handling code is explicitly added. > > I would like to propose the default error mode be changed from PHP 8 as > I believe this would make PDO error handling much more intuitive for new > developers, preventing the common "my code isn't working and I don't > know why" scenario that occurs. > > While a BC break, I believe it's the type of change developers expect in > a major version and I don't believe that explicitly setting the error > mode for code bases that rely on the silent error mode is onerous - many > code bases are already explicitly setting the error mode already. > > Given the way error handling has been / is heading in PHP, I would > suggest the default error mode should be exceptions, but I can forsee > arguments for using warnings instead ("less of a BC break" since code > would still continue unless a custom error handler causes an abort, so > closer to the behavior of "silent"). > > What are peoples views on making this change? > > What do you think the new default be (and why)? > > (I am aware this change will likely require an RFC) > > AllenJB I see only two options: 1) Do nothing. 2) Move to Exceptions. I've never used PDO and not set it to Exceptions, honestly. Adding more global error conditions to code is a terrible idea, so let's not do warnings. If your query breaks, you really shouldn't continue because your data is busted so your following code will fail ungracefully at best, or corrupt data at worst. Changing a default like this seems a reasonably safe thing to do in a major, as long as it's still just as easy to switch back to silent mode for those who prefer to be explicit. --Larry Garfield