From 2e38f5796c00e0cf52a9a5eb2dbdd70d52508926 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 1 Jan 2017 17:30:54 +0100 Subject: [PATCH] RemoteAPICore: do not rely on timestamps of saved revisions This fixes the remote API's relying on timestamps of files in the attic directory. While the timestamp of the current page is always the revision (and actually how the timestamp of the revision is determined), timestamps of attic files do not necessarily match the revision they represent. This should also fix random test failures in the remote api tests. --- inc/RemoteAPICore.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/inc/RemoteAPICore.php b/inc/RemoteAPICore.php index 407e63185b..0ff358cf95 100644 --- a/inc/RemoteAPICore.php +++ b/inc/RemoteAPICore.php @@ -449,14 +449,20 @@ public function pageInfo($id,$rev=''){ throw new RemoteException('The requested page does not exist', 121); } + // set revision to current version if empty, use revision otherwise + // as the timestamps of old files are not necessarily correct + if($rev === '') { + $rev = $time; + } + $pagelog = new PageChangeLog($id, 1024); - $info = $pagelog->getRevisionInfo($time); + $info = $pagelog->getRevisionInfo($rev); $data = array( 'name' => $id, - 'lastModified' => $this->api->toDate($time), + 'lastModified' => $this->api->toDate($rev), 'author' => (($info['user']) ? $info['user'] : $info['ip']), - 'version' => $time + 'version' => $rev ); return ($data); @@ -806,7 +812,7 @@ public function pageVersions($id, $first) { // specified via $conf['recent'] if($time){ $pagelog->setChunkSize(1024); - $info = $pagelog->getRevisionInfo($time); + $info = $pagelog->getRevisionInfo($rev ? $rev : $time); if(!empty($info)) { $data = array(); $data['user'] = $info['user'];