Browse Source

[ZF-6776, ZF-6881] Zend_Locale:

- added support for numberingSystem
- added new method to disable caching without erasing it


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15672 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 years ago
parent
commit
c81de6e935

+ 13 - 0
documentation/manual/en/module_specs/Zend_Locale-Functions.xml

@@ -569,6 +569,13 @@ print Zend_Locale::getTranslation('de', 'language', 'zh');
                             included within that territory. The ISO territory code ('territory') is used as
                             array key and the regex as array value.</entry>
                     </row>
+                    <row>
+                        <entry><emphasis>NumberingSystem</emphasis></entry>
+                        <entry>
+                            Returns a list of scripts with the notation for digits used within the
+                            script
+                        </entry>
+                    </row>
                 </tbody>
             </tgroup>
         </table>
@@ -946,6 +953,12 @@ print Zend_Locale::getTranslation('de', 'language', 'zh');
                             territory has to be given as ISO4217 string for example '001' for
                             world</entry>
                     </row>
+                    <row>
+                        <entry><emphasis>NumberingSystem</emphasis></entry>
+                        <entry>
+                            Returns a scripts with the notation for digits used within this script
+                        </entry>
+                    </row>
                 </tbody>
             </tgroup>
         </table>

+ 20 - 8
documentation/manual/en/module_specs/Zend_Locale-Introduction.xml

@@ -516,14 +516,26 @@ Zend_Locale_Format::setOptions(array('locale' => Zend_Locale_Format::STANDARD,
         <title>Speed up Zend_Locale and its subclasses</title>
 
         <para>
-            <classname>Zend_Locale</classname> and its subclasses can be speed up by the usage of <classname>Zend_Cache</classname>.
-            Use the static method <classname>Zend_Locale::setCache($cache)</classname> if you are using
-            <classname>Zend_Locale</classname>. <classname>Zend_Locale_Format</classname> can be speed up the using the option
-            <code>cache</code> within <classname>Zend_Locale_Format::setOptions(array('cache' => $adapter));</classname>.
-            If you are using both classes you should only set the cache for <classname>Zend_Locale</classname>, otherwise
-            the last set cache will overwrite the previous set cache. For convenience there are also the static
-            methods <code>getCache()</code>, <code>hasCache()</code>, <code>clearCache()</code> and
-            <code>removeCache()</code>.
+            <classname>Zend_Locale</classname> and its subclasses can be speed up by the usage of
+            <classname>Zend_Cache</classname>. Use the static method
+            <classname>Zend_Locale::setCache($cache)</classname> if you are using
+            <classname>Zend_Locale</classname>. <classname>Zend_Locale_Format</classname> can be
+            speed up the using the option <code>cache</code> within
+            <classname>Zend_Locale_Format::setOptions(array('cache' => $adapter));</classname>.
+            If you are using both classes you should only set the cache for
+            <classname>Zend_Locale</classname>, otherwise the last set cache will overwrite the
+            previous set cache. For convenience there are also the static methods
+            <methodname>getCache()</methodname>, <methodname>hasCache()</methodname>,
+            <methodname>clearCache()</methodname> and <methodname>removeCache()</methodname>.
+        </para>
+
+        <para>
+            When no cache is set, then <classname>Zend_Locale</classname> will automatically set a
+            cache itself. Sometimes it is wished to prevent that a cache is set, even if this
+            degrades performance. In this case the static
+            <methodname>disableCache(true)</methodname> method should be used. It does not only
+            disable the actual set cache, without erasing it, but also prevents that a cache is
+            automatically generated when no cache is set.
         </para>
 
     </sect2>

+ 4 - 101
documentation/manual/en/module_specs/Zend_Locale-Parsing.xml

@@ -477,107 +477,10 @@ echo getScriptCode('tamoul', 'fr'); // outputs "Taml"
 ]]></programlisting>
         </example>
 
