dg / dibi

Dibi - smart database abstraction layer
https://dibiphp.com
Other
487 stars 136 forks source link

Dibi\DateTime::__wakeup() doesn't call parent #228

Closed mzstic closed 8 years ago

mzstic commented 8 years ago

After updating to 3.0.5 we started to get weird errors SQL which look like this:

...`foo`='bar', `datetime_registration`=, `aa`='bb', ...

There is missing dateTime value. , after a while we found out where problem is and what solution might be:

Following function in class Dibi\DateTime:

public function __wakeup()
{
    if (isset($this->fix)) {
        if (isset($this->fix[1])) {
            $this->__construct($this->fix[0], new \DateTimeZone($this->fix[1]));
        } else {
            $this->__construct($this->fix[0]);
       }
        unset($this->fix);
    }
}

Should be like this:

public function __wakeup()
{
    if (isset($this->fix)) {
        if (isset($this->fix[1])) {
            $this->__construct($this->fix[0], new \DateTimeZone($this->fix[1]));
        } else {
            $this->__construct($this->fix[0]);
       }
        unset($this->fix);
    } else {
        parent::__wakeup();
    }
}
mzstic commented 8 years ago

Shouldn't be released new version..? 3.0.5 is marked as stable, but in fact it is not stable because of this issue. But for now it's fixed only in dev-master. I want to have only stable packages installed and not fixed version to 3.0.4...