From: Nikita Popov Date: Wed, 10 Sep 2014 15:46:54 +0000 (+0200) Subject: Remove string category support in setlocale() X-Git-Tag: PRE_PHP7_REMOVALS~25^2~111 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c115b6b71e31a289d84f72f8664943497b9ee31;p=php Remove string category support in setlocale() --- diff --git a/NEWS b/NEWS index b47565f051..f6818c531e 100644 --- a/NEWS +++ b/NEWS @@ -108,6 +108,7 @@ . Fix user session handlers (See rfc:session.user.return-value). (Sara) . Added intdiv() function. (Andrea) . Improved precision of log() function for base 2 and 10. (Marc Bennewitz) + . Remove string category support in setlocale(). (Nikita) - Streams: . Fixed bug #68532 (convert.base64-encode omits padding bytes). diff --git a/UPGRADING b/UPGRADING index cb976fd9ce..f3f25bd43a 100644 --- a/UPGRADING +++ b/UPGRADING @@ -75,6 +75,10 @@ PHP X.Y UPGRADE NOTES . gmp_setbit() and gmp_clrbit() now return FALSE for negative indices, making them consistent with other GMP functions. +- Standard: + . Removed string category support in setlocale(). Use the LC_* constants + instead. + ======================================== 2. New Features ======================================== diff --git a/ext/standard/string.c b/ext/standard/string.c index f6096d1697..8bb8a9c9b3 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -4450,49 +4450,18 @@ PHP_FUNCTION(strip_tags) PHP_FUNCTION(setlocale) { zval *args = NULL; - zval *pcategory, *plocale; + zval *plocale; zend_string *loc; char *retval; - int num_args, cat, i = 0; + zend_long cat; + int num_args, i = 0; HashPosition pos; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z+", &pcategory, &args, &num_args) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l+", &cat, &args, &num_args) == FAILURE) { return; } #ifdef HAVE_SETLOCALE - if (Z_TYPE_P(pcategory) == IS_LONG) { - cat = (int)Z_LVAL_P(pcategory); - } else { - /* FIXME: The following behaviour should be removed. */ - zend_string *category = zval_get_string(pcategory); - - php_error_docref(NULL, E_DEPRECATED, "Passing locale category name as string is deprecated. Use the LC_* -constants instead"); - if (!strcasecmp("LC_ALL", category->val)) { - cat = LC_ALL; - } else if (!strcasecmp("LC_COLLATE", category->val)) { - cat = LC_COLLATE; - } else if (!strcasecmp("LC_CTYPE", category->val)) { - cat = LC_CTYPE; -#ifdef LC_MESSAGES - } else if (!strcasecmp("LC_MESSAGES", category->val)) { - cat = LC_MESSAGES; -#endif - } else if (!strcasecmp("LC_MONETARY", category->val)) { - cat = LC_MONETARY; - } else if (!strcasecmp("LC_NUMERIC", category->val)) { - cat = LC_NUMERIC; - } else if (!strcasecmp("LC_TIME", category->val)) { - cat = LC_TIME; - } else { - php_error_docref(NULL, E_WARNING, "Invalid locale category name %s, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, or LC_TIME", category->val); - - zend_string_release(category); - RETURN_FALSE; - } - zend_string_release(category); - } - if (Z_TYPE(args[0]) == IS_ARRAY) { zend_hash_internal_pointer_reset_ex(Z_ARRVAL(args[0]), &pos); } diff --git a/ext/standard/tests/strings/setlocale_error.phpt b/ext/standard/tests/strings/setlocale_error.phpt index 361d00c584..ca46764ed1 100644 --- a/ext/standard/tests/strings/setlocale_error.phpt +++ b/ext/standard/tests/strings/setlocale_error.phpt @@ -1,7 +1,7 @@ --TEST-- Test setlocale() function : error condition --INI-- -error_reporting=14335 +error_reporting=E_ALL --SKIPIF-- --EXPECTF-- @@ -59,11 +54,4 @@ bool(false) -- Testing setlocale() function with invalid multiple locales, 'category' = LC_ALL -- bool(false) --- Testing setlocale() function with invalid category -- - -Deprecated: setlocale(): Passing locale category name as string is deprecated. Use the LC_* -constants instead in %s on line %d - -Warning: setlocale(): Invalid locale category name TEST, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, or LC_TIME in %s on line %d -bool(false) - Done