[ProfilerBundle] fixed storage read() method and unpack/pack data to avoid weird character in the data stream
This commit is contained in:
parent
e8119ce875
commit
450550d06d
@ -58,14 +58,20 @@ class ProfilerStorage
|
||||
protected function read()
|
||||
{
|
||||
$db = $this->initDb(SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READ);
|
||||
$this->data = $db->querySingle(sprintf("SELECT data FROM data WHERE token = '%s' LIMIT 1 ORDER BY created_at DESC", $db->escapeString($this->token)));
|
||||
$data = $db->querySingle(sprintf("SELECT data FROM data WHERE token = '%s' LIMIT 1 ORDER BY created_at DESC", $db->escapeString($this->token)));
|
||||
|
||||
$this->data = unserialize(pack('H*', $data));
|
||||
|
||||
$db->close();
|
||||
}
|
||||
|
||||
public function write($data)
|
||||
{
|
||||
$unpack = unpack('H*', serialize($data));
|
||||
$data = $unpack[1];
|
||||
|
||||
$db = $this->initDb(SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
|
||||
$db->exec(sprintf("INSERT INTO data (token, data, created_at) VALUES ('%s', '%s', %s)", $db->escapeString($this->token), $db->escapeString(serialize($data)), time()));
|
||||
$db->exec(sprintf("INSERT INTO data (token, data, created_at) VALUES ('%s', '%s', %s)", $db->escapeString($this->token), $db->escapeString($data), time()));
|
||||
$db->close();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user