Skip to content

Commit

Permalink
Merge pull request joomla#1333 from stefanneculai/pdo
Browse files Browse the repository at this point in the history
PDO does not support serialization
  • Loading branch information
LouisLandry committed Jul 6, 2012
2 parents 0455225 + 8d85abc commit 893ba43
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions libraries/joomla/database/driver/pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -934,4 +934,48 @@ public function loadNextRow()

return false;
}

/**
* PDO does not support serialize
*
* @return array
*
* @since 12.3
*/
public function __sleep()
{
$serializedProperties = array();

$reflect = new ReflectionClass($this);

// Get properties of the current class
$properties = $reflect->getProperties();

// Static properties of the current class
$staticProperties = $reflect->getStaticProperties();

foreach ($properties as $key => $property)
{
// Do not serialize properties that are PDO
if ($property->isStatic() == false && !($this->{$property->name} instanceof PDO))
{
array_push($serializedProperties, $property->name);
}
}

return $serializedProperties;
}

/**
* Wake up after serialization
*
* @return array
*
* @since 12.3
*/
public function __wakeup()
{
// Get connection back
$this->__construct($this->options);
}
}

0 comments on commit 893ba43

Please sign in to comment.