com php-src: Deprecate explicit use of FILTER_FLAG_SCHEME |HOST_REQUIRED: ext/filter/logical_filters.c ext/ filter/tests/deprecated.phpt

From: Date: Tue, 17 Jul 2018 08:45:46 +0000
Subject: com php-src: Deprecate explicit use of FILTER_FLAG_SCHEME |HOST_REQUIRED: ext/filter/logical_filters.c ext/ filter/tests/deprecated.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102578@lists.php.net to get a copy of this message
Commit: c0407d95f7bd9027d087cf8cc0f5a109b22430eb Author: Christoph M. Becker <cmbecker69@gmx.de> Mon, 16 Jul 2018 22:53:24 +0200 Parents: ffa41787d58580abc41849bdeb5fd19f4e69e4f3 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c0407d95f7bd9027d087cf8cc0f5a109b22430eb Log: 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 <https://wiki.php.net/rfc/deprecations_php_7_3#filter_flag_scheme_required_and_filter_flag_host_required>. Changed paths: M ext/filter/logical_filters.c A ext/filter/tests/deprecated.phpt Diff: diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 0fe3242..525cd0d 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 0000000..a777105 --- /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-- +<?php +if (!extension_loaded('filter')) die('skip filter extension not available'); +?> +--FILE-- +<?php +var_dump(filter_var('//example.com/', FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)); +var_dump(filter_var('http://', FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)); +?> +===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===

« previous php.cvs (#102578) next »