/** * Examine every non-premium video on this wiki and add suggestions where needed. * @return array - An associative array of stats from processing the videos */ private function processVideoList() { wfProfileIn(__METHOD__); $suggestDateProp = WPP_LVS_SUGGEST_DATE; $suggestExpire = time() - LicensedVideoSwapHelper::SUGGESTIONS_TTL; $pageNS = NS_FILE; // Only select videos with nonexistent or expired suggestions unless --refresh is on $whereExpired = ''; if (!$this->refresh) { $whereExpired = " AND (props IS NULL OR props <= {$suggestExpire})"; } // A list of all videos, returning the video title, its file page ID and $sql = "SELECT video_title as title,\n\t\t\t\t\t page.page_id as page_id,\n\t\t\t\t\t props as suggest_date\n\t\t\t\t FROM video_info\n\t\t\t\t JOIN page\n\t\t\t\t ON video_title = page_title\n\t\t\t\t AND page_namespace = {$pageNS}\n\t\t\t\t LEFT JOIN page_wikia_props\n\t\t\t\t ON page.page_id = page_wikia_props.page_id\n\t\t\t\t AND propname = {$suggestDateProp}\n\t\t\t\t WHERE removed = 0\n\t\t\t\t AND premium = 0\n\t\t\t\t {$whereExpired}"; $db = wfGetDB(DB_SLAVE); $results = $db->query($sql, __METHOD__); $lvsHelper = new LicensedVideoSwapHelper(); $vidsFound = 0; $vidsWithSugggestions = 0; $totalSuggestions = 0; // Get the total count of relevant videos while ($row = $db->fetchObject($results)) { $vidsFound++; $title = $row->title; $this->debug("Processing '{$title}'\n"); // This sets page_wikia_props for WPP_LVS_SUGGEST_DATE, WPP_LVS_EMPTY_SUGGEST and WPP_LVS_SUGGEST $suggestions = $lvsHelper->suggestionSearch($title, $this->test, $this->verbose); if ($suggestions) { $vidsWithSugggestions++; $totalSuggestions += count($suggestions); $this->debug("\tFound " . count($suggestions) . " suggestion(s)\n"); } else { $this->debug("\tNo suggestions found\n"); } } // clear cache for total videos $lvsHelper->invalidateCacheTotalVideos(); // clear cache for total new videos $lvsHelper->invalidateCacheTotalNewVideos(); wfProfileOut(__METHOD__); return array('vidsFound' => $vidsFound, 'vidsWithSuggestions' => $vidsWithSugggestions, 'totalSuggestions' => $totalSuggestions); }