/** * Applicable on image pages only, this changes the primary image on the page * from the most recent to the approved revision. **/ public static function onImagePageFindFile($imagePage, &$normalFile, &$displayFile) { // if ($normalFile) // $normalFile->purgeCache(); // if ($displayFile) // $displayFile->purgeCache(); list($approvedRev_ts, $approvedRev_sha1) = ApprovedRevs::GetApprovedFileInfo($imagePage->getFile()->getTitle()); if (!$approvedRev_ts || !$approvedRev_sha1) { return true; } $title = $imagePage->getTitle(); $displayFile = wfFindFile($title, array('time' => $approvedRev_ts)); # If none found, try current if (!$displayFile) { wfDebug(__METHOD__ . ": {$title->getPrefixedDBkey()}: {$approvedRev_ts} not found, using current\n"); $displayFile = wfFindFile($title); # If none found, use a valid local placeholder if (!$displayFile) { $displayFile = wfLocalFile($title); // fallback to current } $normalFile = $displayFile; # If found, set $normalFile } else { wfDebug(__METHOD__ . ": {$title->getPrefixedDBkey()}: using timestamp {$approvedRev_ts}\n"); $normalFile = wfFindFile($title); } return true; }