On February 27, 2021 7:29:43 PM GMT+01:00, Kamil Tekiela <tekiela...@gmail.com> 
wrote:
>> The code shown here
>https://www.w3schools.com/php/func_mysqli_connect.asp is
>relatively correct at the moment. Maybe not nice, but it handles the
>error.
>That is the second hit on google (after php.net manual) when searching
>for
>"php tutorial mysqli_conect") Most other books, tutorials, ... teach
>the
>same.
>
>w3schools is hardly something that should be regarded as a reputable
>source
>of information 

That is correct. I wouldn't advice following that.

> and should not impact the direction PHP is heading in.

That I don't agree with. The things covered in tutorials and books is what 
people use to learn. What people learn is what they use for some time in their 
path. We have a responsibility towards our users.

>This problem comes mostly from the fact that the developers who wrote
>these
>tutorials were unaware that there is automatic error reporting
>available.

For many that is true. In some cases tutorial writers are happy about the fact 
that they don't have to teach exceptions early.

Error handling in PHP is a mess, but I consider the path towards more 
exceptions good. But has to be done with care.

>PHP manual didn't explain this either. This RFC proposes to change that by
>making it the default so that people can't miss it.
>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. I wish I knew
>about
>automatic error reporting instead of struggling with invisible SQL
>errors.
>I still hold a grudge against the tutorials teaching me manual error
>checking or the use of real_escape_string. I do not want new developers
>in
>the era of PHP 8 to suffer the same pain I did.

These tutorials are a pain and there is a large group of people creating worst 
quality content and hoping to benefit from SEO stuff and then earning some 
money from ads. Others focus on content and don't get attention. That is a big 
problem we're having.

I disagree however that throwing out errors the readers don't understand helps. 
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.

[...]

>> In 8.1 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.
>> In a later version we change it.
>> That gives a chance to reach users. We will still miss many, but for
>a
>notable amount of people there is a chance.
>
>I believe Nikita has proposed it already. I am not very happy about it
>as
>this would mostly go unnoticed. People who have mysqli error reporting
>silenced often have every other error reporting silenced too including
>deprecation notices. Adding such deprecation notice would just create
>another confusing PHP error that developers would have to fix.

The difference is: With a deprecation warning we control the error message 
better.

> 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. "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. I
>believe it would be just a waste of time. 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.

I don't know why there is a specific time pressure. That behavior is now almost 
twenty years old.

And we'll, about visibility: Tutorial writers hopefully don't ignore it and can 
catch up. Also deprecation warnings have a chance to be reported to the authors 
etc. Yes, it won't reach everybody, but we're talking here about a change 
affecting huge numbers of systems.  If we help just a few hundred thousands of 
those to make a smoother transition it's already a good thing.

And yes, there are more people reading deprecstion notices than changelogs. 
Outside the enthusiasts only few do. Partially since most entries are 
irrelevant, partially since there are so many changelogs one could read all 
day, partially since people don't even know what version they are running or 
that the host is being upgraded by an admin.

People look at it, if they notice a problem. But they first need a way to even 
notice. Silently ignoring half the code (the existing error handling) goes 
unnoticed.

Last thing: I truly think it is great that your trying to push this forward! 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 becoming used to 
the way things are. I only consider the change too rushed.

johannes

P.S. Most people here know it, I assume, but as disclaimer: I am a member of 
the MySQL engineering team at Oracle, where these days, I'm not working on 
anything regarding Client APIs. All opinions stated are my own.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to