Skip to content

Commit c7d7af8

Browse files
committed
Remove fgetss and friends
These were deprecated in PHP 7.3 as part of https://wiki.php.net/rfc/deprecations_php_7_3.
1 parent 83bc092 commit c7d7af8

26 files changed

+8
-3954
lines changed

UPGRADING

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,21 @@ PHP 8.0 UPGRADE NOTES
6464
* mbereg_search_getpos() -> mb_ereg_search_getpos()
6565
* mbereg_search_setpos() -> mb_ereg_search_setpos()
6666

67+
- SPL:
68+
. SplFileObject::fgetss() has been removed.
69+
6770
- Standard:
6871
. assert() will no longer evaluate string arguments, instead they will be
6972
treated like any other argument. assert($a == $b) should be used instead of
7073
assert('$a == $b'). The assert.quiet_eval ini directive and
7174
ASSERT_QUIET_EVAL constants have also been removed, as they would no longer
7275
have any effect.
7376
. parse_str() can no longer be used without specifying a result array.
77+
. fgetss() has been removed.
78+
. The string.strip_tags filter has been removed.
79+
80+
- Zlib:
81+
. gzgetss() has been removed.
7482

7583
========================================
7684
2. New Features

ext/opcache/Optimizer/zend_func_info.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ static const func_info_t func_infos[] = {
615615
F0("feof", MAY_BE_FALSE | MAY_BE_TRUE),
616616
F1("fgetc", MAY_BE_FALSE | MAY_BE_STRING),
617617
F1("fgets", MAY_BE_FALSE | MAY_BE_STRING),
618-
F1("fgetss", MAY_BE_FALSE | MAY_BE_STRING),
619618
F1("fread", MAY_BE_FALSE | MAY_BE_STRING),
620619
F1("fopen", MAY_BE_FALSE | MAY_BE_RESOURCE),
621620
F0("fpassthru", MAY_BE_FALSE | MAY_BE_LONG),
@@ -1263,7 +1262,6 @@ static const func_info_t func_infos[] = {
12631262
F0("gzeof", MAY_BE_FALSE | MAY_BE_TRUE),
12641263
F1("gzgetc", MAY_BE_FALSE | MAY_BE_STRING),
12651264
F1("gzgets", MAY_BE_FALSE | MAY_BE_STRING),
1266-
F1("gzgetss", MAY_BE_FALSE | MAY_BE_STRING),
12671265
F1("gzread", MAY_BE_FALSE | MAY_BE_STRING),
12681266
F1("gzopen", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_RESOURCE),
12691267
F0("gzpassthru", MAY_BE_FALSE | MAY_BE_LONG),

ext/spl/spl_directory.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,30 +2826,6 @@ SPL_METHOD(SplFileObject, fgetc)
28262826
}
28272827
} /* }}} */
28282828

2829-
/* {{{ proto string SplFileObject::fgetss([string allowable_tags])
2830-
Get a line from file pointer and strip HTML tags */
2831-
SPL_METHOD(SplFileObject, fgetss)
2832-
{
2833-
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
2834-
zval arg2;
2835-
2836-
if(!intern->u.file.stream) {
2837-
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized");
2838-
return;
2839-
}
2840-
2841-
if (intern->u.file.max_line_len > 0) {
2842-
ZVAL_LONG(&arg2, intern->u.file.max_line_len);
2843-
} else {
2844-
ZVAL_LONG(&arg2, 1024);
2845-
}
2846-
2847-
spl_filesystem_file_free_line(intern);
2848-
intern->u.file.current_line_num++;
2849-
2850-
FileFunctionCall(fgetss, ZEND_NUM_ARGS(), &arg2);
2851-
} /* }}} */
2852-
28532829
/* {{{ proto int SplFileObject::fpassthru()
28542830
Output all remaining data from a file pointer */
28552831
SPL_METHOD(SplFileObject, fpassthru)
@@ -3038,10 +3014,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fseek, 0, 0, 1)
30383014
ZEND_ARG_INFO(0, whence)
30393015
ZEND_END_ARG_INFO()
30403016

