]> granicus.if.org Git - php/commitdiff
Remove string category support in setlocale()
authorNikita Popov <nikic@php.net>
Wed, 10 Sep 2014 15:46:54 +0000 (17:46 +0200)
committerNikita Popov <nikic@php.net>
Sat, 17 Jan 2015 17:26:45 +0000 (18:26 +0100)
NEWS
UPGRADING
ext/standard/string.c
ext/standard/tests/strings/setlocale_error.phpt

diff --git a/NEWS b/NEWS
index b47565f05151129e782445f4a2c472bb3c1fffcf..f6818c531ef139eee06c0bdfc31707bfea602f40 100644 (file)
--- a/NEWS
+++ b/NEWS
   . 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).
index cb976fd9cebc5b300e25716ccdd6cbac8d23f077..f3f25bd43a8bdc0d35ac6320e7f5f82a9e8e329b 100644 (file)
--- 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
 ========================================
index f6096d16974f2b151dc018d74bdc6935ec5b788c..8bb8a9c9b33a7f09922a2eb98fb630188046cd21 100644 (file)
@@ -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);
        }
index 361d00c5843aa76e1ed9ae488d64f7cce6e4e5e1..ca46764ed1a759b02ca6ef94bfeac8da1c5441f8 100644 (file)
@@ -1,7 +1,7 @@
 --TEST--
 Test setlocale() function : error condition
 --INI--
-error_reporting=14335
+error_reporting=E_ALL
 --SKIPIF--
 <?php
 if (substr(PHP_OS, 0, 3) == 'WIN') {
@@ -35,11 +35,6 @@ echo "\n-- Testing setlocale() function with invalid multiple locales, 'category
 //Invalid array of locales
 var_dump( setlocale(LC_ALL,"en_US.invalid", "en_AU.invalid", "ko_KR.invalid") );
 
-echo "\n-- Testing setlocale() function with invalid category --\n";
-//invalid $category
-$invalid_category = "TEST";
-var_dump( setlocale($invalid_category,"en_US.utf8") );
 echo "\nDone";
 ?>
 --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