-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Do not inherit LC_CTYPE locale from environment #5488
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
net-snmp's ext/snmp/snmp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index 8464e74aad..47a47f559b 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -49,6 +49,7 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#include <locale.h>
#ifndef __P
#ifdef __GNUC__
@@ -1971,6 +1972,7 @@ PHP_MINIT_FUNCTION(snmp)
le_snmp_session = zend_register_list_destructors_ex(php_snmp_session_destructor, NULL, PHP_SNMP_SESSION_RES_NAME, module_number);
init_snmp("snmpapp");
+ setlocale(LC_ALL, "C");
#ifdef NETSNMP_DS_LIB_DONT_PERSIST_STATE
/* Prevent update of the snmpapp.conf file */ |
Seems to work as desired. We would have to fix 2 Windows tests, or apply PR #5481. |
For some reason the |
php_basename uses php_mblen so maybe basename() is locale-sensitive. I don't get why there is no diff though. |
@nikic I ran this test locally on MacOS, and it shows the following diff:
|
Maybe the diff can't be rendered due to invalid UTF-8? Anyhow, from the docs:
Isn't that lovely. ;) |
The basename() issue should be fixed by 90705d4. That was an implementation bug that got uncovered by this change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this! :)
Big +1 for this, it is a good step forward |
Related to php#5488 which makes php-src start out with the C locale for all locales, including LC_CTYPE in php 8. Example: An application sets `setlocale(LC_CTYPE, "C")` to work around issues with strtolower not working on turkish, and unexpectedly gets slightly worse performance.
Apparently, the way setlocale inheritance currently works in PHP is as follows:
This PR removes locale inheritance completely. On startup we will stay at the default of LC_ALL="C". Changing the locale requires an explicit setlocale() call.