Browse files

Rewrote Filesystem->getDataFromFile file for clarity

Reworked the code to make it clearer, and expanded on comments.
  • Loading branch information...
1 parent 3d6f5c7 commit f4464cab8a967c533c28ed3b3308305e8be5da99 @tedivm tedivm committed Dec 26, 2012
Showing with 21 additions and 1 deletion.
  1. +21 −1 src/Stash/Driver/FileSystem.php
View
22 src/Stash/Driver/FileSystem.php
@@ -132,7 +132,27 @@ static protected function getDataFromFile($path)
}
include($path);
- return !isset($data) && !@is_null($data) ? false : array('data' => $data, 'expiration' => $expiration);
+
+ // If the item does not exist we should return false. However, it's
+ // possible that the item exists as null, so we have to make sure that
+ // it's both unset and not null. The downside to this is that the
+ // is_null function will issue a warning on an item that
+
+ // Item exists
+ // isset + is_null = true + false = true
+ if(isset($data))
+ {
+ return array('data' => $data, 'expiration' => $expiration);
+
+ // Item is null
+ // isset + is_null = false + true = true
+ }elseif(@is_null($data)){
+ return array('data' => null, 'expiration' => $expiration);
+ }
+
+ // Item does not exist
+ // isset + is_null = false + notice/false = false
+ return false;
}

0 comments on commit f4464ca

Please sign in to comment.