diff --git a/libraries/joomla/table/table.php b/libraries/joomla/table/table.php index ee485fcf9039c..6a372321d2260 100644 --- a/libraries/joomla/table/table.php +++ b/libraries/joomla/table/table.php @@ -19,7 +19,7 @@ * @since 11.1 * @tutorial Joomla.Platform/jtable.cls */ -abstract class JTable extends JObject implements JObservableInterface, JTableInterface +abstract class JTable extends JObject implements JObservableInterface, JTableInterface, Serializable { /** * Include paths for searching for JTable classes. @@ -1711,4 +1711,33 @@ protected function _unlock() return true; } + + /** + * Implement Serializable. Prevent DB object getting into serialized string. + * + * @return string + */ + public function serialize() + { + $vars = get_object_vars($this); + unset ($vars['_db']); + return serialize($vars); + } + + /** + * Implement Serializable. DB object needs to be restored separately as it was excluded from serialization. + * + * @param string $data A serialized string matching this class. + * + * @return void + */ + public function unserialize($data) + { + $vars = unserialize($data); + foreach ($vars as $key => $value) + { + $this->$key = $value; + } + $this->_db = JFactory::getDBO(); + } }