ZF-12453: Zend_Feed_Writer_Feed addAuthor() throwing exceptions

Description

Fatal error: Uncaught exception 'Zend_Feed_Exception' with message 'Invalid parameter: "name" must be a non-empty string value' ../library/Zend/Feed/Writer/Feed/FeedAbstract.php on line 122.

Once that's fixed we get another exception:

Fatal error: Uncaught exception 'Zend_Feed_Exception' with message 'Invalid parameter: "name" must be a non-empty string value' in ../library/Zend/Feed/Writer/Entry.php on line 119

This is due to code that won't ever work.

Patch

Change line 120 in Zend_Feed_Writer_Feed_FeedAbstract to:


if (empty($name) || !is_string($name)) {

AND

Change line 117 in Zend_Feed_Writer_Entry to:


if (empty($name) || !is_string($name)) {

Comments

I think this issue is related to the PHP version, because in version 5.3.6 there are no errors:


$name = 'Joe';
var_dump($name['name']); // string (1) "J"

Add patches. (Unit tests already there.)

I'm using 5.4. But I think this code should never work. Maybe the new behaviour of 5.4 causes an exception rather than a hidden bug. http://php.net/manual/en/…

"As of PHP 5.4 string offsets have to either be integers or integer-like strings, otherwise a warning will be thrown. Previously an offset like "foo" was silently cast to 0." http://php.net/manual/en/…

Fix unit tests. (Replace "assertType")

Patch applied on trunk (25082) and release-1.12 (25083)