ZF-11631: Zend_Filter_Alnum and Alpha not referring locale through Zend_Registry

Issue Type: Improvement Created: 2011-07-30T17:01:51.000+0000 Last Updated: 2011-09-15T08:15:14.000+0000 Status: Resolved Fix version(s): - Next Major Release ()

Reporter: Toshimasa Ishibashi (iandeth) Assignee: Thomas Weidner (thomas) Tags: - Zend_Filter

  • Zend_Locale
  • Zend_Registry

Related issues: Attachments:


h1. ISSUE forcing app's locale to 'ja'

<pre class="highlight">
$locale = Zend_Locale('ja');
Zend_Registry::set('Zend_Locale', $locale);

but Zend_Filter_Alnum (and Alpha) is ignoring it:

<pre class="highlight">
# Zend/Filter/Alnum.php line 92
# and Zend/Filter/Alpha.php line 92
this->_locale = new Zend_Locale('auto');

so alphabet+num validation is broken with multi-byte texts:

<pre class="highlight">
$va = new Zend_Validate_Alnum();
$va->isValid( $some_mb_str );
# -> true (but should be false, since it's not [a-zA-Z])

h1. THE FIX * it should refer to Zend_Registry first. * like Zend/Validate/Date.php line 97

here is the path for Alpha.php (should be the same for Alnum.php too)

<pre class="highlight">
diff -Naru Alpha.php.original Alpha.php 
--- Alpha.php.original  2011-07-31 01:59:34.000000000 +0900
+++ Alpha.php   2011-07-31 01:59:40.000000000 +0900
@@ -89,7 +89,11 @@
         if (null === self::$_meansEnglishAlphabet) {
-            $this->_locale = new Zend_Locale('auto');
+            require_once 'Zend/Registry.php';
+            if (Zend_Registry::isRegistered('Zend_Locale'))
+                $this->_locale = Zend_Registry::get('Zend_Locale');
+            else
+                $this->_locale = new Zend_Locale('auto');
             self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(),
                                                     array('ja', 'ko', 'zh')


Posted by Thomas Weidner (thomas) on 2011-07-30T18:05:57.000+0000

Changing from bug to improvement. Note that most filters are for now not locale-aware.

Posted by Thomas Weidner (thomas) on 2011-09-15T08:15:14.000+0000

Fixed in ZF2 with GH-416

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.