/** * {@inheritdoc} */ public function serialize() { // Cleanup the connection, much like __destruct() does it as well. if ($this->needsCleanup) { $this->nextIdDelete(); } $this->needsCleanup = FALSE; return parent::serialize(); }