Skip to content

Commit 9824065

Browse files
authored
Check if file exists on FileStorage (php-debugbar#777)
1 parent 61334cf commit 9824065

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/DebugBar/DebugBar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ public function getStackedData($delete = true)
386386
$datasets = $stackedData;
387387
}
388388

389-
return $datasets;
389+
return array_filter($datasets);
390390
}
391391

392392
/**

src/DebugBar/Storage/FileStorage.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ public function save($id, $data)
4141
*/
4242
public function get($id)
4343
{
44-
return json_decode(file_get_contents($this->makeFilename($id)), true);
44+
$fileName = $this->makeFilename($id);
45+
if (!file_exists($fileName)) {
46+
return [];
47+
}
48+
49+
return json_decode(file_get_contents($fileName), true);
4550
}
4651

4752
/**

0 commit comments

Comments
 (0)