Some method signatures used in Zend_Search_Lucene and Zend_Pdf have an
optional encoding parameter which defaults to empty-string.  A couple
examples:
Zend_Search_Lucene_Field::Text($name, $value, [$encoding=''])
Zend_Pdf_Page::drawText($text, $x, $y, [$charEncoding=''])

Using these methods with the default of empty causes serious problems on
some of our Solaris servers because PHP's iconv() function fails when passed
an empty $in_encoding parameter.  The php.net docs have no default defined
for that parameter and behavior is not defined for the function when given
an empty/null first parameter.  The call results in a false return value and
a Notice: iconv(): Wrong charset, conversion from `' to `UTF-8' is not
allowed"  (where UTF-8 is typically the output encoding used by the ZF
component).

Is it maybe a problem with ZF code that it allows empty values to be passed
through to this function for which it does not appear that empty input is
supported?  I'd argue that all code that uses iconv() (and other iconv
extension functions) should make sure that the default value for input
encoding parameters is not empty, but instead is set to the value of
iconv_get_encoding('input') or ini_get('iconv.input_encoding') (probably the
former).

Obviously I can fix this by specifying the encoding parameter to all my
calls; but other people who don't have the capability to track down this
issue on their own might not get that far.  And the fact that it only
generates a Notice-level error compounds the problem since most (?) people
will never see that message.

Big disclaimer:  it doesn't happen on all of our servers.  Me and people
much smarter than myself have tried and failed to find any difference in
iconv or PHP configuration between those servers (5.2.4, libiconv 1.11).  If
anyone's got any ideas on that front, I'm all ears.

Reply via email to