[pmwiki-devel] bug in RestorePage()?
Peter Bowers
pbowers at pobox.com
Fri Apr 10 13:42:03 CDT 2009
RestorePage() is designed to restore a page to the revision that was
active at the time specified in $restore. It appears to be intended
to accept a standard $page array and then process it, returning the
new text.
However, it appears that the $page array must be read in with a $since
of the same value as the $restore value or else RestorePage() doesn't
work.
Specifically this line in RestorePage() appears to be in error:
if ($k<$restore) break;
This appears to be trying to compare a timestamp with the desired
timestamp and not processing any more if we have passed the desired
timestamp. However, the key to this hash is actually
"diff:12341234:23452345" rather than just 12341234. Thus $k is
"diff:12341234:23452345" and that is being compared to $restore which
is "12341234". I believe that $k needs to be processed with a
substr() or a preg_match() or something to pull out the first
timestamp before this comparison is made.
This bug does not affect normal operation of page revisions because
the pages are always read with $since for any kind of restore.
However, recipes wanting to make use of RestorePage() can be strongly
affected. Either the requirement for a read with $since needs to be
clearly documented or (better) there needs to be a fix to
RestorePage()...
-Peter
More information about the pmwiki-devel
mailing list