-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix PDO MySQL URI test #8451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PDO MySQL URI test #8451
Conversation
ecc9a01
to
c6afdf8
Compare
Isn't that NUL character an important part of the test? Can you show the test failures? |
I belive no, @cmb69 please test yourself the important fact is this tests is not working correctly if the MySQL server is not on localhost/default port if server port is for example 3307, I get:
with this PR, I get |
Why not add that to the list of expected failure messages? |
because the test is wrong, we definitely do not want to touch other service than defined in DSN |
This appears to be the whole point of that part of the test. It is about |
maybe, would it be fine if I add something like test will be fixed and the |
If that would error without the NUL byte, that appears to be reasonable. Maybe @kamil-tekiela has thoughts on this.
"Spec" might be an exaggeration, but it tests the implementation (which is as it is for whatever reason): Lines 165 to 167 in 0df2886
|
6e7abf5
to
d708bf7
Compare
Sorry, I am not seeing how it is wrong.
That's the whole idea. The test is checking whether the URI past the NUL byte is ignored. If it's ignored then PDO should error out on the incorrect database name.
It's testing whether the NUL byte ends DSN
Ok, that part might need fixing. The DSN should contain the same config except
And what would that test? We hope that this test never reaches this part so invalid charset is meaningless to this test. Better keep that part as it was. |
you answered it by yourself:
now the test is testing the behaviour as before & /w full DSN, can you please review the changes? |
tested with #8392, I can confirm the changes are fixing the test |
@@ -73,5 +71,5 @@ MySQLPDOTest::skip(); | |||
print "done!"; | |||
?> | |||
--EXPECTF-- | |||
[003] URI=uri:file://%spdomuri.tst, DSN=mysql%sdbname=%s, File=%spdomuri.tst (%d bytes, 'mysql%sdbname=letshopeinvalid%s'), chr(0) test, EXPECTED ERROR | |||
[003] URI=uri:file://%spdomuri.tst, DSN=mysql:%sdbname=%s, File=%spdomuri.tst (%d bytes, 'mysql:%sdbname=letshopeinvalid%snonsense'), EXPECTED ERROR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did the output change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, chr(0) test
is not needed here as the line/echo is "identified" by [003]
, other additions here are to improve the expectation
can this PR be merged? I need it for #8392 |
fwrite($fp, sprintf('mysql:dbname=letshopeinvalid;%s%s', | ||
chr(0), $dsn)); | ||
$dsnUnknownDatabase = preg_replace('~dbname=[^;]+~', 'dbname=letshopeinvalid', $dsn) | ||
. chr(0) . ';host=nonsense;unix_socket=nonsense'; | ||
fwrite($fp, $dsnUnknownDatabase); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that this change defeats the purpose of that part of the test. The test is for checking that a NUL byte terminates the DSN string. If there is no NUL byte (or it would be ignored), later options override previous options (dbname=good;dbname=bad
would be the same as dbname=bad
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the test in a minimalistic way.
I aggre, we can basically copy the 1st test with fwrite($fp, $dsn. chr(0) . ';host=nonsense;unix_socket=nonsense');
, not bother with dbname=letshopeinvalid
and expect the same result. Do you want me to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I aggre, we can basically copy the 1st test with
fwrite($fp, $dsn. chr(0) . ';host=nonsense;unix_socket=nonsense');
, not bother withdbname=letshopeinvalid
and expect the same result.
That make sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI issue unrelated, let's merge this PR, needed for #8392
"\0"
char in URI causes the remaining part completely ignored, thus testing effectively onlymysql:dbname=letshopeinvalid
but this URI then tested connection /w default host/port/credentials resulting with a many different failures (for example, consider MySQL server accessible on localhost /w and /wo default port)