/** * 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) { list($approvedRevTimestamp, $approvedRevSha1) = ApprovedRevs::getApprovedFileInfo($imagePage->getFile()->getTitle()); if (!$approvedRevTimestamp || !$approvedRevSha1) { return true; } $title = $imagePage->getTitle(); $displayFile = wfFindFile($title, array('time' => $approvedRevTimestamp)); # If none found, try current if (!$displayFile) { wfDebug(__METHOD__ . ": {$title->getPrefixedDBkey()}: {$approvedRevTimestamp} 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 {$approvedRevTimestamp}\n"); $normalFile = wfFindFile($title); } return true; }