Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113008 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61547 invoked from network); 27 Jan 2021 16:57:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Jan 2021 16:57:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4879C1804A7 for ; Wed, 27 Jan 2021 08:39:05 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from v-smtpout1.han.skanova.net (v-smtpout1.han.skanova.net [81.236.60.154]) (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 ; Wed, 27 Jan 2021 08:39:04 -0800 (PST) Received: from [192.168.7.11] ([213.64.245.126]) by cmsmtp with ESMTPA id 4nqRlgUNj3UCO4nqRlv8M7; Wed, 27 Jan 2021 17:39:03 +0100 To: Kamil Tekiela , Christian Schneider Cc: Nikita Popov , PHP internals References: <0edafce4-c9a5-c483-65f1-72e49614135a@telia.com> <4D7D042F-39A5-4BEF-93B6-542FD53928A1@cschneid.com> <73C12DD2-D99E-44BA-B557-6043F3DDD4C7@cschneid.com> <30C0E1A8-6269-4221-AF21-3FA738D5910C@cschneid.com> <0eb16a55-92d0-7118-57fe-0f3f7d2bc351@telia.com> Message-ID: <95c3196d-106b-8964-ddd5-9069eb333a61@telia.com> Date: Wed, 27 Jan 2021 17:39:02 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <0eb16a55-92d0-7118-57fe-0f3f7d2bc351@telia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-CMAE-Envelope: MS4wfNg309xaLQ3h78b78Mk3hIq8CAiY7iz9wXw0QUDvDP7ug23wdcPxmTuD6mxYVihbdgGfwxiRFO3n4yrYziXFWPhQhQF23Fesb81q0yZwroWIPpgqtTe9 2JITk6CR/a3bEKcqI3ae4VMw9Ehz8sOPnT2ZTgZrYhQMo4gNVF0SNZT9SvyEUDcRNa8PIkb3Xs0RzolSwbPnsB+2Uc6cG/DBh73YgFzKirMvPtuXtuKRbwJb zMDdwGFnucu2w2lwlgAa66eQjKuj5cQ5NBhiuHGnjMCNCr8OU5ZXglsMwX504kEN Subject: Re: [PHP-DEV] [RFC]: Change Default mysqli Error Mode From: bjorn.x.larsson@telia.com (=?UTF-8?Q?Bj=c3=b6rn_Larsson?=) Den 2021-01-27 kl. 17:13, skrev Björn Larsson: > Den 2021-01-27 kl. 16:07, skrev Kamil Tekiela: >>> >>> Wouldn't this mean everybody would add mysqli_report() to their code? >> >> That is the idea. That is what everyone should already have in their >> codebase. >> >>    And wouldn't this render the default of mysqli_report() entirely >> useless? >> >> I'm sorry, but I don't follow the train of thought? Why would it make >> that >> useless? You must set the correct error reporting mode anyway and that >> function helps in doing so. >> >>    Or is your idea that at a later stage you then want to create a >> warning >>> for manual mysqli_report() calls? >> >> What are manual mysqli_report() calls? You either have that line in your >> code or you don't. The idea that Nikita suggested is to meet your >> concerns. >> The only way to figure out if your code needs an adjustment is to have a >> warning emitted from any mysqli connect methods if you have not called >> mysqli_report before. It would inform users that they are missing the >> setting. >> >>    No, I want to know if I have any code which needs fixing so I can >> see how >>> I want to change those places e.g. a duplicate key from INSERT to >>> REPLACE >>> or whatever the correct fix is. Without the code aborting. >> >> You can do that right now. This proposal will not make it easier or more >> difficult for you to do that. Just paste >> mysqli_report(MYSQLI_REPORT_ERROR) >> before mysqli_connect() and PHP will generate a warning whenever your >> SQL >> throws an error. >> >>    Otherwise the temptation is big to just add a global >>> mysqli_report(MYSQLI_REPORT_OFF) everywhere just in case. >> >> I don't get what's wrong with that. This is literally what I said in the >> RFC you can do if you don't want mysqli to report any errors. Whoever >> doesn't want to see errors can use this line to silence them. >> I would even make a counterpoint. If we set  MYSQLI_REPORT_ERROR as the >> default then users will definitely silence errors and forget. The >> warning >> mode is so useless and annoying that people will prefer to silence it >> seeing no benefit to it. If we want this change to be useful then we >> should >> make SQL errors report as exceptions by default. >> >> Regarding Nikita's proposal: The compromise is reasonable, but this will >> not be well-received by the community. Additional warnings will only >> make >> things more confusing without providing outstanding benefits. If we >> want to >> force people to set the error reporting mode that they want, then it >> would >> be better to set a sensible default value and give a clear >> explanation in >> the migration guide how to set it back to the previous value. Of >> course, I >> don't hate Nikita's proposal and I might say I even like it a little >> bit, >> but only in connection with exception mode as the default value. This >> way >> users will not be surprised by an exception if it happens that they >> forget >> to silence. But I would prefer that everyone embraced exceptions. >> > I'm missing a thing here when we talk about "your code". I mean on our > site > we have third party libraries. They can typically have a release > schedule on > a couple of releases each year. So all code is not up to us to change. > So how > does this proposal adress that scenario when it's  not up to us to do the > necessary changes? Is it e.g. a blocker to upgrade to PHP 8.1 with > exceptions vs warnings until the library is updated? > > As a side note I'm at the moment migrating our test site to PHP 8 and > the two most prominent hickups are located in a third party library: > "Undefined array key" and "Attempt to read property "value" on null" > which are warnings. Not sure how it would have been with these as > exceptions, e.g. would the test site stop running and thereby stop > testing of other parts. > > And as I have said earlier, I do like exceptions! It's the migration > aspect I'm wondering about... > > r//Björn L PS And sorry for the lousy formatting in earlier response.