Also, as far as I can remember, mb_list_encodings() is an horrible
performance clogger. On my last project, it was accounted for more than
75% of the pages loading time. It might not have been used in the same
context, though, but I sure hope you know what you're doing when
implementing things like these. I'd like to hear some feedback about
this, just to know if it's still the case.
Regards,
-- Nicolas
Lucas CORBEAUX a écrit :
Hello there,
As I'm working on migrating my projects into 1.10.0 I found a breaking
feature in Zend_Filter_StringToUpper (and probably in some others
filters / validators working with mbstring functions) in the setEncoding
method.
Here is the problem :
$encoding = (string) $encoding;
if (!in_array($encoding, mb_list_encodings())) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("The given encoding '$encoding' is
not supported by mbstring");
}
Now the encoding is checked, that's a great thing. But the following
guide : http://framework.zend.com/manual/1.10/en/migration.110.html
doesn't talk about this feature, which can break some project. Ok,
that's not a real problem, because in case of an incorrect encoding
mbstring functions display a warning.
But there is, in my opinion, a real problem. Mbstring functions are case
insensitives with the encoding param, but the following test :
if (!in_array($encoding, mb_list_encodings()))
Is case sensitive.
So the following code will throw an exception :
$filter = new Zend_Filter_StringToUpper();
$filter->setEncoding('utf-8'); // mb_strtoupper($myString, 'utf-8')
seems to work fine...
I'm not sure if it's a desired behavior or if it's an issue, but, at
least, I think one or two words about it in the migration guide should
be really welcome ;)
Lucas