From: Nikita Popov Date: Mon, 28 Jan 2019 16:40:39 +0000 (+0100) Subject: Remove fgetss and friends X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7d7af8069246c886606501e30e6e8741e6683c2;p=php Remove fgetss and friends These were deprecated in PHP 7.3 as part of https://wiki.php.net/rfc/deprecations_php_7_3. --- diff --git a/UPGRADING b/UPGRADING index c96c4bcf91..98667b0091 100644 --- a/UPGRADING +++ b/UPGRADING @@ -64,6 +64,9 @@ PHP 8.0 UPGRADE NOTES * mbereg_search_getpos() -> mb_ereg_search_getpos() * mbereg_search_setpos() -> mb_ereg_search_setpos() +- SPL: + . SplFileObject::fgetss() has been removed. + - Standard: . assert() will no longer evaluate string arguments, instead they will be treated like any other argument. assert($a == $b) should be used instead of @@ -71,6 +74,11 @@ PHP 8.0 UPGRADE NOTES ASSERT_QUIET_EVAL constants have also been removed, as they would no longer have any effect. . parse_str() can no longer be used without specifying a result array. + . fgetss() has been removed. + . The string.strip_tags filter has been removed. + +- Zlib: + . gzgetss() has been removed. ======================================== 2. New Features diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 7405913846..f14c3faa0d 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -615,7 +615,6 @@ static const func_info_t func_infos[] = { F0("feof", MAY_BE_FALSE | MAY_BE_TRUE), F1("fgetc", MAY_BE_FALSE | MAY_BE_STRING), F1("fgets", MAY_BE_FALSE | MAY_BE_STRING), - F1("fgetss", MAY_BE_FALSE | MAY_BE_STRING), F1("fread", MAY_BE_FALSE | MAY_BE_STRING), F1("fopen", MAY_BE_FALSE | MAY_BE_RESOURCE), F0("fpassthru", MAY_BE_FALSE | MAY_BE_LONG), @@ -1263,7 +1262,6 @@ static const func_info_t func_infos[] = { F0("gzeof", MAY_BE_FALSE | MAY_BE_TRUE), F1("gzgetc", MAY_BE_FALSE | MAY_BE_STRING), F1("gzgets", MAY_BE_FALSE | MAY_BE_STRING), - F1("gzgetss", MAY_BE_FALSE | MAY_BE_STRING), F1("gzread", MAY_BE_FALSE | MAY_BE_STRING), F1("gzopen", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_RESOURCE), F0("gzpassthru", MAY_BE_FALSE | MAY_BE_LONG), diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index ccfbea03e3..43377ba012 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -2826,30 +2826,6 @@ SPL_METHOD(SplFileObject, fgetc) } } /* }}} */ -/* {{{ proto string SplFileObject::fgetss([string allowable_tags]) - Get a line from file pointer and strip HTML tags */ -SPL_METHOD(SplFileObject, fgetss) -{ - spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS); - zval arg2; - - if(!intern->u.file.stream) { - zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized"); - return; - } - - if (intern->u.file.max_line_len > 0) { - ZVAL_LONG(&arg2, intern->u.file.max_line_len); - } else { - ZVAL_LONG(&arg2, 1024); - } - - spl_filesystem_file_free_line(intern); - intern->u.file.current_line_num++; - - FileFunctionCall(fgetss, ZEND_NUM_ARGS(), &arg2); -} /* }}} */ - /* {{{ proto int SplFileObject::fpassthru() Output all remaining data from a file pointer */ SPL_METHOD(SplFileObject, fpassthru) @@ -3038,10 +3014,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fseek, 0, 0, 1) ZEND_ARG_INFO(0, whence) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fgetss, 0, 0, 0) - ZEND_ARG_INFO(0, allowable_tags) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fscanf, 0, 0, 1) ZEND_ARG_INFO(0, format) ZEND_ARG_VARIADIC_INFO(1, vars) @@ -3080,7 +3052,6 @@ static const zend_function_entry spl_SplFileObject_functions[] = { SPL_ME(SplFileObject, fseek, arginfo_file_object_fseek, ZEND_ACC_PUBLIC) SPL_ME(SplFileObject, fgetc, arginfo_splfileinfo_void, ZEND_ACC_PUBLIC) SPL_ME(SplFileObject, fpassthru, arginfo_splfileinfo_void, ZEND_ACC_PUBLIC) - SPL_ME(SplFileObject, fgetss, arginfo_file_object_fgetss, ZEND_ACC_PUBLIC) SPL_ME(SplFileObject, fscanf, arginfo_file_object_fscanf, ZEND_ACC_PUBLIC) SPL_ME(SplFileObject, fwrite, arginfo_file_object_fwrite, ZEND_ACC_PUBLIC) SPL_ME(SplFileObject, fread, arginfo_file_object_fread, ZEND_ACC_PUBLIC) diff --git a/ext/spl/tests/bug45216.phpt b/ext/spl/tests/bug45216.phpt deleted file mode 100644 index 31e6d62352..0000000000 --- a/ext/spl/tests/bug45216.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -SPL: SplFileObject::fgetss (bug 45216) ---CREDITS-- -Perrick Penet -#testfest phpcampparis 2008-06-07 ---FILE-- -text 1'); -$handle = fopen($file, 'r'); - -$object = new SplFileObject($file); -var_dump($object->fgetss()); -var_dump(fgetss($handle)); -?> ---CLEAN-- - ---EXPECTF-- -Deprecated: Function fgetss() is deprecated in %s on line %d -string(12) "text 0text 1" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(12) "text 0text 1" diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index d77ef73ca0..2bd6c60225 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1101,12 +1101,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_fgetc, 0) ZEND_ARG_INFO(0, fp) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_fgetss, 0, 0, 1) - ZEND_ARG_INFO(0, fp) - ZEND_ARG_INFO(0, length) - ZEND_ARG_INFO(0, allowable_tags) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_fscanf, 0, 0, 2) ZEND_ARG_INFO(0, stream) ZEND_ARG_INFO(0, format) @@ -3132,7 +3126,6 @@ static const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(feof, arginfo_feof) PHP_FE(fgetc, arginfo_fgetc) PHP_FE(fgets, arginfo_fgets) - PHP_DEP_FE(fgetss, arginfo_fgetss) PHP_FE(fread, arginfo_fread) PHP_NAMED_FE(fopen, php_if_fopen, arginfo_fopen) PHP_FE(fpassthru, arginfo_fpassthru) diff --git a/ext/standard/file.c b/ext/standard/file.c index 93b58e9a94..1057c683c8 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1090,55 +1090,6 @@ PHPAPI PHP_FUNCTION(fgetc) } /* }}} */ -/* {{{ proto string fgetss(resource fp [, int length [, string allowable_tags]]) - Get a line from file pointer and strip HTML tags */ -PHPAPI PHP_FUNCTION(fgetss) -{ - zval *fd; - zend_long bytes = 0; - size_t len = 0; - size_t actual_len, retval_len; - char *buf = NULL, *retval; - php_stream *stream; - char *allowed_tags=NULL; - size_t allowed_tags_len=0; - - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_RESOURCE(fd) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(bytes) - Z_PARAM_STRING(allowed_tags, allowed_tags_len) - ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); - - PHP_STREAM_TO_ZVAL(stream, fd); - - if (ZEND_NUM_ARGS() >= 2) { - if (bytes <= 0) { - php_error_docref(NULL, E_WARNING, "Length parameter must be greater than 0"); - RETURN_FALSE; - } - - len = (size_t) bytes; - buf = safe_emalloc(sizeof(char), (len + 1), 0); - /*needed because recv doesn't set null char at end*/ - memset(buf, 0, len + 1); - } - - if ((retval = php_stream_get_line(stream, buf, len, &actual_len)) == NULL) { - if (buf != NULL) { - efree(buf); - } - RETURN_FALSE; - } - - retval_len = php_strip_tags(retval, actual_len, &stream->fgetss_state, allowed_tags, allowed_tags_len); - - // TODO: avoid reallocation ??? - RETVAL_STRINGL(retval, retval_len); - efree(retval); -} -/* }}} */ - /* {{{ proto mixed fscanf(resource stream, string format [, string ...]) Implements a mostly ANSI compatible fscanf() */ PHP_FUNCTION(fscanf) @@ -1986,8 +1937,6 @@ PHP_FUNCTION(fgetcsv) char enclosure = '"'; /* allow this to be set as parameter */ int escape = (unsigned char) '\\'; - /* first section exactly as php_fgetss */ - zend_long len = 0; size_t buf_len; char *buf; diff --git a/ext/standard/file.h b/ext/standard/file.h index f5019d422b..19a54b5461 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -35,7 +35,6 @@ PHPAPI PHP_FUNCTION(fread); PHPAPI PHP_FUNCTION(fgetc); PHPAPI PHP_FUNCTION(fgets); PHP_FUNCTION(fscanf); -PHPAPI PHP_FUNCTION(fgetss); PHP_FUNCTION(fgetcsv); PHP_FUNCTION(fputcsv); PHPAPI PHP_FUNCTION(fwrite); diff --git a/ext/standard/filters.c b/ext/standard/filters.c index 7b039cd18f..b73e8148b6 100644 --- a/ext/standard/filters.c +++ b/ext/standard/filters.c @@ -166,129 +166,6 @@ static const php_stream_filter_factory strfilter_tolower_factory = { }; /* }}} */ -/* {{{ strip_tags filter implementation */ -typedef struct _php_strip_tags_filter { - const char *allowed_tags; - int allowed_tags_len; - uint8_t state; - uint8_t persistent; -} php_strip_tags_filter; - -static int php_strip_tags_filter_ctor(php_strip_tags_filter *inst, zend_string *allowed_tags, int persistent) -{ - if (allowed_tags != NULL) { - if (NULL == (inst->allowed_tags = pemalloc(ZSTR_LEN(allowed_tags) + 1, persistent))) { - return FAILURE; - } - memcpy((char *)inst->allowed_tags, ZSTR_VAL(allowed_tags), ZSTR_LEN(allowed_tags) + 1); - inst->allowed_tags_len = (int)ZSTR_LEN(allowed_tags); - } else { - inst->allowed_tags = NULL; - } - inst->state = 0; - inst->persistent = persistent; - - return SUCCESS; -} - -static void php_strip_tags_filter_dtor(php_strip_tags_filter *inst) -{ - if (inst->allowed_tags != NULL) { - pefree((void *)inst->allowed_tags, inst->persistent); - } -} - -static php_stream_filter_status_t strfilter_strip_tags_filter( - php_stream *stream, - php_stream_filter *thisfilter, - php_stream_bucket_brigade *buckets_in, - php_stream_bucket_brigade *buckets_out, - size_t *bytes_consumed, - int flags - ) -{ - php_stream_bucket *bucket; - size_t consumed = 0; - php_strip_tags_filter *inst = (php_strip_tags_filter *) Z_PTR(thisfilter->abstract); - - while (buckets_in->head) { - bucket = php_stream_bucket_make_writeable(buckets_in->head); - consumed = bucket->buflen; - - bucket->buflen = php_strip_tags(bucket->buf, bucket->buflen, &(inst->state), inst->allowed_tags, inst->allowed_tags_len); - - php_stream_bucket_append(buckets_out, bucket); - } - - if (bytes_consumed) { - *bytes_consumed = consumed; - } - - return PSFS_PASS_ON; -} - -static void strfilter_strip_tags_dtor(php_stream_filter *thisfilter) -{ - assert(Z_PTR(thisfilter->abstract) != NULL); - - php_strip_tags_filter_dtor((php_strip_tags_filter *)Z_PTR(thisfilter->abstract)); - - pefree(Z_PTR(thisfilter->abstract), ((php_strip_tags_filter *)Z_PTR(thisfilter->abstract))->persistent); -} - -static const php_stream_filter_ops strfilter_strip_tags_ops = { - strfilter_strip_tags_filter, - strfilter_strip_tags_dtor, - "string.strip_tags" -}; - -static php_stream_filter *strfilter_strip_tags_create(const char *filtername, zval *filterparams, uint8_t persistent) -{ - php_strip_tags_filter *inst; - php_stream_filter *filter = NULL; - zend_string *allowed_tags = NULL; - - php_error_docref(NULL, E_DEPRECATED, "The string.strip_tags filter is deprecated"); - - inst = pemalloc(sizeof(php_strip_tags_filter), persistent); - - if (filterparams != NULL) { - if (Z_TYPE_P(filterparams) == IS_ARRAY) { - smart_str tags_ss = {0}; - zval *tmp; - - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(filterparams), tmp) { - convert_to_string_ex(tmp); - smart_str_appendc(&tags_ss, '<'); - smart_str_append(&tags_ss, Z_STR_P(tmp)); - smart_str_appendc(&tags_ss, '>'); - } ZEND_HASH_FOREACH_END(); - smart_str_0(&tags_ss); - allowed_tags = tags_ss.s; - } else { - allowed_tags = zval_get_string(filterparams); - } - } - - if (php_strip_tags_filter_ctor(inst, allowed_tags, persistent) == SUCCESS) { - filter = php_stream_filter_alloc(&strfilter_strip_tags_ops, inst, persistent); - } else { - pefree(inst, persistent); - } - - if (allowed_tags) { - zend_string_release(allowed_tags); - } - - return filter; -} - -static const php_stream_filter_factory strfilter_strip_tags_factory = { - strfilter_strip_tags_create -}; - -/* }}} */ - /* {{{ base64 / quoted_printable stream filter implementation */ typedef enum _php_conv_err_t { @@ -2037,7 +1914,6 @@ static const struct { { &strfilter_rot13_ops, &strfilter_rot13_factory }, { &strfilter_toupper_ops, &strfilter_toupper_factory }, { &strfilter_tolower_ops, &strfilter_tolower_factory }, - { &strfilter_strip_tags_ops, &strfilter_strip_tags_factory }, { &strfilter_convert_ops, &strfilter_convert_factory }, { &consumed_filter_ops, &consumed_filter_factory }, { &chunked_filter_ops, &chunked_filter_factory }, diff --git a/ext/standard/tests/file/fgetss.phpt b/ext/standard/tests/file/fgetss.phpt deleted file mode 100644 index 41ac46dc92..0000000000 --- a/ext/standard/tests/file/fgetss.phpt +++ /dev/null @@ -1,144 +0,0 @@ ---TEST-- -fgetss() tests ---FILE-- -aaaaaa\ndddddd", - "asdqw\naaaa<>qqqq", - "aaaqqq", - "asdasdblah", - "some another text <> hoho " - ); - -foreach ($array as $str) { - file_put_contents($filename, $str); - $fp = fopen($filename, "r"); - var_dump(fgetss($fp)); - var_dump(fgetss($fp)); -} - -foreach ($array as $str) { - file_put_contents($filename, $str); - $fp = fopen($filename, "r"); - var_dump(fgetss($fp, 10)); - var_dump(fgetss($fp, 10)); -} - -var_dump(fgetss($fp, -10)); -var_dump(fgetss($fp, 0)); -fclose($fp); -var_dump(fgetss($fp, 0)); - -@unlink($filename); - -echo "Done\n"; -?> ---EXPECTF-- -Deprecated: Function fgetss() is deprecated in %s on line %d -string(18) "askasdfasdfaaaaaa -" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(6) "dddddd" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(6) "asdqw -" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(8) "aaaaqqqq" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(23) "aaafunction foo() {}qqq" - -Deprecated: Function fgetss() is deprecated in %s on line %d -bool(false) - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(6) "asdasd" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(0) "" - -Deprecated: Function fgetss() is deprecated in %s on line %d -bool(false) - -Deprecated: Function fgetss() is deprecated in %s on line %d -bool(false) - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(11) "some text -" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(4) "blah" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(24) "some another text hoho " - -Deprecated: Function fgetss() is deprecated in %s on line %d -bool(false) - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(9) "askasdfas" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(6) "dfaaaa" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(5) "asdqw" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(0) "" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(3) "aaa" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(7) "functio" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(6) "asdasd" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(0) "" - -Deprecated: Function fgetss() is deprecated in %s on line %d -bool(false) - -Deprecated: Function fgetss() is deprecated in %s on line %d -bool(false) - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(9) "some text" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(2) " -" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(9) "some anot" - -Deprecated: Function fgetss() is deprecated in %s on line %d -string(9) "her text " - -Deprecated: Function fgetss() is deprecated in %s on line %d - -Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d -bool(false) - -Deprecated: Function fgetss() is deprecated in %s on line %d - -Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d -bool(false) - -Deprecated: Function fgetss() is deprecated in %s on line %d - -Warning: fgetss(): supplied resource is not a valid stream resource in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/file/fgetss1.phpt b/ext/standard/tests/file/fgetss1.phpt deleted file mode 100644 index 0266371865..0000000000 --- a/ext/standard/tests/file/fgetss1.phpt +++ /dev/null @@ -1,73 +0,0 @@ ---TEST-- -more fgetss() tests ---FILE-- -aaaaaa\ndddddd", - "asdqw\naaaa<>qqqq", - "aaaqqq", - "asdasdblah", - "some another text <> hoho " - ); - -foreach ($array as $str) { - file_put_contents($filename, $str); - $fp = fopen($filename, "r"); - var_dump(fgetss($fp, 1000, ",,")); - var_dump(fgetss($fp)); -} - -foreach ($array as $str) { - file_put_contents($filename, $str); - $fp = fopen($filename, "r"); - var_dump(fgetss($fp, 10)); - var_dump(fgetss($fp, 10, "