added tokenDataExists() method to prevent loading complete profile structures upon writes
This commit is contained in:
parent
1e15f21096
commit
46be1212f2
@ -92,7 +92,7 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($this->read($profile->getToken())) {
|
if ($this->tokenDataExists($profile->getToken())) {
|
||||||
$this->exec($db, 'UPDATE sf_profiler_data SET parent = :parent, data = :data, ip = :ip, method = :method, url = :url, time = :time, created_at = :created_at WHERE token = :token', $args);
|
$this->exec($db, 'UPDATE sf_profiler_data SET parent = :parent, data = :data, ip = :ip, method = :method, url = :url, time = :time, created_at = :created_at WHERE token = :token', $args);
|
||||||
} else {
|
} else {
|
||||||
$this->exec($db, 'INSERT INTO sf_profiler_data (token, parent, data, ip, method, url, time, created_at) VALUES (:token, :parent, :data, :ip, :method, :url, :time, :created_at)', $args);
|
$this->exec($db, 'INSERT INTO sf_profiler_data (token, parent, data, ip, method, url, time, created_at) VALUES (:token, :parent, :data, :ip, :method, :url, :time, :created_at)', $args);
|
||||||
@ -236,4 +236,20 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface
|
|||||||
|
|
||||||
return $profiles;
|
return $profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether data for the given token already exists in storage.
|
||||||
|
*
|
||||||
|
* @param string $token
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
protected function tokenDataExists($token)
|
||||||
|
{
|
||||||
|
$db = $this->initDb();
|
||||||
|
$tokenExists = $this->fetch($db, 'SELECT 1 FROM sf_profiler_data WHERE token = :token LIMIT 1', array(':token' => $token));
|
||||||
|
$this->close($db);
|
||||||
|
|
||||||
|
return !empty($tokenExists);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user