-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Standardize PHP's docref errors #4254
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
Conversation
cc73dd9
to
0f36d21
Compare
I'm wondering if some of the |
be09cab
to
cec8513
Compare
I'm not sure I really understand what the motivation for this change is. Can you maybe explain in more detail what the advantage of migrating everything to docref0 is? |
Ah yes seems like an important point, main reason is that outside of streams (and DBA extensions, and 2 other cases IIRC) the docref1&2 functions aren't used, moreover there is no more mention about the differences of these different docrefs in PHP 5 nor 7 coding standard and I needed to look at a PHP 4 version to see what they are about [1] so it seems that as of PHP 5 the recommended way of displaying docref errors is by using the The second motivation is that all errors would look the same instead of having some cases where you can get function(param): error message in case of docref1 and function(param1, param2): error message in case of docref2 which may be slightly confusing IMHO.
This does, however, impact extensions so if this kind of change is better for PHP 8 I'm fine with that too. [1] https://github.com/php/php-src/blob/PHP-4.0/CODING_STANDARDS |
cec8513
to
8866698
Compare
It looks like I uncovered a genuine bug, |
3e037e5
to
4c2dca5
Compare
ee3f2d6
to
fadb5bb
Compare
fadb5bb
to
aed3231
Compare
Converted docref1 and 2 function usage to standard docref (previously docref0).
a00fd4a
to
524c355
Compare
Would it be better that I leave the |
Converting all
php_error_docref0()
,php_error_docref1()
andphp_error_docref2()
to use the standardphp_error_docref()
function to generate clickable errors.Rationale:
The
php_error_docref1
andphp_error_docref2
functions aren't really used outside of streams, the DBA extension, and a couple of edge cases. Thephp_error_docref0
is redefined asphp_error_docref
so those conversions are straight forward.Moreover, there is no more mention about the differences and use cases of the
php_error_docref<n>
functions in PHP 5 nor 7 coding standard contrary to what the source code says, and to get any information about them, one must look at a PHP 4 version to see what they are about. [1]Going by this it seems that as of PHP 5 the recommended way of generating clickable errors with an optional docref is by using the
php_error_docref
macro which is bound tophp_error_docref0
A second motivation is that all of PHP's errors would look the same. Currently there are some case, as said before mostly related to streams, where an error message looks like
Error_Type: function(param): [...]
if generated by usingphp_error_docref1()
orError_Type: function(param1, param2): [...]
if generated by usingphp_error_docref2()
which may be slightly confusing.Improvements:
failed to open stream
errors state the stream just after this text instead of in the function brackets.rename()
better description of which part is the problem, source path or target path.fopen()
as to where the error is caused.Changes:
php_win32_docref2_from_error()
has been renamed tophp_win32_docref_from_error_with_param
as its behaviour changed, this however shouldn't affect much code as it was only used 4 times instreams/plain_wrapper.c
. [3]List of areas not covered by unit tests:
_php_stream_open_wrapper_ex
(streams.c
) default case in switch statementphp_plain_files_metadata
(plain_wrapper.c
)php_plain_files_rename
(plain_wrapper.c
) whenEXDEF
is defined: branchif (errno == EXDEV)
Possible bugs uncovered:
opendir()
[3] emit a Warning on Windows even though the message says the operation was completed successfully.References
[1] https://github.com/php/php-src/blob/PHP-4.0/CODING_STANDARDS
[2] https://lxr.room11.org/search?project=php-src%407.4&q=php_win32_docref2_from_error&defs=&refs=&path=&hist=&type=
[3] See test: ext/standard/tests/dir/opendir_variation6-win32.phpt