Skip to content

Commit

Permalink
[HttpKernel] fixed file profile storage when trying to read an empty …
Browse files Browse the repository at this point in the history
…token
  • Loading branch information
fabpot committed Oct 14, 2011
1 parent 7816290 commit cc76da1
Showing 1 changed file with 6 additions and 8 deletions.
Expand Up @@ -81,7 +81,7 @@ public function find($ip, $url, $limit)
'ip' => $csvIp,
'url' => $csvUrl,
'time' => $csvTime,
'parent' => $csvParent
'parent' => $csvParent,
);

$result[] = $row;
Expand Down Expand Up @@ -116,9 +116,7 @@ public function purge()
*/
public function read($token)
{
$file = $this->getFilename($token);

if (!file_exists($file)) {
if (!$token || !file_exists($file = $this->getFilename($token))) {
return null;
}

Expand Down Expand Up @@ -159,7 +157,7 @@ public function write(Profile $profile)
$profile->getIp(),
$profile->getUrl(),
$profile->getTime(),
$profile->getParent() ? $profile->getParent()->getToken() : null
$profile->getParent() ? $profile->getParent()->getToken() : null,
));
fclose($file);

Expand All @@ -171,7 +169,7 @@ public function write(Profile $profile)
fclose($fp);
}

return ! $exists;
return !$exists;
}

/**
Expand Down Expand Up @@ -205,7 +203,7 @@ protected function getChildrenFilename($token)
*/
protected function getIndexFilename()
{
return $this->folder.'/'.'index.csv';
return $this->folder.'/index.csv';
}

/**
Expand Down Expand Up @@ -246,6 +244,6 @@ protected function readLineFromFile($file)
fseek($file, -2, SEEK_CUR);
}

return $str === "" ? $this->readLineFromFile($file) : $str;
return $str === '' ? $this->readLineFromFile($file) : $str;
}
}

0 comments on commit cc76da1

Please sign in to comment.