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

Issue Type: Bug Created: 2009-05-22T18:41:51.000+0000 Last Updated: 2012-11-20T20:52:55.000+0000 Status: Closed Fix version(s): Reporter: Mason Wolf (dooby) Assignee: None Tags: - Zend_Db_Table

Related issues: Attachments:


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:

<pre class="highlight">
$rowObj1->prop1 = $rowObj2->prop1

This code can fail:

<pre class="highlight">

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

<pre class="highlight">
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.


Posted by Mason Wolf (dooby) on 2009-05-22T18:44:03.000+0000

added code-block tags to improve readability

Posted by Rob Allen (rob) on 2012-11-20T20:52:55.000+0000

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.