You are here

public function MarkdownBenchmark::unserialize in Markdown 3.0.x

File

src/MarkdownBenchmark.php, line 301

Class

MarkdownBenchmark
Class MarkdownBenchmark.

Namespace

Drupal\markdown

Code

public function unserialize($serialized) {
  $data = unserialize($serialized);

  // Data was gzipped.
  if ($data['gzip']) {

    // Decompress data if PHP has gzip capabilities.
    if (extension_loaded('zlib')) {
      $data['object'] = gzdecode(base64_decode($data['object']));
    }
    else {
      $this->result = sprintf('This cached %s object was stored using gzip compression. Unable to decompress. The PHP on this server must have the "zlib" extension installed.', static::class);
      return;
    }
  }
  $object = unserialize($data['object']);
  foreach ($object as $prop => $value) {
    $this->{$prop} = $value;
  }
}