Oh, that’s not good. However I don’t know of a way to avoid this besides catching and suppressing the error (which is not great). It’s rather something PHP needs to fix if the fix should be proper.
Maybe you have another idea?
PS: You should always disable error reporting on production systems. Displaying errors there can give attackers a lot of insights (just like in this case). And it probably makes sense to connect to the database via a local port or socket that’s blocked for external access as MySQL is generally unencrypted anyway.