Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113323 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 95356 invoked from network); 27 Feb 2021 22:41:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Feb 2021 22:41:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 07B881804D0 for ; Sat, 27 Feb 2021 14:31:28 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail.toneristzuen.de (mail.toneristzuen.de [84.19.169.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 27 Feb 2021 14:31:26 -0800 (PST) Received: from Galaxy-S20.fritz.box (ppp-188-174-55-8.dynamic.mnet-online.de [188.174.55.8]) by mail.toneristzuen.de (Postfix) with ESMTPSA id 2E3BF4265F; Sat, 27 Feb 2021 23:31:24 +0100 (CET) Date: Sat, 27 Feb 2021 23:31:22 +0100 User-Agent: K-9 Mail for Android In-Reply-To: References: <84a86f15-313e-1fb3-eb09-7fd6bbdeb5ce@php.net> <821813eb972cd5dad30a0e10385a115a9a8908a2.camel@schlueters.de> <2d9e003c-2a05-9cfa-8625-5aedf5b069f6@gmail.com> <445707c1-2b67-1f46-8d93-d9e0ca420b87@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net,Kamil Tekiela ,Rowan Tommins Message-ID: <3746C84D-AA34-4259-854B-9DB03C071CBD@schlueters.de> Subject: Re: [PHP-DEV] [RFC]: Change Default mysqli Error Mode From: johannes@schlueters.de (=?ISO-8859-1?Q?Johannes_Schl=FCter?=) On February 27, 2021 7:29:43 PM GMT+01:00, Kamil Tekiela wrote: >> The code shown here >https://www=2Ew3schools=2Ecom/php/func_mysqli_connect=2Easp is >relatively correct at the moment=2E Maybe not nice, but it handles the >error=2E >That is the second hit on google (after php=2Enet manual) when searching >for >"php tutorial mysqli_conect") Most other books, tutorials, =2E=2E=2E teac= h >the >same=2E > >w3schools is hardly something that should be regarded as a reputable >source >of information=20 That is correct=2E I wouldn't advice following that=2E > and should not impact the direction PHP is heading in=2E That I don't agree with=2E The things covered in tutorials and books is wh= at people use to learn=2E What people learn is what they use for some time = in their path=2E We have a responsibility towards our users=2E >This problem comes mostly from the fact that the developers who wrote >these >tutorials were unaware that there is automatic error reporting >available=2E For many that is true=2E In some cases tutorial writers are happy about th= e fact that they don't have to teach exceptions early=2E Error handling in PHP is a mess, but I consider the path towards more exce= ptions good=2E But has to be done with care=2E >PHP manual didn't explain this either=2E This RFC proposes to change that= by >making it the default so that people can't miss it=2E >The reason why I really want this default setting to change is that I >was >lied to by books and tutorials when I was learning PHP=2E I wish I knew >about >automatic error reporting instead of struggling with invisible SQL >errors=2E >I still hold a grudge against the tutorials teaching me manual error >checking or the use of real_escape_string=2E I do not want new developers >in >the era of PHP 8 to suffer the same pain I did=2E These tutorials are a pain and there is a large group of people creating w= orst quality content and hoping to benefit from SEO stuff and then earning = some money from ads=2E Others focus on content and don't get attention=2E T= hat is a big problem we're having=2E I disagree however that throwing out errors the readers don't understand h= elps=2E How many will say "oh the tutorial is broken" and how many will say= "my PHP is broken"? Back in my days, I remember, I was more often looking = for failures by me or my system configuration than blaming the tutorial=2E [=2E=2E=2E] >> In 8=2E1 add deprecation notices to mysqli_connect & friends AND to >access >to the connection_error (if I remember right that goes via the __get >hook, >thus we can add a deprecation note to a "property" access) >> The later is a good place as many people use the @ operator on the >connect, but not on the error check=2E >> In a later version we change it=2E >> That gives a chance to reach users=2E We will still miss many, but for >a >notable amount of people there is a chance=2E > >I believe Nikita has proposed it already=2E I am not very happy about it >as >this would mostly go unnoticed=2E People who have mysqli error reporting >silenced often have every other error reporting silenced too including >deprecation notices=2E Adding such deprecation notice would just create >another confusing PHP error that developers would have to fix=2E The difference is: With a deprecation warning we control the error message= better=2E > I am sorry >to say this about my fellow developers but many of the ones that you are >targeting with this proposal who wouldn't read an upgrade guide before >upgrading, are also the ones who would ignore this deprecation warning in >their error logs=2E "Hey, the code still works, I don't know what this >deprecation notice is talking about!" >For these reasons, I am unwilling to go through a deprecation phase=2E I >believe it would be just a waste of time=2E But if this is the only way >that >this change will land in PHP then I would also accept it as a very >unsatisfying compromise=2E I don't know why there is a specific time pressure=2E That behavior is now= almost twenty years old=2E And we'll, about visibility: Tutorial writers hopefully don't ignore it an= d can catch up=2E Also deprecation warnings have a chance to be reported to= the authors etc=2E Yes, it won't reach everybody, but we're talking here a= bout a change affecting huge numbers of systems=2E If we help just a few h= undred thousands of those to make a smoother transition it's already a good= thing=2E And yes, there are more people reading deprecstion notices than changelogs= =2E Outside the enthusiasts only few do=2E Partially since most entries are= irrelevant, partially since there are so many changelogs one could read al= l day, partially since people don't even know what version they are running= or that the host is being upgraded by an admin=2E People look at it, if they notice a problem=2E But they first need a way t= o even notice=2E Silently ignoring half the code (the existing error handli= ng) goes unnoticed=2E Last thing: I truly think it is great that your trying to push this forwar= d! We always need people coming up here and fixing the painpoints they had!= It is easy for people here to get reluctant to change over time and becomi= ng used to the way things are=2E I only consider the change too rushed=2E johannes P=2ES=2E Most people here know it, I assume, but as disclaimer: I am a mem= ber of the MySQL engineering team at Oracle, where these days, I'm not work= ing on anything regarding Client APIs=2E All opinions stated are my own=2E