Skip to content

Commit fae2246

Browse files
committed
Deprecate case-insensitive constants via typelib import
As of PHP 7.3.0, case-insensitive constants are deprecated. We catch up on this with regard to ext/com_dotnet, which allows to import constants from typelibs, by triggering a deprecation notice whenever `com_load_typelib()` is called with `$case_sensitive` being `false`, and whenever `com.autoregister_casesensitive` is set to `false`, regardless of whether there are actually constants in the typelib which would be imported.
1 parent ade9d5e commit fae2246

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ PHP NEWS
1010
. Fixed bug #75921 (Inconsistent: No warning in some cases when stdObj is
1111
created on the fly). (David Walker)
1212

13+
- COM:
14+
. Deprecated registering of case-insensitive constants from typelibs. (cmb)
15+
1316
- CURL:
1417
. Fixed bug #76480 (Use curl_multi_wait() so that timeouts are respected).
1518
(Pierrick)

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ PHP 7.4 UPGRADE NOTES
149149
so is equivalent to calling a non-static method statically, which has been
150150
deprecated since PHP 7.0.
151151

152+
- COM:
153+
. Importing type libraries with case-insensitive constant registering has been
154+
deprecated.
155+
152156
- Mbstring:
153157
. Passing a non-string pattern to mb_ereg_replace() is deprecated. Currently
154158
non-string patterns are interpreted as ASCII codepoints. In PHP 8 the

ext/com_dotnet/com_com.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,10 @@ PHP_FUNCTION(com_load_typelib)
831831
return;
832832
}
833833

834+
if (!cs) {
835+
php_error_docref(NULL, E_DEPRECATED, "Declaration of case-insensitive constants is deprecated");
836+
}
837+
834838
RETVAL_FALSE;
835839

836840
php_com_initialize();

ext/com_dotnet/com_extension.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,19 @@ static PHP_INI_MH(OnTypeLibFileUpdate)
265265
return SUCCESS;
266266
}
267267

268+
static ZEND_INI_MH(OnAutoregisterCasesensitive)
269+
{
270+
if (!zend_ini_parse_bool(new_value)) {
271+
php_error_docref("com.configuration", E_DEPRECATED, "Declaration of case-insensitive constants is deprecated");
272+
}
273+
return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
274+
}
275+
268276
PHP_INI_BEGIN()
269277
STD_PHP_INI_ENTRY("com.allow_dcom", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_dcom, zend_com_dotnet_globals, com_dotnet_globals)
270278
STD_PHP_INI_ENTRY("com.autoregister_verbose", "0", PHP_INI_ALL, OnUpdateBool, autoreg_verbose, zend_com_dotnet_globals, com_dotnet_globals)
271279
STD_PHP_INI_ENTRY("com.autoregister_typelib", "0", PHP_INI_ALL, OnUpdateBool, autoreg_on, zend_com_dotnet_globals, com_dotnet_globals)
272-
STD_PHP_INI_ENTRY("com.autoregister_casesensitive", "1", PHP_INI_ALL, OnUpdateBool, autoreg_case_sensitive, zend_com_dotnet_globals, com_dotnet_globals)
280+
STD_PHP_INI_ENTRY("com.autoregister_casesensitive", "1", PHP_INI_ALL, OnAutoregisterCasesensitive, autoreg_case_sensitive, zend_com_dotnet_globals, com_dotnet_globals)
273281
STD_PHP_INI_ENTRY("com.code_page", "", PHP_INI_ALL, OnUpdateLong, code_page, zend_com_dotnet_globals, com_dotnet_globals)
274282
PHP_INI_ENTRY("com.typelib_file", "", PHP_INI_SYSTEM, OnTypeLibFileUpdate)
275283
PHP_INI_END()

0 commit comments

Comments
 (0)