Skip to content

Commit 2b32caf

Browse files
DmitryMaksimovcmb69
authored andcommitted
Use neutral language instead of default on Windows
Most notably, this affects some Windows specific error messages, which are no longer in the default language of the system, to better match error messages provided by PHP which are not localized anyway. This also affects the com_dotnet extension, where it could fix some DCOM related issues. Furthermore, the constant `LOCALE_NEUTRAL` is added, which can be used for `variant_cmp()`. Closes GH-7613.
1 parent 0497b2b commit 2b32caf

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

UPGRADING

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ PHP 8.2 UPGRADE NOTES
108108
10. New Global Constants
109109
========================================
110110

111+
- COM_DOTNET:
112+
. LOCALE_NEUTRAL
113+
111114
========================================
112115
11. Changes to INI File Handling
113116
========================================
@@ -116,6 +119,10 @@ PHP 8.2 UPGRADE NOTES
116119
12. Windows Support
117120
========================================
118121

122+
- Core:
123+
. Windows specific error messages are no longer localized, but instead in
124+
English to better match PHP error messages.
125+
119126
========================================
120127
13. Other Changes
121128
========================================

ext/com_dotnet/com_extension.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ PHP_MINIT_FUNCTION(com_dotnet)
245245
COM_CONST(VARCMP_GT);
246246
COM_CONST(VARCMP_NULL);
247247
COM_CONST(LOCALE_SYSTEM_DEFAULT);
248+
COM_CONST(LOCALE_NEUTRAL);
248249

249250
COM_CONST(NORM_IGNORECASE);
250251
COM_CONST(NORM_IGNORENONSPACE);

ext/com_dotnet/com_handlers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name
326326

327327
if (SUCCEEDED(ITypeInfo_GetTypeComp(obj->typeinfo, &comp))) {
328328
olename = php_com_string_to_olestring(name->val, name->len, obj->code_page);
329-
lhash = LHashValOfNameSys(SYS_WIN32, LOCALE_SYSTEM_DEFAULT, olename);
329+
lhash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, olename);
330330

331331
if (SUCCEEDED(ITypeComp_Bind(comp, olename, lhash, INVOKE_FUNC, &TI, &kind, &bindptr))) {
332332
switch (kind) {
@@ -410,7 +410,7 @@ static int com_objects_compare(zval *object1, zval *object2)
410410
obja = CDNO_FETCH(object1);
411411
objb = CDNO_FETCH(object2);
412412

413-
switch (VarCmp(&obja->v, &objb->v, LOCALE_SYSTEM_DEFAULT, 0)) {
413+
switch (VarCmp(&obja->v, &objb->v, LOCALE_NEUTRAL, 0)) {
414414
case VARCMP_LT:
415415
ret = -1;
416416
break;

ext/com_dotnet/com_iterator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int b
200200
} else {
201201
/* can we enumerate it? */
202202
if (FAILED(IDispatch_Invoke(V_DISPATCH(&obj->v), DISPID_NEWENUM,
203-
&IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD|DISPATCH_PROPERTYGET,
203+
&IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD|DISPATCH_PROPERTYGET,
204204
&dp, &v, NULL, NULL))) {
205205
goto fail;
206206
}

win32/winutil.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error)
2929

3030
DWORD ret = FormatMessageW(
3131
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
32-
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&bufw, 0, NULL
32+
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), (LPWSTR)&bufw, 0, NULL
3333
);
3434

3535
if (!ret || !bufw) {

0 commit comments

Comments
 (0)