3041-
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fgetss, 0, 0, 0)
3042-
ZEND_ARG_INFO(0, allowable_tags)
3043-
ZEND_END_ARG_INFO()
3044-
30453017
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fscanf, 0, 0, 1)
30463018
ZEND_ARG_INFO(0, format)
30473019
ZEND_ARG_VARIADIC_INFO(1, vars)
@@ -3080,7 +3052,6 @@ static const zend_function_entry spl_SplFileObject_functions[] = {
30803052
SPL_ME(SplFileObject, fseek, arginfo_file_object_fseek, ZEND_ACC_PUBLIC)
30813053
SPL_ME(SplFileObject, fgetc, arginfo_splfileinfo_void, ZEND_ACC_PUBLIC)
30823054
SPL_ME(SplFileObject, fpassthru, arginfo_splfileinfo_void, ZEND_ACC_PUBLIC)
3083-
SPL_ME(SplFileObject, fgetss, arginfo_file_object_fgetss, ZEND_ACC_PUBLIC)
30843055
SPL_ME(SplFileObject, fscanf, arginfo_file_object_fscanf, ZEND_ACC_PUBLIC)
30853056
SPL_ME(SplFileObject, fwrite, arginfo_file_object_fwrite, ZEND_ACC_PUBLIC)
30863057
SPL_ME(SplFileObject, fread, arginfo_file_object_fread, ZEND_ACC_PUBLIC)

ext/spl/tests/bug45216.phpt

Lines changed: 0 additions & 25 deletions
This file was deleted.

ext/standard/basic_functions.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,12 +1101,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_fgetc, 0)
11011101
ZEND_ARG_INFO(0, fp)
11021102
ZEND_END_ARG_INFO()
11031103

1104-
ZEND_BEGIN_ARG_INFO_EX(arginfo_fgetss, 0, 0, 1)
1105-
ZEND_ARG_INFO(0, fp)
1106-
ZEND_ARG_INFO(0, length)
1107-
ZEND_ARG_INFO(0, allowable_tags)
1108-
ZEND_END_ARG_INFO()
1109-
11101104
ZEND_BEGIN_ARG_INFO_EX(arginfo_fscanf, 0, 0, 2)
11111105
ZEND_ARG_INFO(0, stream)
11121106
ZEND_ARG_INFO(0, format)
@@ -3132,7 +3126,6 @@ static const zend_function_entry basic_functions[] = { /* {{{ */
31323126
PHP_FE(feof, arginfo_feof)
31333127
PHP_FE(fgetc, arginfo_fgetc)
31343128
PHP_FE(fgets, arginfo_fgets)
3135-
PHP_DEP_FE(fgetss, arginfo_fgetss)
31363129
PHP_FE(fread, arginfo_fread)
31373130
PHP_NAMED_FE(fopen, php_if_fopen, arginfo_fopen)
31383131
PHP_FE(fpassthru, arginfo_fpassthru)

ext/standard/file.c

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,55 +1090,6 @@ PHPAPI PHP_FUNCTION(fgetc)
10901090
}
10911091
/* }}} */
10921092

