[pmwiki-users] Questions on release 2.0.0 (PageStore class)
Patrick R. Michaud
pmichaud at pobox.com
Fri Sep 2 13:01:50 CDT 2005
On Fri, Sep 02, 2005 at 07:58:33AM +0000, Karl Loncarek wrote:
> Just one small question to Pm:
> What is the line (in class PageStore in function write)
> $s = $s && (filesize("$pagefile,new") > $sz * 0.95);
> good for? Checking whether the new filesize has not reduced to much?
> Intended as check whether all went OK (and the file was not got corrupted)?
It's intended as a last-effort check that the file was completely saved.
PmWiki checks the error result code for every write made to disk,
but unfortunately some operating systems or versions of PHP don't
correctly report when an error in writing occurs. So, the above
makes sure that at least 95% of the expected file has been written
to disk before replacing the old copy of the file with the new one.
This is important because if the new file somehow ends up with
zero length because of a disk write error, then replacing the old
one with the new one loses the page contents and all of its history.
Of course, this filesize check won't really work for gzipped files,
since they typically compress to far less than 95% of the original
size. So, commenting it out is probably the right approach. However,
it also means that anyone who ends up on a system that doesn't
correctly report disk write errors will be at a small risk of losing
More information about the pmwiki-users