-        <sect3 id="zend.locale.appendix.numberscripts.supported">
-
-            <title>List of supported numeral systems</title>
-
-            <para>
-                <table id="zend.locale.appendix.numberscripts.supported.table">
-                    <title>List of supported numeral systems</title>
-                    <tgroup cols="2">
-                        <thead>
-                            <row>
-                                <entry>Notation Name</entry>
-                                <entry>Script</entry>
-                            </row>
-                        </thead>
-                        <tbody>
-                            <row>
-                                <entry>Arabic</entry>
-                                <entry>Arab</entry>
-                            </row>
-                            <row>
-                                <entry>Balinese</entry>
-                                <entry>Bali</entry>
-                            </row>
-                            <row>
-                                <entry>Bengali</entry>
-                                <entry>Beng</entry>
-                            </row>
-                            <row>
-                                <entry>Devanagari</entry>
-                                <entry>Deva</entry>
-                            </row>
-                            <row>
-                                <entry>Gujarati</entry>
-                                <entry>Gujr</entry>
-                            </row>
-                            <row>
-                                <entry>Gurmukhi</entry>
-                                <entry>Guru</entry>
-                            </row>
-                            <row>
-                                <entry>Kannada</entry>
-                                <entry>Knda</entry>
-                            </row>
-                            <row>
-                                <entry>Khmer</entry>
-                                <entry>Khmr</entry>
-                            </row>
-                            <row>
-                                <entry>Lao</entry>
-                                <entry>Laoo</entry>
-                            </row>
-                            <row>
-                                <entry>Limbu</entry>
-                                <entry>Limb</entry>
-                            </row>
-                            <row>
-                                <entry>Malayalam</entry>
-                                <entry>Mlym</entry>
-                            </row>
-                            <row>
-                                <entry>Mongolian</entry>
-                                <entry>Mong</entry>
-                            </row>
-                            <row>
-                                <entry>Myanmar</entry>
-                                <entry>Mymr</entry>
-                            </row>
-                            <row>
-                                <entry>New_Tai_Lue</entry>
-                                <entry>Talu</entry>
-                            </row>
-                            <row>
-                                <entry>Nko</entry>
-                                <entry>Nkoo</entry>
-                            </row>
-                            <row>
-                                <entry>Oriya</entry>
-                                <entry>Orya</entry>
-                            </row>
-                            <row>
-                                <entry>Tamil</entry>
-                                <entry>Taml</entry>
-                            </row>
-                            <row>
-                                <entry>Telugu</entry>
-                                <entry>Telu</entry>
-                            </row>
-                            <row>
-                                <entry>Thai</entry>
-                                <entry>Tale</entry>
-                            </row>
-                            <row>
-                                <entry>Tibetan</entry>
-                                <entry>Tibt</entry>
-                            </row>
-                        </tbody>
-                    </tgroup>
-                </table>
-            </para>
-
-        </sect3>
+        <para>
+            For a list of supported numeral systems call
+            <methodname>Zend_Locale::getTranslationList('numberingsystem', 'en')</methodname>.
+        </para>
 
     </sect2>
 

+ 12 - 0
library/Zend/Locale.php

