Skip to content

Commit b760ae4

Browse files
committed
Remove deprecated iconv INI settings
1 parent 0e0c608 commit b760ae4

10 files changed

+64
-232
lines changed

ext/iconv/iconv.c

Lines changed: 3 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "ext/standard/info.h"
2626
#include "main/php_output.h"
2727
#include "SAPI.h"
28-
#include "php_ini.h"
2928

3029
#include <stdlib.h>
3130
#include <errno.h>
@@ -56,9 +55,6 @@
5655
#define _php_iconv_memequal(a, b, c) \
5756
(memcmp(a, b, c) == 0)
5857

59-
ZEND_DECLARE_MODULE_GLOBALS(iconv)
60-
static PHP_GINIT_FUNCTION(iconv);
61-
6258
/* {{{ iconv_module_entry
6359
*/
6460
zend_module_entry iconv_module_entry = {
@@ -71,11 +67,7 @@ zend_module_entry iconv_module_entry = {
7167
NULL,
7268
PHP_MINFO(miconv),
7369
PHP_ICONV_VERSION,
74-
PHP_MODULE_GLOBALS(iconv),
75-
PHP_GINIT(iconv),
76-
NULL,
77-
NULL,
78-
STANDARD_MODULE_PROPERTIES_EX
70+
STANDARD_MODULE_PROPERTIES,
7971
};
8072
/* }}} */
8173

@@ -86,18 +78,6 @@ ZEND_TSRMLS_CACHE_DEFINE()
8678
ZEND_GET_MODULE(iconv)
8779
#endif
8880

89-
/* {{{ PHP_GINIT_FUNCTION */
90-
static PHP_GINIT_FUNCTION(iconv)
91-
{
92-
#if defined(COMPILE_DL_ICONV) && defined(ZTS)
93-
ZEND_TSRMLS_CACHE_UPDATE();
94-
#endif
95-
iconv_globals->input_encoding = NULL;
96-
iconv_globals->output_encoding = NULL;
97-
iconv_globals->internal_encoding = NULL;
98-
}
99-
/* }}} */
100-
10181
#if defined(HAVE_LIBICONV) && defined(ICONV_ALIASED_LIBICONV)
10282
#define iconv libiconv
10383
#endif
@@ -142,62 +122,11 @@ static const char _generic_superset_name[] = ICONV_UCS4_ENCODING;
142122
#define GENERIC_SUPERSET_NBYTES 4
143123
/* }}} */
144124

145-
146-
static PHP_INI_MH(OnUpdateInputEncoding)
147-
{
148-
if (ZSTR_LEN(new_value) >= ICONV_CSNMAXLEN) {
149-
return FAILURE;
150-
}
151-
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
152-
php_error_docref("ref.iconv", E_DEPRECATED, "Use of iconv.input_encoding is deprecated");
153-
}
154-
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
155-
return SUCCESS;
156-
}
157-
158-
159-
static PHP_INI_MH(OnUpdateOutputEncoding)
160-
{
161-
if (ZSTR_LEN(new_value) >= ICONV_CSNMAXLEN) {
162-
return FAILURE;
163-
}
164-
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
165-
php_error_docref("ref.iconv", E_DEPRECATED, "Use of iconv.output_encoding is deprecated");
166-
}
167-
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
168-
return SUCCESS;
169-
}
170-
171-
172-
static PHP_INI_MH(OnUpdateInternalEncoding)
173-
{
174-
if (ZSTR_LEN(new_value) >= ICONV_CSNMAXLEN) {
175-
return FAILURE;
176-
}
177-
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
178-
php_error_docref("ref.iconv", E_DEPRECATED, "Use of iconv.internal_encoding is deprecated");
179-
}
180-
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
181-
return SUCCESS;
182-
}
183-
184-
185-
/* {{{ PHP_INI
186-
*/
187-
PHP_INI_BEGIN()
188-
STD_PHP_INI_ENTRY("iconv.input_encoding", "", PHP_INI_ALL, OnUpdateInputEncoding, input_encoding, zend_iconv_globals, iconv_globals)
189-
STD_PHP_INI_ENTRY("iconv.output_encoding", "", PHP_INI_ALL, OnUpdateOutputEncoding, output_encoding, zend_iconv_globals, iconv_globals)
190-
STD_PHP_INI_ENTRY("iconv.internal_encoding", "", PHP_INI_ALL, OnUpdateInternalEncoding, internal_encoding, zend_iconv_globals, iconv_globals)
191-
PHP_INI_END()
192-
/* }}} */
193-
194125
/* {{{ PHP_MINIT_FUNCTION */
195126
PHP_MINIT_FUNCTION(miconv)
196127
{
197128
char *version = "unknown";
198129

199-
REGISTER_INI_ENTRIES();
200-
201130
#if HAVE_LIBICONV
202131
{
203132
static char buf[16];
@@ -236,7 +165,6 @@ PHP_MINIT_FUNCTION(miconv)
236165
PHP_MSHUTDOWN_FUNCTION(miconv)
237166
{
238167
php_iconv_stream_filter_unregister_factory();
239-
UNREGISTER_INI_ENTRIES();
240168
return SUCCESS;
241169
}
242170
/* }}} */
@@ -254,29 +182,18 @@ PHP_MINFO_FUNCTION(miconv)
254182
php_info_print_table_row(2, "iconv implementation", Z_STRVAL_P(iconv_impl));
255183
php_info_print_table_row(2, "iconv library version", Z_STRVAL_P(iconv_ver));
256184
php_info_print_table_end();
257-
258-
DISPLAY_INI_ENTRIES();
259185
}
260186
/* }}} */
261187

262188
static const char *get_internal_encoding(void) {
263-
if (ICONVG(internal_encoding) && ICONVG(internal_encoding)[0]) {
264-
return ICONVG(internal_encoding);
265-
}
266189
return php_get_internal_encoding();
267190
}
268191

269192
static const char *get_input_encoding(void) {
270-
if (ICONVG(input_encoding) && ICONVG(input_encoding)[0]) {
271-
return ICONVG(input_encoding);
272-
}
273193
return php_get_input_encoding();
274194
}
275195

276196
static const char *get_output_encoding(void) {
277-
if (ICONVG(output_encoding) && ICONVG(output_encoding)[0]) {
278-
return ICONVG(output_encoding);
279-
}
280197
return php_get_output_encoding();
281198
}
282199

@@ -2269,8 +2186,7 @@ PHP_FUNCTION(iconv_set_encoding)
22692186
{
22702187
char *type;
22712188
zend_string *charset;
2272-
size_t type_len, retval;
2273-
zend_string *name;
2189+
size_t type_len;
22742190

22752191
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sS", &type, &type_len, &charset) == FAILURE) {
22762192
RETURN_THROWS();
@@ -2281,24 +2197,7 @@ PHP_FUNCTION(iconv_set_encoding)
22812197
RETURN_FALSE;
22822198
}
22832199

2284-
if(!strcasecmp("input_encoding", type)) {
2285-
name = zend_string_init("iconv.input_encoding", sizeof("iconv.input_encoding") - 1, 0);
2286-
} else if(!strcasecmp("output_encoding", type)) {
2287-
name = zend_string_init("iconv.output_encoding", sizeof("iconv.output_encoding") - 1, 0);
2288-
} else if(!strcasecmp("internal_encoding", type)) {
2289-
name = zend_string_init("iconv.internal_encoding", sizeof("iconv.internal_encoding") - 1, 0);
2290-
} else {
2291-
RETURN_FALSE;
2292-
}
2293-
2294-
retval = zend_alter_ini_entry(name, charset, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
2295-
zend_string_release_ex(name, 0);
2296-
2297-
if (retval == SUCCESS) {
2298-
RETURN_TRUE;
2299-
} else {
2300-
RETURN_FALSE;
2301-
}
2200+
RETURN_FALSE;
23022201
}
23032202
/* }}} */
23042203

ext/iconv/iconv.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ function iconv_mime_decode_headers(string $headers, int $mode = 0, string $chars
1818

1919
function iconv(string $in_charset, string $out_charset, string $str): string|false {}
2020

21+
/** @deprecated */
2122
function iconv_set_encoding(string $type, string $charset): bool {}
2223

24+
/** TODO Should be deprecated? */
2325
function iconv_get_encoding(string $type = 'all'): array|string|false {}

ext/iconv/iconv_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static const zend_function_entry ext_functions[] = {
8080
ZEND_FE(iconv_mime_decode, arginfo_iconv_mime_decode)
8181
ZEND_FE(iconv_mime_decode_headers, arginfo_iconv_mime_decode_headers)
8282
ZEND_FE(iconv, arginfo_iconv)
83-
ZEND_FE(iconv_set_encoding, arginfo_iconv_set_encoding)
83+
ZEND_DEP_FE(iconv_set_encoding, arginfo_iconv_set_encoding)
8484
ZEND_FE(iconv_get_encoding, arginfo_iconv_get_encoding)
8585
ZEND_FE_END
8686
};

ext/iconv/php_iconv.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ PHP_FUNCTION(iconv_mime_encode);
6565
PHP_FUNCTION(iconv_mime_decode);
6666
PHP_FUNCTION(iconv_mime_decode_headers);
6767

68-
ZEND_BEGIN_MODULE_GLOBALS(iconv)
69-
char *input_encoding;
70-
char *internal_encoding;
71-
char *output_encoding;
72-
ZEND_END_MODULE_GLOBALS(iconv)
73-
74-
#define ICONVG(v) ZEND_MODULE_GLOBALS_ACCESSOR(iconv, v)
75-
7668
#if defined(ZTS) && defined(COMPILE_DL_ICONV)
7769
ZEND_TSRMLS_CACHE_EXTERN()
7870
#endif

ext/iconv/tests/iconv_default_charset.phpt

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ extension_loaded('iconv') or die('skip');
66
function_exists('iconv_get_encoding') or die("skip iconv_get_encoding() is not available in this build");
77
?>
88
--INI--
9-
error_reporting=E_ALL & ~E_DEPRECATED
9+
error_reporting=E_ALL
1010
default_charset=UTF-8
1111
internal_encoding=
1212
input_encoding=
1313
output_encoding=
14-
iconv.internal_encoding=
15-
iconv.input_encoding=
16-
iconv.output_encoding=
1714
--FILE--
1815
<?php
1916
echo "*** Testing default_charset handling ***\n";
@@ -39,17 +36,6 @@ var_dump(ini_get('default_charset'),
3936
ini_get('iconv.input_encoding'),
4037
ini_get('iconv.output_encoding'));
4138

42-
/*
43-
echo "\n--- Altering encodings ---\n";
44-
var_dump(ini_set('default_charset', 'ISO-8859-1'),
45-
ini_set('internal_encoding'),
46-
ini_set('input_encoding'),
47-
ini_set('output_encoding'),
48-
ini_set('iconv.internal_encoding'),
49-
ini_set('iconv.input_encoding'),
50-
ini_set('iconv.output_encoding'));
51-
*/
52-
5339
echo "Done";
5440
?>
5541
--EXPECT--
@@ -59,9 +45,9 @@ string(5) "UTF-8"
5945
string(0) ""
6046
string(0) ""
6147
string(0) ""
62-
string(0) ""
63-
string(0) ""
64-
string(0) ""
48+
bool(false)
49+
bool(false)
50+
bool(false)
6551

6652
--- Altering encodings ---
6753
string(5) "UTF-8"
@@ -71,7 +57,7 @@ string(10) "ISO-8859-1"
7157
string(0) ""
7258
string(0) ""
7359
string(0) ""
74-
string(0) ""
75-
string(0) ""
76-
string(0) ""
60+
bool(false)
61+
bool(false)
62+
bool(false)
7763
Done

ext/iconv/tests/iconv_encoding_basic.phpt

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ extension_loaded('iconv') or die('skip');
66
function_exists('iconv_get_encoding') or die("skip iconv_get_encoding() is not available in this build");
77
?>
88
--INI--
9-
error_reporting=E_ALL & ~E_DEPRECATED
9+
error_reporting=E_ALL
1010
input_encoding=ISO-8859-1
11-
iconv.internal_encoding=ISO-8859-1
12-
iconv.output_encoding=ISO-8859-1
1311
--FILE--
1412
<?php
1513
/* Prototype : mixed iconv_get_encoding([string type])
@@ -48,49 +46,55 @@ var_dump(iconv_get_encoding("all"));
4846

4947
echo "Done";
5048
?>
51-
--EXPECT--
49+
--EXPECTF--
5250
*** Testing iconv_get_encoding()/iconv_set_encoding() : basic functionality ***
5351
--- Default get_encoding ---
5452
array(3) {
5553
["input_encoding"]=>
5654
string(10) "ISO-8859-1"
5755
["output_encoding"]=>
58-
string(10) "ISO-8859-1"
56+
string(5) "UTF-8"
5957
["internal_encoding"]=>
60-
string(10) "ISO-8859-1"
58+
string(5) "UTF-8"
6159
}
6260
string(10) "ISO-8859-1"
63-
string(10) "ISO-8859-1"
64-
string(10) "ISO-8859-1"
61+
string(5) "UTF-8"
62+
string(5) "UTF-8"
6563
array(3) {
6664
["input_encoding"]=>
6765
string(10) "ISO-8859-1"
6866
["output_encoding"]=>
69-
string(10) "ISO-8859-1"
67+
string(5) "UTF-8"
7068
["internal_encoding"]=>
71-
string(10) "ISO-8859-1"
69+
string(5) "UTF-8"
7270
}
7371

7472
--- Altering encodings ---
75-
bool(true)
76-
bool(true)
77-
bool(true)
73+
74+
Deprecated: Function iconv_set_encoding() is deprecated in %s on line %d
75+
bool(false)
76+
77+
Deprecated: Function iconv_set_encoding() is deprecated in %s on line %d
78+
bool(false)
79+
80+
Deprecated: Function iconv_set_encoding() is deprecated in %s on line %d
81+
bool(false)
7882

7983
--- results of alterations ---
8084
array(3) {
8185
["input_encoding"]=>
82-
string(5) "UTF-8"
86+
string(10) "ISO-8859-1"
8387
["output_encoding"]=>
8488
string(5) "UTF-8"
8589
["internal_encoding"]=>
8690
string(5) "UTF-8"
8791
}
88-
string(5) "UTF-8"
92+
string(10) "ISO-8859-1"
8993
string(5) "UTF-8"
9094
string(5) "UTF-8"
9195
array(3) {
9296
["input_encoding"]=>
93-
string(5) "UTF-8"
97+
string(10) "ISO-8859-1"
9498
["output_encoding"]=>
9599
string(5) "UTF-8"
96100
["internal_encoding"]=>

0 commit comments

Comments
 (0)