1093-
/* {{{ proto string fgetss(resource fp [, int length [, string allowable_tags]])
1094-
Get a line from file pointer and strip HTML tags */
1095-
PHPAPI PHP_FUNCTION(fgetss)
1096-
{
1097-
zval *fd;
1098-
zend_long bytes = 0;
1099-
size_t len = 0;
1100-
size_t actual_len, retval_len;
1101-
char *buf = NULL, *retval;
1102-
php_stream *stream;
1103-
char *allowed_tags=NULL;
1104-
size_t allowed_tags_len=0;
1105-
1106-
ZEND_PARSE_PARAMETERS_START(1, 3)
1107-
Z_PARAM_RESOURCE(fd)
1108-
Z_PARAM_OPTIONAL
1109-
Z_PARAM_LONG(bytes)
1110-
Z_PARAM_STRING(allowed_tags, allowed_tags_len)
1111-
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
1112-
1113-
PHP_STREAM_TO_ZVAL(stream, fd);
1114-
1115-
if (ZEND_NUM_ARGS() >= 2) {
1116-
if (bytes <= 0) {
1117-
php_error_docref(NULL, E_WARNING, "Length parameter must be greater than 0");
1118-
RETURN_FALSE;
1119-
}
1120-
1121-
len = (size_t) bytes;
1122-
buf = safe_emalloc(sizeof(char), (len + 1), 0);
1123-
/*needed because recv doesn't set null char at end*/
1124-
memset(buf, 0, len + 1);
1125-
}
1126-
1127-
if ((retval = php_stream_get_line(stream, buf, len, &actual_len)) == NULL) {
1128-
if (buf != NULL) {
1129-
efree(buf);
1130-
}
1131-
RETURN_FALSE;
1132-
}
1133-
1134-
retval_len = php_strip_tags(retval, actual_len, &stream->fgetss_state, allowed_tags, allowed_tags_len);
1135-
1136-
// TODO: avoid reallocation ???
1137-
RETVAL_STRINGL(retval, retval_len);
1138-
efree(retval);
1139-
}
1140-
/* }}} */
1141-
11421093
/* {{{ proto mixed fscanf(resource stream, string format [, string ...])
11431094
Implements a mostly ANSI compatible fscanf() */
11441095
PHP_FUNCTION(fscanf)
@@ -1986,8 +1937,6 @@ PHP_FUNCTION(fgetcsv)
19861937
char enclosure = '"'; /* allow this to be set as parameter */
19871938
int escape = (unsigned char) '\\';
19881939

1989-
/* first section exactly as php_fgetss */
1990-
19911940
zend_long len = 0;
19921941
size_t buf_len;
19931942
char *buf;

ext/standard/file.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ PHPAPI PHP_FUNCTION(fread);
3535
PHPAPI PHP_FUNCTION(fgetc);
3636
PHPAPI PHP_FUNCTION(fgets);
3737
PHP_FUNCTION(fscanf);
38-
PHPAPI PHP_FUNCTION(fgetss);
3938
PHP_FUNCTION(fgetcsv);
4039
PHP_FUNCTION(fputcsv);
4140
PHPAPI PHP_FUNCTION(fwrite);

ext/standard/filters.c

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -166,129 +166,6 @@ static const php_stream_filter_factory strfilter_tolower_factory = {
166166
};
167167
/* }}} */
168168