@@ -890,6 +890,18 @@ class Zend_Locale
     }
 
     /**
+     * Disables the set cache
+     *
+     * @param  boolean $flag True disables any set cache, default is false
+     * @return void
+     */
+    public static function disableCache($flag)
+    {
+        require_once 'Zend/Locale/Data.php';
+        Zend_Locale_Data::disableCache($flag);
+    }
+
+    /**
      * Internal function, returns a single locale on detection
      *
      * @param  string|Zend_Locale $locale (Optional) Locale to work on

+ 36 - 4
library/Zend/Locale/Data.php

@@ -61,6 +61,14 @@ class Zend_Locale_Data
     private static $_cache = null;
 
     /**
+     * Internal option, cache disabled
+     *
+     * @var    boolean
+     * @access private
+     */
+    private static $_cacheDisabled = false;
+
+    /**
      * Read the content from locale
      *
      * Can be called like:
@@ -290,7 +298,7 @@ class Zend_Locale_Data
     {
         $locale = self::_checkLocale($locale);
 
-        if (!isset(self::$_cache)) {
+        if (!isset(self::$_cache) && !self::$_cacheDisabled) {
             require_once 'Zend/Cache.php';
             self::$_cache = Zend_Cache::factory(
                 'Core',
@@ -306,7 +314,7 @@ class Zend_Locale_Data
 
         $val = urlencode($val);
         $id = strtr('Zend_LocaleL_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
-        if ($result = self::$_cache->load($id)) {
+        if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) {
             return unserialize($result);
         }
 
@@ -807,6 +815,16 @@ class Zend_Locale_Data
                 }
                 break;
 
+            case 'numberingsystem':
+                $_temp = self::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem', 'id');
+                foreach ($_temp as $key => $keyvalue) {
+                    $temp += self::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem[@id=\'' . $key . '\']', 'digits', $key);
+                    if (empty($temp[$key])) {
+                        unset($temp[$key]);
+                    }
+                }
+                break;
+
             default :
                 require_once 'Zend/Locale/Exception.php';
                 throw new Zend_Locale_Exception("Unknown list ($path) for parsing locale data.");
@@ -833,7 +851,7 @@ class Zend_Locale_Data
     {
         $locale = self::_checkLocale($locale);
 
-        if (!isset(self::$_cache)) {
+        if (!isset(self::$_cache) && !self::$_cacheDisabled) {
             require_once 'Zend/Cache.php';
             self::$_cache = Zend_Cache::factory(
                 'Core',
@@ -848,7 +866,7 @@ class Zend_Locale_Data
         }
         $val = urlencode($val);
         $id = strtr('Zend_LocaleC_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
-        if ($result = self::$_cache->load($id)) {
+        if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) {
             return unserialize($result);
         }
 
@@ -1248,6 +1266,10 @@ class Zend_Locale_Data
                 $temp = self::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex[@territoryId=\'' . $value . '\']', 'territoryId');
                 break;
 
+            case 'numberingsystem':
+                $temp = self::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem[@id=\'' . strtolower($value) . '\']', 'digits', $value);
+                break;
+
             default :
                 require_once 'Zend/Locale/Exception.php';
                 throw new Zend_Locale_Exception("Unknown detail ($path) for parsing locale data.");
@@ -1317,4 +1339,14 @@ class Zend_Locale_Data
     {
         self::$_cache->clean();
     }
+
+    /**
+     * Disables the cache
+     *
+     * @param unknown_type $flag
+     */
+    public static function disableCache($flag)
+    {
+        self::$_cacheDisabled = (boolean) $flag;
+    }
 }

+ 20 - 47
library/Zend/Locale/Format.php

@@ -42,32 +42,9 @@ class Zend_Locale_Format
                                      'fix_date'      => false,
                                      'locale'        => null,
                                      'cache'         => null,
+                                     'disableCache'  => false,
                                      'precision'     => null);
 
