quickapps / cms

Modular CMS powered by CakePHP
GNU General Public License v3.0
164 stars 69 forks source link

SerializedType:: toPHP fails with Postgres when data is stored as BLOB #104

Closed aydot closed 9 years ago

aydot commented 9 years ago

Since Postgres stores uncorrupted serialized data as BLOB (bytea column type) [https://github.com/quickapps/cms/blob/2.0/src/Database/Type/SerializedType.php#L34] could be improved by having

public function toPHP($value, Driver $driver)
{
    if (is_resource($value)) {
        return @unserialize(stream_get_contents($value));
    }

    if ($this->_isSerialized($value)) {
        //@codingStandardsIgnoreStart
        $value = @unserialize($value);
        //@codingStandardsIgnoreEnd
    }
    return $value;
}

I'd happy to create a pull request and have a test for it.

quickapps commented 9 years ago

I see, could you please create the pull request and test case you mentioned? I would really appreciate it.

Thanks for reporting this one :)

aydot commented 9 years ago

Sorry for getting back late...I was thinking.. would the user just use binary type instead of serialized? cos CakePHP can handle it correctly when the field is binary.

quickapps commented 9 years ago

Yes, I think it's possible. The Serialized type is just used to store array & objects as plain text (text column types), I'll take a look to the binary type and see if Serialized type can be removed from Core in favor of Cake's binary type.

Out of curiosity, How has it been your experience with QuickApps CMS so far? Which features would you like to see in future releases?

Regards!

aydot commented 9 years ago

I haven't used it much, I plan to play around with it in the near future though, I will report back to you. thank you!