169-
/* {{{ strip_tags filter implementation */
170-
typedef struct _php_strip_tags_filter {
171-
const char *allowed_tags;
172-
int allowed_tags_len;
173-
uint8_t state;
174-
uint8_t persistent;
175-
} php_strip_tags_filter;
176-
177-
static int php_strip_tags_filter_ctor(php_strip_tags_filter *inst, zend_string *allowed_tags, int persistent)
178-
{
179-
if (allowed_tags != NULL) {
180-
if (NULL == (inst->allowed_tags = pemalloc(ZSTR_LEN(allowed_tags) + 1, persistent))) {
181-
return FAILURE;
182-
}
183-
memcpy((char *)inst->allowed_tags, ZSTR_VAL(allowed_tags), ZSTR_LEN(allowed_tags) + 1);
184-
inst->allowed_tags_len = (int)ZSTR_LEN(allowed_tags);
185-
} else {
186-
inst->allowed_tags = NULL;
187-
}
188-
inst->state = 0;
189-
inst->persistent = persistent;
190-
191-
return SUCCESS;
192-
}
193-
194-
static void php_strip_tags_filter_dtor(php_strip_tags_filter *inst)
195-
{
196-
if (inst->allowed_tags != NULL) {
197-
pefree((void *)inst->allowed_tags, inst->persistent);
198-
}
199-
}
200-
201-
static php_stream_filter_status_t strfilter_strip_tags_filter(
202-
php_stream *stream,
203-
php_stream_filter *thisfilter,
204-
php_stream_bucket_brigade *buckets_in,
205-
php_stream_bucket_brigade *buckets_out,
206-
size_t *bytes_consumed,
207-
int flags
208-
)
209-
{
210-
php_stream_bucket *bucket;
211-
size_t consumed = 0;
212-
php_strip_tags_filter *inst = (php_strip_tags_filter *) Z_PTR(thisfilter->abstract);
213-
214-
while (buckets_in->head) {
215-
bucket = php_stream_bucket_make_writeable(buckets_in->head);
216-
consumed = bucket->buflen;
217-
218-
bucket->buflen = php_strip_tags(bucket->buf, bucket->buflen, &(inst->state), inst->allowed_tags, inst->allowed_tags_len);
219-
220-
php_stream_bucket_append(buckets_out, bucket);
221-
}
222-
223-
if (bytes_consumed) {
224-
*bytes_consumed = consumed;
225-
}
226-
227-
return PSFS_PASS_ON;
228-
}
229-
230-
static void strfilter_strip_tags_dtor(php_stream_filter *thisfilter)
231-
{
232-
assert(Z_PTR(thisfilter->abstract) != NULL);
233-
234-
php_strip_tags_filter_dtor((php_strip_tags_filter *)Z_PTR(thisfilter->abstract));
235-
236-
pefree(Z_PTR(thisfilter->abstract), ((php_strip_tags_filter *)Z_PTR(thisfilter->abstract))->persistent);
237-
}
238-
239-
static const php_stream_filter_ops strfilter_strip_tags_ops = {
240-
strfilter_strip_tags_filter,
241-
strfilter_strip_tags_dtor,
242-
"string.strip_tags"
243-
};
244-
245-
static php_stream_filter *strfilter_strip_tags_create(const char *filtername, zval *filterparams, uint8_t persistent)
246-
{
247-
php_strip_tags_filter *inst;
248-
php_stream_filter *filter = NULL;
249-
zend_string *allowed_tags = NULL;
250-
251-
php_error_docref(NULL, E_DEPRECATED, "The string.strip_tags filter is deprecated");
252-
253-
inst = pemalloc(sizeof(php_strip_tags_filter), persistent);
254-
255-
if (filterparams != NULL) {
256-
if (Z_TYPE_P(filterparams) == IS_ARRAY) {
257-
smart_str tags_ss = {0};
258-
zval *tmp;
259-
260-
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(filterparams), tmp) {
261-
convert_to_string_ex(tmp);
262-
smart_str_appendc(&tags_ss, '<');
263-
smart_str_append(&tags_ss, Z_STR_P(tmp));
264-
smart_str_appendc(&tags_ss, '>');
265-
} ZEND_HASH_FOREACH_END();
266-
smart_str_0(&tags_ss);
267-
allowed_tags = tags_ss.s;
268-
} else {
269-
allowed_tags = zval_get_string(filterparams);
270-
}
271-
}
272-
273-
if (php_strip_tags_filter_ctor(inst, allowed_tags, persistent) == SUCCESS) {
274-
filter = php_stream_filter_alloc(&strfilter_strip_tags_ops, inst, persistent);
275-
} else {
276-
pefree(inst, persistent);
277-
}
278-
279-
if (allowed_tags) {
280-
zend_string_release(allowed_tags);
281-
}
282-
283-
return filter;
284-
}
285-
286-
static const php_stream_filter_factory strfilter_strip_tags_factory = {
287-
strfilter_strip_tags_create
288-
};
289-
290-
/* }}} */
291-
292169
/* {{{ base64 / quoted_printable stream filter implementation */
293170

294171
typedef enum _php_conv_err_t {
@@ -2037,7 +1914,6 @@ static const struct {
20371914
{ &strfilter_rot13_ops, &strfilter_rot13_factory },
20381915
{ &strfilter_toupper_ops, &strfilter_toupper_factory },
20391916
{ &strfilter_tolower_ops, &strfilter_tolower_factory },
2040-
{ &strfilter_strip_tags_ops, &strfilter_strip_tags_factory },
20411917
{ &strfilter_convert_ops, &strfilter_convert_factory },
20421918
{ &consumed_filter_ops, &consumed_filter_factory },
20431919
{ &chunked_filter_ops, &chunked_filter_factory },

0 commit comments

Comments
 (0)