-    private static $_signs = array(
-        'Latn' => array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'), // Latn - default latin
-        'Arab' => array( '٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'), // 0660 - 0669 arabic
-        'Deva' => array( '०', '१', '२', '३', '४', '५', '६', '७', '८', '९'), // 0966 - 096F devanagari
-        'Beng' => array( '০', '১', '২', '৩', '৪', '৫', '৬', '৭', '৮', '৯'), // 09E6 - 09EF bengali
-        'Guru' => array( '੦', '੧', '੨', '੩', '੪', '੫', '੬', '੭', '੮', '੯'), // 0A66 - 0A6F gurmukhi
-        'Gujr' => array( '૦', '૧', '૨', '૩', '૪', '૫', '૬', '૭', '૮', '૯'), // 0AE6 - 0AEF gujarati
-        'Orya' => array( '୦', '୧', '୨', '୩', '୪', '୫', '୬', '୭', '୮', '୯'), // 0B66 - 0B6F orija
-        'Taml' => array( '௦', '௧', '௨', '௩', '௪', '௫', '௬', '௭', '௮', '௯'), // 0BE6 - 0BEF tamil
-        'Telu' => array( '౦', '౧', '౨', '౩', '౪', '౫', '౬', '౭', '౮', '౯'), // 0C66 - 0C6F telugu
-        'Knda' => array( '೦', '೧', '೨', '೩', '೪', '೫', '೬', '೭', '೮', '೯'), // 0CE6 - 0CEF kannada
-        'Mlym' => array( '൦', '൧', '൨', '൩', '൪', '൫', '൬', '൭', '൮', '൯ '), // 0D66 - 0D6F malayalam
-        'Tale' => array( '๐', '๑', '๒', '๓', '๔', '๕', '๖', '๗', '๘', '๙ '), // 0E50 - 0E59 thai
-        'Laoo' => array( '໐', '໑', '໒', '໓', '໔', '໕', '໖', '໗', '໘', '໙'), // 0ED0 - 0ED9 lao
-        'Tibt' => array( '༠', '༡', '༢', '༣', '༤', '༥', '༦', '༧', '༨', '༩ '), // 0F20 - 0F29 tibetan
-        'Mymr' => array( '၀', '၁', '၂', '၃', '၄', '၅', '၆', '၇', '၈', '၉'), // 1040 - 1049 myanmar
-        'Khmr' => array( '០', '១', '២', '៣', '៤', '៥', '៦', '៧', '៨', '៩'), // 17E0 - 17E9 khmer
-        'Mong' => array( '᠐', '᠑', '᠒', '᠓', '᠔', '᠕', '᠖', '᠗', '᠘', '᠙'), // 1810 - 1819 mongolian
-        'Limb' => array( '᥆', '᥇', '᥈', '᥉', '᥊', '᥋', '᥌', '᥍', '᥎', '᥏'), // 1946 - 194F limbu
-        'Talu' => array( '᧐', '᧑', '᧒', '᧓', '᧔', '᧕', '᧖', '᧗', '᧘', '᧙'), // 19D0 - 19D9 tailue
-        'Bali' => array( '᭐', '᭑', '᭒', '᭓', '᭔', '᭕', '᭖', '᭗', '᭘', '᭙'), // 1B50 - 1B59 balinese
-        'Nkoo' => array( '߀', '߁', '߂', '߃', '߄', '߅', '߆', '߇', '߈', '߉')  // 07C0 - 07C9 nko
-    );
-
     /**
      * Sets class wide options, if no option was given, the actual set options will be returned
      * The 'precision' option of a value is used to truncate or stretch extra digits. -1 means not to touch the extra digits.
@@ -172,6 +149,10 @@ class Zend_Locale_Format
                     }
                     break;
 
+                case 'disablecache' :
+                    Zend_Locale_Data::disableCache($value);
+                    break;
+
                 case 'precision' :
                     if ($value === NULL) {
                         $value = -1;
@@ -212,38 +193,30 @@ class Zend_Locale_Format
      */
     public static function convertNumerals($input, $from, $to = null)
     {
-        if (is_string($from)) {
-            $from = ucfirst(strtolower($from));
-        }
-        if (isset(self::$_signs[$from]) === false) {
+        $from   = strtolower($from);
+        $source = Zend_Locale_Data::getContent('en', 'numberingsystem', $from);
+        if (empty($source)) {
             require_once 'Zend/Locale/Exception.php';
             throw new Zend_Locale_Exception("Unknown script '$from'. Use 'Latn' for digits 0,1,2,3,4,5,6,7,8,9.");
         }
-        if (is_string($to)) {
-            $to = ucfirst(strtolower($to));
-        }
-        if (($to !== null) and (isset(self::$_signs[$to]) === false)) {
-            require_once 'Zend/Locale/Exception.php';
-            throw new Zend_Locale_Exception("Unknown script '$to'. Use 'Latn' for digits 0,1,2,3,4,5,6,7,8,9.");
-        }
 
-        if (isset(self::$_signs[$from])) {
-            for ($X = 0; $X < 10; ++$X) {
-                $source[$X + 10] = "/" . self::$_signs[$from][$X] . "/u";
+        if ($to !== null) {
+            $to     = strtolower($to);
+            $target = Zend_Locale_Data::getContent('en', 'numberingsystem', $to);
+            if (empty($target)) {
+                require_once 'Zend/Locale/Exception.php';
+                throw new Zend_Locale_Exception("Unknown script '$to'. Use 'Latn' for digits 0,1,2,3,4,5,6,7,8,9.");
             }
+        } else {
+            $target = '0123456789';
         }
 
-        if (isset(self::$_signs[$to])) {
-            for ($X = 0; $X < 10; ++$X) {
-                $dest[$X + 10] = self::$_signs[$to][$X];
-            }
-        } else {
-            for ($X = 0; $X < 10; ++$X) {
-                $dest[$X + 10] = $X;
-            }
+        for ($x = 0; $x < 10; ++$x) {
+            $asource[$x] = "/" . iconv_substr($source, $x, 1) . "/u";
+            $atarget[$x] = iconv_substr($target, $x, 1);
         }
 
-        return preg_replace($source, $dest, $input);
+        return preg_replace($asource, $atarget, $input);
     }
 
     /**

+ 33 - 0
tests/Zend/Locale/DataTest.php

@@ -2460,4 +2460,37 @@ class Zend_Locale_DataTest extends PHPUnit_Framework_TestCase
         $value = Zend_Locale_Data::getContent('de_AT', 'postaltoterritory', 'AT');
         $this->assertEquals("\d{4}", $value);
     }
+
+    /**
+     * test for reading postaltoterritory from locale
+     * expected array
+     */
+    public function testNumberingSystem()
+    {
+        $value = Zend_Locale_Data::getList('de_AT', 'numberingsystem');
+        $result = array(
+            'arab' => '٠١٢٣٤٥٦٧٨٩',
+            'arabext' => '۰۱۲۳۴۵۶۷۸۹',
+            'beng' => '০১২৩৪৫৬৭৮৯',
+            'deva' => '०१२३४५६७८९',
+            'fullwide' => '0123456789',
+            'gujr' => '૦૧૨૩૪૫૬૭૮૯',
+            'guru' => '੦੧੨੩੪੫੬੭੮੯',
+            'khmr' => "០១២៣៤៥៦៧៨៩",
+            'knda' => '೦೧೨೩೪೫೬೭೮೯',
+            'laoo' => '໐໑໒໓໔໕໖໗໘໙',
+            'latn' => '0123456789',
+            'mlym' => '൦൧൨൩൪൫൬൭൮൯',
+            'mong' => "᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙",
+            'mymr' => "၀၁၂၃၄၅၆၇၈၉",
+            'orya' => '୦୧୨୩୪୫୬୭୮୯',
+            'telu' => '౦౧౨౩౪౫౬౭౮౯',
+            'thai' => '๐๑๒๓๔๕๖๗๘๙',
+            'tibt' => '༠༡༢༣༤༥༦༧༨༩'
+        );
+        $this->assertEquals($result, $value);
+
+        $value = Zend_Locale_Data::getContent('de_AT', 'numberingsystem', 'Arab');
+        $this->assertEquals("٠١٢٣٤٥٦٧٨٩", $value);
+    }
 }

+ 1 - 1
tests/Zend/Locale/FormatTest.php

@@ -752,7 +752,7 @@ class Zend_Locale_FormatTest extends PHPUnit_Framework_TestCase
      */
     public function testSetOption()
     {
-        $this->assertEquals(7, count(Zend_Locale_Format::setOptions(array('format_type' => 'php'))));
+        $this->assertEquals(8, count(Zend_Locale_Format::setOptions(array('format_type' => 'php'))));
         $this->assertTrue(is_array(Zend_Locale_Format::setOptions()));
 
         try {

+ 16 - 0
tests/Zend/LocaleTest.php

@@ -240,10 +240,12 @@ class Zend_LocaleTest extends PHPUnit_Framework_TestCase
      */
     public function testgetLanguageTranslationList()
     {
+        set_error_handler(array($this, 'errorHandlerIgnore'));
         $list = Zend_LocaleTestHelper::getLanguageTranslationList();
         $this->assertTrue(is_array($list));
         $list = Zend_LocaleTestHelper::getLanguageTranslationList('de');
         $this->assertTrue(is_array($list));
+        restore_error_handler();
     }
 
     /**
@@ -252,10 +254,12 @@ class Zend_LocaleTest extends PHPUnit_Framework_TestCase
      */
     public function testgetLanguageTranslation()
     {
+        set_error_handler(array($this, 'errorHandlerIgnore'));
         $this->assertEquals('Deutsch', Zend_LocaleTestHelper::getLanguageTranslation('de', 'de_AT'));
         $this->assertEquals('German',  Zend_LocaleTestHelper::getLanguageTranslation('de', 'en'));
         $this->assertFalse(Zend_LocaleTestHelper::getLanguageTranslation('xyz'));
         $this->assertTrue(is_string(Zend_LocaleTestHelper::getLanguageTranslation('de', 'auto')));
+        restore_error_handler();
     }
 
     /**
@@ -264,11 +268,13 @@ class Zend_LocaleTest extends PHPUnit_Framework_TestCase
      */
     public function testgetScriptTranslationList()
     {
+        set_error_handler(array($this, 'errorHandlerIgnore'));
         $list = Zend_LocaleTestHelper::getScriptTranslationList();
         $this->assertTrue(is_array($list));
 
         $list = Zend_LocaleTestHelper::getScriptTranslationList('de');
         $this->assertTrue(is_array($list));
+        restore_error_handler();
     }
 
     /**
@@ -277,9 +283,11 @@ class Zend_LocaleTest extends PHPUnit_Framework_TestCase
      */
     public function testgetScriptTranslation()
     {
+        set_error_handler(array($this, 'errorHandlerIgnore'));
         $this->assertEquals('Arabisch', Zend_LocaleTestHelper::getScriptTranslation('Arab', 'de_AT'));
         $this->assertEquals('Arabic', Zend_LocaleTestHelper::getScriptTranslation('Arab', 'en'));
         $this->assertFalse(Zend_LocaleTestHelper::getScriptTranslation('xyz'));
+        restore_error_handler();
     }
 
     /**
@@ -288,11 +296,13 @@ class Zend_LocaleTest extends PHPUnit_Framework_TestCase
      */
     public function testgetCountryTranslationList()
     {
+        set_error_handler(array($this, 'errorHandlerIgnore'));
         $list = Zend_LocaleTestHelper::getCountryTranslationList();
         $this->assertTrue(is_array($list));
 
         $list = Zend_LocaleTestHelper::getCountryTranslationList('de');
         $this->assertEquals("Vereinigte Staaten", $list['US']);
+        restore_error_handler();
     }
 
     /**
@@ -301,9 +311,11 @@ class Zend_LocaleTest extends PHPUnit_Framework_TestCase
      */
     public function testgetCountryTranslation()
     {
+        set_error_handler(array($this, 'errorHandlerIgnore'));
         $this->assertEquals('Deutschland', Zend_LocaleTestHelper::getCountryTranslation('DE', 'de_DE'));
         $this->assertEquals('Germany', Zend_LocaleTestHelper::getCountryTranslation('DE', 'en'));
         $this->assertFalse(Zend_LocaleTestHelper::getCountryTranslation('xyz'));
+        restore_error_handler();
     }
 
     /**
@@ -312,11 +324,13 @@ class Zend_LocaleTest extends PHPUnit_Framework_TestCase
      */
     public function testgetTerritoryTranslationList()
     {
+        set_error_handler(array($this, 'errorHandlerIgnore'));
         $list = Zend_LocaleTestHelper::getTerritoryTranslationList();
         $this->assertTrue(is_array($list));
 
         $list = Zend_LocaleTestHelper::getTerritoryTranslationList('de');
         $this->assertTrue(is_array($list));
+        restore_error_handler();
     }
 
     /**
@@ -325,10 +339,12 @@ class Zend_LocaleTest extends PHPUnit_Framework_TestCase
      */
     public function testgetTerritoryTranslation()
     {
+        set_error_handler(array($this, 'errorHandlerIgnore'));
         $this->assertEquals('Afrika', Zend_LocaleTestHelper::getTerritoryTranslation('002', 'de_AT'));
         $this->assertEquals('Africa', Zend_LocaleTestHelper::getTerritoryTranslation('002', 'en'));
         $this->assertFalse(Zend_LocaleTestHelper::getTerritoryTranslation('xyz'));
         $this->assertTrue(is_string(Zend_LocaleTestHelper::getTerritoryTranslation('002', 'auto')));
+        restore_error_handler();
     }
 
     /**