Join GitHub today
xPDOFileCache->get might return invalid data when use_flock is false #113
I think I spotted a problem in xPDOFileCache while looking into a cache corruption issue on NFS for a customer:
xPDOFileCache->get always uses flock even when use_flock is false. Meanwhile xPDOCacheManager->writeFile which is used by xPDOFileCache->set honours use_flock and will use file based locking if use_flock is false.
Step to reproduce
If use_flock is false cache files are read and their contents returned by get even when they are currently being (re)written.
If use_flock is false xPDOFileCache->get should return null when the existence of a lockfile signals that a (re)write is in progress.
Originally MODX 2.5.5 but this issue is present in 2.x und 3.x branches of modxcms/xpdo.
This issue is affecting an environment I support as well. Specifically, a load balanced set of servers that share a common NFS mount. Would a PR that conforms to the expected behavior listed in this issue be accepted?
"If use_flock is false xPDOFileCache->get should return null when the existence of a lockfile signals that a (re)write is in progress."