svn: /php/php-src/ branches/PHP_5_2/ext/filter/filter.c branches/PHP_5_3/ext/filter/filter.c trunk/ext/filter/filter.c
| From: | Adam Harvey | Date: | Tue, 20 Apr 2010 04:31:11 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_2/ext/filter/filter.c branches/PHP_5_3/ext/filter/filter.c trunk/ext/filter/filter.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-62284@lists.php.net to get a copy of this message | ||
aharvey Tue, 20 Apr 2010 04:31:11 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=298196
Log:
Added explanatory comments to filter_input and filter_input_array to document
why some code that looks intuitively wrong is actually correct. Related to
bug #51344 (FILTER_NULL_ON_FAILURE flag automatically set in filter_input()
functions).
Bug: http://bugs.php.net/51344 (Wont fix)
FILTER_NULL_ON_FAILURE flag automatically set in filter_input() functions.
Changed paths:
U php/php-src/branches/PHP_5_2/ext/filter/filter.c
U php/php-src/branches/PHP_5_3/ext/filter/filter.c
U php/php-src/trunk/ext/filter/filter.c
Modified: php/php-src/branches/PHP_5_2/ext/filter/filter.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/filter/filter.c 2010-04-20 02:11:47 UTC (rev 298195)
+++ php/php-src/branches/PHP_5_2/ext/filter/filter.c 2010-04-20 04:31:11 UTC (rev 298196)
@@ -740,6 +740,12 @@
return;
}
}
+
+ /* The FILTER_NULL_ON_FAILURE flag inverts the usual return values of
+ * the function: normally when validation fails false is returned, and
+ * when the input value doesn't exist NULL is returned. With the flag
+ * set, NULL and false should be returned, respectively. Ergo, although
+ * the code below looks incorrect, it's actually right. */
if (filter_flags & FILTER_NULL_ON_FAILURE) {
RETURN_FALSE;
} else {
@@ -810,6 +816,12 @@
PHP_FILTER_GET_LONG_OPT(option, filter_flags);
}
}
+
+ /* The FILTER_NULL_ON_FAILURE flag inverts the usual return values of
+ * the function: normally when validation fails false is returned, and
+ * when the input value doesn't exist NULL is returned. With the flag
+ * set, NULL and false should be returned, respectively. Ergo, although
+ * the code below looks incorrect, it's actually right. */
if (filter_flags & FILTER_NULL_ON_FAILURE) {
RETURN_FALSE;
} else {
Modified: php/php-src/branches/PHP_5_3/ext/filter/filter.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/filter/filter.c 2010-04-20 02:11:47 UTC (rev 298195)
+++ php/php-src/branches/PHP_5_3/ext/filter/filter.c 2010-04-20 04:31:11 UTC (rev 298196)
@@ -780,6 +780,12 @@
return;
}
}
+
+ /* The FILTER_NULL_ON_FAILURE flag inverts the usual return values of
+ * the function: normally when validation fails false is returned, and
+ * when the input value doesn't exist NULL is returned. With the flag
+ * set, NULL and false should be returned, respectively. Ergo, although
+ * the code below looks incorrect, it's actually right. */
if (filter_flags & FILTER_NULL_ON_FAILURE) {
RETURN_FALSE;
} else {
@@ -846,6 +852,12 @@
PHP_FILTER_GET_LONG_OPT(option, filter_flags);
}
}
+
+ /* The FILTER_NULL_ON_FAILURE flag inverts the usual return values of
+ * the function: normally when validation fails false is returned, and
+ * when the input value doesn't exist NULL is returned. With the flag
+ * set, NULL and false should be returned, respectively. Ergo, although
+ * the code below looks incorrect, it's actually right. */
if (filter_flags & FILTER_NULL_ON_FAILURE) {
RETURN_FALSE;
} else {
Modified: php/php-src/trunk/ext/filter/filter.c
===================================================================
--- php/php-src/trunk/ext/filter/filter.c 2010-04-20 02:11:47 UTC (rev 298195)
+++ php/php-src/trunk/ext/filter/filter.c 2010-04-20 04:31:11 UTC (rev 298196)
@@ -780,6 +780,12 @@
return;
}
}
+
+ /* The FILTER_NULL_ON_FAILURE flag inverts the usual return values of
+ * the function: normally when validation fails false is returned, and
+ * when the input value doesn't exist NULL is returned. With the flag
+ * set, NULL and false should be returned, respectively. Ergo, although
+ * the code below looks incorrect, it's actually right. */
if (filter_flags & FILTER_NULL_ON_FAILURE) {
RETURN_FALSE;
} else {
@@ -846,6 +852,12 @@
PHP_FILTER_GET_LONG_OPT(option, filter_flags);
}
}
+
+ /* The FILTER_NULL_ON_FAILURE flag inverts the usual return values of
+ * the function: normally when validation fails false is returned, and
+ * when the input value doesn't exist NULL is returned. With the flag
+ * set, NULL and false should be returned, respectively. Ergo, although
+ * the code below looks incorrect, it's actually right. */
if (filter_flags & FILTER_NULL_ON_FAILURE) {
RETURN_FALSE;
} else {