From c0407d95f7bd9027d087cf8cc0f5a109b22430eb Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 16 Jul 2018 22:53:24 +0200 Subject: [PATCH] Deprecate explicit use of FILTER_FLAG_SCHEME|HOST_REQUIRED As of PHP 5.2.1 FILTER_VALIDATE_URL implies FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED, which makes these constants useless at best, if not even misleading. Therefore we deprecate the explicit use of these constants for FILTER_VALIDATE_URL, to pave the way for their eventual removal. See . --- ext/filter/logical_filters.c | 5 +++++ ext/filter/tests/deprecated.phpt | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 ext/filter/tests/deprecated.phpt diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 0fe324268dda1..525cd0d0979be 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -539,6 +539,11 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ php_url *url; size_t old_len = Z_STRLEN_P(value); + if (flags & (FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) { + php_error_docref(NULL, E_DEPRECATED, + "explicit use of FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED is deprecated"); + } + php_filter_url(value, flags, option_array, charset); if (Z_TYPE_P(value) != IS_STRING || old_len != Z_STRLEN_P(value)) { diff --git a/ext/filter/tests/deprecated.phpt b/ext/filter/tests/deprecated.phpt new file mode 100644 index 0000000000000..a7771056efb1a --- /dev/null +++ b/ext/filter/tests/deprecated.phpt @@ -0,0 +1,19 @@ +--TEST-- +FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED are deprecated +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Deprecated: filter_var(): explicit use of FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED is deprecated in %s +bool(false) + +Deprecated: filter_var(): explicit use of FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED is deprecated in %s +bool(false) +===DONE===