/** * Update thumbnail data (update database and clear cache) * @param File $file * @return Status $status */ public function updateThumbnailData($file) { wfProfileIn(__METHOD__); // check for read only mode if (wfReadOnly()) { wfProfileOut(__METHOD__); return Status::newFatal(wfMessage('videos-error-readonly')->plain()); } $props = $file->repo->getFileProps($file->getVirtualUrl()); if (empty($props['size']) || empty($props['width']) || empty($props['height']) || empty($props['bits']) || empty($props['sha1']) || $props['sha1'] == $file->getSha1()) { wfProfileOut(__METHOD__); return Status::newGood(0); } $dbw = wfGetDB(DB_MASTER); $dbw->begin(); $dbw->update('image', array('img_size' => $props['size'], 'img_width' => intval($props['width']), 'img_height' => intval($props['height']), 'img_bits' => $props['bits'], 'img_sha1' => $props['sha1']), array('img_name' => $file->getName()), __METHOD__); $affected = $dbw->affectedRows(); $dbw->commit(); $status = Status::newGood($affected); if ($affected > 0) { $file->purgeEverything(); } wfProfileOut(__METHOD__); return $status; }