Skip to content

Conversation

@khaledalam
Copy link

Description

Fixes #20871 by improving error messages for invalid -d command-line options.

Previously, when an invalid -d option was passed to PHP CLI, the error message reported "Unknown on line X". This was confusing for users who don't know about PHP's internal INI handling.

image

Changes

  • Modified Zend/zend_ini_parser.y to detect CLI/FPM -d option parsing context
  • When parsing -d options (filename is "Unknown" and unbuffered_errors is true), error messages now report "-d option on line 0" instead of "Unknown on line X"
  • Added test case sapi/cli/tests/gh20871.phpt to verify the fix with multiple invalid syntax scenarios

@iluuu1994
Copy link
Member

It would probably help even more if there was an indication that the parsing error happens for INI parsing, rather than parsing of the PHP code. For example, instead of "in Unknown" it could print "in INI command line parameter '-d'". Or maybe even the INI line itself.

@khaledalam
Copy link
Author

It would probably help even more if there was an indication that the parsing error happens for INI parsing, rather than parsing of the PHP code. For example, instead of "in Unknown" it could print "in INI command line parameter '-d'". Or maybe even the INI line itself.

@iluuu1994 Thank you for the feedback! I've updated the message. The error message now clearly indicates this is INI parsing,

e.g. PHP: syntax error, unexpected '=' in INI command line parameter '-d'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad error line and file for invalid "-d" arguments

2 participants