Skip to content
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 GH-12778: Windows IIS FastCGI Spin-Up Performance Slowdown #12784

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ PHP 8.4 INTERNALS UPGRADE NOTES
========================
5. SAPI changes
========================

* The LC_CTYPE locale is no longer overridden at module startup to C.UTF-8.
This was originally introduced to fix an issue with UTF-8 characters when
libedit was used for providing the readline functionality. The new fix now
delays the locale reset until the readline functionality is actually used.
SAPIs relying on this behaviour must manually call zend_reset_lc_ctype_locale().
This change is done to fix a performance regression.
See https://github.com/php/php-src/pull/12784.
11 changes: 11 additions & 0 deletions ext/readline/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ PHP_MINFO_FUNCTION(readline)

/* }}} */

static void php_readline_fix_locale() {
/* Yes, this variable is process-wide, but so is the locale setting. */
static bool locale_fixed = false;
if (!locale_fixed) {
locale_fixed = true;
zend_reset_lc_ctype_locale();
}
}

/* {{{ Reads a line */
PHP_FUNCTION(readline)
{
Expand All @@ -126,6 +135,8 @@ PHP_FUNCTION(readline)
RETURN_THROWS();
}

php_readline_fix_locale();

result = readline(prompt);

if (! result) {
Expand Down
2 changes: 2 additions & 0 deletions ext/readline/readline_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ static int readline_shell_run(void) /* {{{ */
#endif
read_history(history_file);

zend_reset_lc_ctype_locale();

EG(exit_status) = 0;
while ((line = readline(ZSTR_VAL(prompt))) != NULL) {
if (strcmp(line, "exit") == 0 || strcmp(line, "quit") == 0) {
Expand Down
1 change: 0 additions & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,6 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
zuf.getenv_function = sapi_getenv;
zuf.resolve_path_function = php_resolve_path_for_zend;
zend_startup(&zuf);
zend_reset_lc_ctype_locale();
zend_update_current_locale();

zend_observer_startup();
Expand Down
2 changes: 2 additions & 0 deletions sapi/phpdbg/phpdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,8 @@ int main(int argc, char **argv) /* {{{ */
PHPDBG_G(flags) = flags;

if (phpdbg->startup(phpdbg) == SUCCESS) {
zend_reset_lc_ctype_locale();

zend_mm_heap *mm_heap;
#ifdef _WIN32
EXCEPTION_POINTERS *xp;
Expand Down
Loading