Skip to content

sapi/cli/php_cli.c: later -n and -c should supersede earlier ones - #25261

Open
orlitzky wants to merge 1 commit into
php:masterfrom
orlitzky:n-and-c-flag-precedence
Open

orlitzky wants to merge 1 commit into
php:masterfrom
orlitzky:n-and-c-flag-precedence

Conversation

@orlitzky

@orlitzky orlitzky commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

The -n and -c flags serve essentially the same purpose, to indicate which ini file should be used. The -c flag lets you name an ini file explicitly, while -n means that no ini file should be used.

Typically, argument parsers will override earlier occurrences of a flag with later ones. Later occurrences of -c do indeed override earlier -c flags, but if you specify -n after -c, the -n is essentially ignored; the ini file passed to -c is loaded anyway.

After updating ext/standard/tests/ini_info/php_ini_loaded_file.phpt to support TEST_PHP_EXTRA_ARGS, that test fails if the extra args include -c. In particular, it fails "make test". This commit updates the argument parser so that subsequent -n override any existing -c flags, fixing the tests.

See also:

@remicollet

Copy link
Copy Markdown
Member

I dont' think such a behavior change is acceptable for stable branches (but is fine for next)

@orlitzky
orlitzky changed the base branch from PHP-8.4 to master November 12, 2026 12:55
The "-n" and "-c" flags serve essentially the same purpose, to
indicate which ini file should be used. The -c flag lets you name an
ini file explicitly, while -n means that no ini file should be used.

Typically, argument parsers will override earlier occurrences of a
flag with later ones. Later occurrences of -c do indeed override
earlier -c flags, but if you specify -n after -c, the -n is
essentially ignored; the ini file passed to -c is loaded anyway.

After updating ext/standard/tests/ini_info/php_ini_loaded_file.phpt to
support TEST_PHP_EXTRA_ARGS, that test fails if the extra args include
-c. In particular, it fails "make test". This commit updates the
argument parser so that subsequent -n override any existing -c
flags, fixing the tests.
@orlitzky
orlitzky force-pushed the n-and-c-flag-precedence branch from 7c48f10 to fe10ea1 Compare November 12, 2026 12:56
@orlitzky
orlitzky requested a review from bukka as a code owner November 12, 2026 12:56
@orlitzky orlitzky mentioned this pull request Nov 27, 2026
4 tasks done
lotharsm added a commit to lotharsm/felsqualle-gentoo that referenced this pull request Nov 27, 2026
The tests are now fixed upstream, so we don't have to disable them. The
remaining one, ext/standard/tests/ini_info/php_ini_loaded_file.phpt, is
waiting for php/php-src#25261.
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.

2 participants