Skip to content

Commit 97fda48

Browse files
committed
Fix GH-11141: Could not open input file: should be sent to stderr
I grepped for php_printf cases in main/ and sapi/ and converted the cases which clearly indicate errors to fprintf(stderr, ...), like suggested in the linked issue.
1 parent bbe42a5 commit 97fda48

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

main/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,7 +2107,7 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
21072107

21082108
/* start up winsock services */
21092109
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
2110-
php_printf("\nwinsock.dll unusable. %d\n", WSAGetLastError());
2110+
fprintf(stderr, "\nwinsock.dll unusable. %d\n", WSAGetLastError());
21112111
return FAILURE;
21122112
}
21132113
php_win32_signal_ctrl_handler_init();
@@ -2166,7 +2166,7 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
21662166
* (this uses configuration parameters from php.ini)
21672167
*/
21682168
if (php_init_stream_wrappers(module_number) == FAILURE) {
2169-
php_printf("PHP: Unable to initialize stream url wrappers.\n");
2169+
fprintf(stderr, "PHP: Unable to initialize stream url wrappers.\n");
21702170
return FAILURE;
21712171
}
21722172

@@ -2180,7 +2180,7 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
21802180

21812181
/* startup extensions statically compiled in */
21822182
if (php_register_internal_extensions_func() == FAILURE) {
2183-
php_printf("Unable to start builtin modules\n");
2183+
fprintf(stderr, "Unable to start builtin modules\n");
21842184
return FAILURE;
21852185
}
21862186

sapi/cli/php_cli.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ static zend_result cli_seek_file_begin(zend_file_handle *file_handle, char *scri
574574
{
575575
FILE *fp = VCWD_FOPEN(script_file, "rb");
576576
if (!fp) {
577-
php_printf("Could not open input file: %s\n", script_file);
577+
fprintf(stderr, "Could not open input file: %s\n", script_file);
578578
return FAILURE;
579579
}
580580

sapi/litespeed/lsapi_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ static int cli_main( int argc, char * argv[] )
13471347
php_request_shutdown( NULL );
13481348
}
13491349
} else {
1350-
php_printf("Could not open input file: %s.\n", *p);
1350+
fprintf(stderr, "Could not open input file: %s.\n", *p);
13511351
}
13521352
} else {
13531353
cli_usage();

0 commit comments

Comments
 (0)