Issues

ZF-10159: Ungreedy delimitter in Zend_Locale_Format::_parseDate

Description

Using the core of the Magento eCommerce system I found that the preg_match_all contains an ungreedy delimiter in the pattern that is supposed to be uppercase (since my Linux server is case sensitive).

When the 'u' is lowercase it throws the exception "No date part in '$date' found." whilest the date parameter is an actual date.

Info: File: \Zend\Locale\Format.php :857 Function: _parseDate Paramters given: $date: 2010-06-30 16:56:17 $options: Array ( [date_format] => yyyy-MM-dd HH:mm:ss [locale] => nl_NL [fix_date] => 1 [format_type] => iso [number_format] => [cache] => [disableCache] => [precision] => )

OS: CentOS PHP Version: 5.2.13

Comments

The lowercase 'u' in a pcre expression is not PCRE_UNGREEDY, it actually means to be utf8 compatible (PCRE8).

Could you confirm that your pcre lib was compiled with utf8 enabled? as the use of this modifier without utf8 being enabled when pcre is compiled will result in the match function returning an error rather than any matches.

You should be able to find this information in your phpinfo.

There is no info wether is was compiled with utf8 support or not.

All I could find in phpinfo is:

PCRE (Perl Compatible Regular Expressions) Support enabled PCRE Library Version 8.01 2010-01-19

php was compiled using: --with-pcre-regex=/usr/local

There is no "ungreedy" operator which is used. Zend Framework uses for I18n within the complete framework the encoding UTF-8.

This pattern is available within PHP per default. And according to the manual it can not be switched off.

Please give some additional information for reproduction. Actually with the given informations a reproduction is not possible.

Well, I created a tiny bit of code to reproduce the exception:

<?php $locale = 'nl_NL'; $part = 'yyyy-MM-dd HH:mm:ss'; $date = '2010-06-30 15:25:05'; $date = new Zend_Date( $date, $part, $locale ); ?>

And it throws this exception: Exception information:

Message: No date part in '2010-06-30 15:25:05' found. Stack trace:

0 /home///Framework/library/Zend/Date.php(1075): Zend_Date->_calculate('set', '2010-06-30 15:2...', 'yyyy-MM-dd HH:m...', 'nl_NL')

1 /home///Framework/library/Zend/Date.php(197): Zend_Date->set('2010-06-30 15:2...', 'yyyy-MM-dd HH:m...', 'nl_NL')

2 /home///Framework/application/controllers/IndexController.php(20): Zend_Date->__construct('2010-06-30 15:2...', 'yyyy-MM-dd HH:m...', 'nl_NL')

3 /home///Framework/library/Zend/Controller/Action.php(513): IndexController->indexAction()

4 /home///Framework/library/Zend/Controller/Dispatcher/Standard.php(289): Zend_Controller_Action->dispatch('indexAction')

5 /home///Framework/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))

6 /home///Framework/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()

7 /home///Framework/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()

8 /home///public_html/index.php(27): Zend_Application->run()

9 {main}

Request Parameters:

array ( 'controller' => 'index', 'action' => 'index', 'module' => 'default', )

Hope that is enough info.

As in the ticket: My server is CentOS 5 with PHP 5.2.13

it would seem that my server has NOT been configured with PCRE_UTF8. I have will try to recompile PCRE with UTF8 support. But would it be better to give a warning from the Zend Framework when PCRE are used and it is not supported?

I'll get back on this to let you know if it works.

Now a notice is thrown when UTF-8 is not available.

Note that UTF-8 is available within vanilla php installations. Additionally it should be mentioned that the request could even work without an exception by PCRE because it depends on the given input how PCRE behaves.

Closing issue as fixed as there is not more which could be done