title: how to unserialize this data with php?
body: <p>I've got this data set which was probably serialised with php function serialize()</p>
  
  <pre><code>C:8:"Poreikis":768:{a:14:{s:3:"_id";a:1:{s:2:"id";s:4:"5889";}s:5:"_data";a:12:{s:2:"id";s:4:"5889";s:11:"stokojantis";s:4:"2748";s:17:"parent_kategorija";s:1:"1";s:10:"kategorija";s:1:"3";s:11:"pavadinimas";s:6:"Komoda";s:9:"aprasymas";s:89:"blah blah";s:7:"pasiula";N;s:6:"active";s:1:"Y";s:10:"created_at";s:19:"2013-02-10 12:10:48";s:10:"updated_at";s:19:"2013-02-10 12:10:48";s:7:"creator";s:4:"1842";s:6:"editor";N;}s:7:"_values";a:0:{}s:6:"_state";i:3;s:13:"_lastModified";a:0:{}s:9:"_modified";a:0:{}s:10:"_oldValues";a:0:{}s:15:"_pendingDeletes";a:0:{}s:15:"_pendingUnlinks";a:0:{}s:20:"_serializeReferences";b:0;s:17:"_invokedSaveHooks";b:0;s:4:"_oid";i:2;s:8:"_locator";N;s:10:"_resources";a:0:{}}}
  </code></pre>
  
  <p>I've tried <code>unserialize()</code> function:</p>
  
  <pre><code>var_dump( unserialize($var) );
  </code></pre>
  
  <p>and I've got this:</p>
  
  <pre><code>PHP Warning:  Class __PHP_Incomplete_Class has no unserializer in /root/hacked.php on line 4
  object(__PHP_Incomplete_Class)#1 (1) {
    ["__PHP_Incomplete_Class_Name"]=&gt;
    string(8) "Poreikis"
  }
  </code></pre>
  
  <p>and I've also tried this with python:</p>
  
  <pre><code>  1 #!/usr/bin/env python
    2 # -*- coding: utf-8 -*-
    3 
    4 import pprint
    5 import phpserialize
    6 from path import path
    7
    8 #filename   = sys.argv[1]
    9 content     = u'_THAT_STRING_FROM_TOP'
   10
   11 unser = phpserialize.unserialize(content)
   13 print unser
  </code></pre>
  
  <p>got this</p>
  
  <pre><code>~# python unserialize.py
  Traceback (most recent call last):
    File "hacked.py", line 11, in &lt;module&gt;
      unser = phpserialize.unserialize(content)
    File "/usr/local/lib/python2.7/dist-packages/phpserialize.py", line 522, in loads
      object_hook, array_hook)
    File "/usr/local/lib/python2.7/dist-packages/phpserialize.py", line 512, in load
      return _unserialize()
    File "/usr/local/lib/python2.7/dist-packages/phpserialize.py", line 510, in _unserialize
      raise ValueError('unexpected opcode')
  </code></pre>
  
  <p>Seems that variable maybe invalid? Ok, so now about this data. </p>
  
  <p>There's ORM engine in PHP called "Doctrine", and there's a model class in doctrine called 'BaseRecycleBin.php', which is actually defining a table called '_deleted_items', which stores this kind of value. And I've even found that <a href="http://svn.doctrine-project.org/branches/0.11/lib/Doctrine/Parser/Serialize.php" rel="nofollow">serialization class</a> in doctrine. Which seems to be doesn't do anything irregular at all.</p>
  
  <p>So main question is: how to unserialize this string?</p>
  
  <p>Also if it's possible to answer, does Doctrine can restore that data back from that table? Cause this is my original intension, to construct queries from lots of serialised strings, which originally are from that '_deleted_items' table.</p>