Issues

ZF-3015: Zend_Validate_StringLength use iconv extension and missing [get|set]Encoding method

Description

Zend_Validate_StringLength use iconv extension but it is not documented in http://framework.zend.com/manual/en/… and not duty to get the length of an single byte string

  • if mbstring installed -> use mb_strlen
  • elseif iconv_installed -> use iconv_strlen
  • elseif single byte encoding -> use strlen
  • else -> throw exception or detact the langth by self or use strlen

Comments

On System i (AS/400 or i5/OS is same as System i5), iconv_strlen function does not work. I hope if Zend Framework is used on System i, Zend Framework should avoid using iconv_strlen function.

Please evaluate and categorize/assign as necessary.

Marc Bennewitz:

Besides that mb_strlen is faster than iconv_strlen, there is no real difference between the two. To remain BC, i'd say we add a new method setLocale() to allow different locales to be used. The dependency will be documented as requested.

Would that work for you?

Hi Andries

mb_strlen sounds good but it is not available on all configurations and only a must have for multi byte encodings. I don't understand why you would add "setLocale" ? There is no encoding information. An "setEncoding" is used to check this.

On other ZF components a string information is used, too. Is it useful to create a global component to handle this ? example:


Zend_String
 + __construct($string, $encoding)
 + __toString()
 + getLength()
 + convert($encoding)
  ...
  + static strlen($string, $encoding)
  + static convert($string, $toEncoding, $fromEncoding)
  ...

I have Zend Core 2.5.0 installed on a number of machines. Zend_Validate_StringLenth::isValid() fails on some machines but not others (I think it is dependent on the underlying OS variant of Linux.) Clearly as is pointed out above, reliance on the iconv extension cannot be guaranteed across every platform. Therefore alternate strlen functions are required to cope with this as suggested above.

This issue has stopped development of our system and I'd like to see this issue raised to 'Blocker' status and resolved quickly in the current 1.6 ZF stream. There are 20 occurrences of iconv_strlen in the 1.6 library and whilst we are not using all the effected code (yet), it is too much to maintain a hack version of the library to make it work for us.

Hi, all. I find that "Zend Core for i5/OS Ver2.6.1" can handle iconv_strlen() and iconv_strpos() function.

phpbughuntday

I am unable to reproduce this issue. Could you provide us with a testcase that fails?

I can confirm via a conversation with Zend that Zend Core does NOT automatically enable iconv on installation in a Linux environment.

"reply I got from the Product Manager of the Core. Can you get back to me with the answer about Linux so we can get the solution for you?

"iconv extension is part of Zend Core 2.5 but is disabled by default on Linux - does he use linux? If yes, we need to check if he tried to enable it.

We plan to release and updated version of Zend Core (2.5.2) in a month, that will bundle and support the latest ZF."

You can enable iconv by enabling the extension in your php.ini file. (/usr/local/Zend/Core/etc/php.ini on a Zend Core installation)

As I responded to Zend, if Zend Core and ZF are to work together, then these inconsistencies need to be ironed out. Either ZF is built to work on the current ZC, or ZC is brought up to date to support ZF. In any event it would be prudent to augment the ZF documentation to contain a section on using it with ZC on any platform.

This is more an improvement than a bug.

Actually this issue has to be discussed with devteam as it should be resolved with the whole ZF, not only this component.

The basic question is if we want to rely on mb* or iconv* or both.

New feature implemented with r13278