Jump to content

Files disappearing when read


Lexas

Recommended Posts

Hello guys, I'm having a very strange issue. I use Wordpress and started using WP File Cache to implement caches.

 

Explaining to those who don't know, Wordpress has a caching system built-in, but it only works during page load, stores data in RAM and then deletes everything. On each page load cache starts empty and when load finishes it's all deleted. WP File Cache implements HD caching, so that data cached on a page load remains there, and on next load it's used again. There's no direct relation to database queries, this cache must be explicitly used.

 

My problem is that it's not working at all, I see files being written, but on every page load cache is empty. I tested it both in my local development environment using Apache over WinXP and in my host using linux and LiteSpeed.

 

 

I tried to debug it, and I see files are written using

@file_put_contents($fname, serialize($data), LOCK_EX);

, which returns some amount of bytes written. I also see files existing in HD.

 

When cache is read, it uses

$files = glob($fname);

. It should return an array with all found files, empty array when not found and false when error happens. It always returns empty array, which is tested with

empty($files)

and returns.

 

If cache file would be found, it would be read with

$this->cache[$group][$key] = unserialize(@file_get_contents($result, LOCK_EX));

, but this code is never run because function returns before it. I print_r glob() output and always got

Array ( )

.

 

 

Since I see files there, I know it succeeds when writing, but files disappear after that and PHP reports they weren't found. I wasn't able to assure if glob() is deleting them or if something else is and glob() doesn't find them, but it's very strange no file being found when denz of them are created. If they were found, they should last for 1h

$ttl = 3600; @filemtime($files[0]) > time() - $ttl

and then deleted

@unlink($files[0]);

, but these code also never run.

 

 

Any idea what may be happening and what I can do to find the cause and fix it?

Link to comment
https://forums.phpfreaks.com/topic/204454-files-disappearing-when-read/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.