@@ -31,9 +31,9 @@ class FileStorage implements Nette\Caching\IStorage
31
31
* delete* = try unlink, if fails (on NTFS) { lock(EX), truncate, close, unlink } else close (on ext3)
32
32
*/
33
33
34
- /** @internal cache file structure */
34
+ /** @internal cache file structure: meta-struct size + serialized meta-struct + data */
35
35
private const
36
- META_HEADER_LEN = 28 , // 22b signature + 6b meta-struct size + serialized meta-struct + data
36
+ META_HEADER_LEN = 6 ,
37
37
// meta structure: array of
38
38
META_TIME = 'time ' , // timestamp
39
39
META_SERIALIZED = 'serialized ' , // is content serialized?
@@ -205,8 +205,8 @@ public function write(string $key, $data, array $dp): void
205
205
$ meta [self ::META_SERIALIZED ] = true ;
206
206
}
207
207
208
- $ head = serialize ($ meta ) . ' ?> ' ;
209
- $ head = ' <?php //netteCache[01] ' . str_pad ((string ) strlen ($ head ), 6 , '0 ' , STR_PAD_LEFT ) . $ head ;
208
+ $ head = serialize ($ meta );
209
+ $ head = str_pad ((string ) strlen ($ head ), 6 , '0 ' , STR_PAD_LEFT ) . $ head ;
210
210
$ headLen = strlen ($ head );
211
211
212
212
do {
@@ -321,9 +321,8 @@ protected function readMetaAndLock(string $file, int $lock): ?array
321
321
322
322
flock ($ handle , $ lock );
323
323
324
- $ head = stream_get_contents ($ handle , self ::META_HEADER_LEN );
325
- if ($ head && strlen ($ head ) === self ::META_HEADER_LEN ) {
326
- $ size = (int ) substr ($ head , -6 );
324
+ $ size = (int ) stream_get_contents ($ handle , self ::META_HEADER_LEN );
325
+ if ($ size ) {
327
326
$ meta = stream_get_contents ($ handle , $ size , self ::META_HEADER_LEN );
328
327
$ meta = unserialize ($ meta );
329
328
$ meta [self ::FILE ] = $ file ;
0 commit comments