ZF-6785: Inconsistencies in Zend_Db_Table_Row_Abstract::toArray() and ::setFromArray()


The data returned by the toArray() function does not use getter methods that may have been set up, but setFromArray() does use the setter methods. As a result, while the following code can be perfectly valid for copying a property from one row object to another:

$rowObj1->prop1 = $rowObj2->prop1

This code can fail:


Specific example - Suppose prop1 is serialized before being written to the database, and the model contains the following functions:

public function setProp1($value) {
    $this->set('prop1', serialize($value));

public function getProp1() {
    return unserialize($this->get('prop1'));

On $rowObj1, the property prop1 would be serialized twice after running $rowObj1->setFromArray($rowObj2->toArray()).

I suspect the correct solution is to have toArray() use any getter methods that may have been set up.


added code-block tags to improve readability

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.