protected function initCategories()
 {
     $categories = $this->wg->VideosModuleCategories;
     if (empty($categories)) {
         return;
     }
     $this->categories = $this->transformCatNames(wfReturnArray($categories));
 }
 /**
  * Called when a watched item is being updated. If the timestamp is null, this indicates the
  * watchers have seen the page so the watch can be cleared. If the time stamp is not null,
  * this indicates the watchers need to be notified and should be added to the global_watchlist.
  * @param $watchedItem WatchedItem: object
  * @param $watchers Array or Integer: array of user IDs or user ID
  * @param $timestamp Datetime or null
  * @return bool (always true)
  */
 public static function updateGlobalWatchList(WatchedItem $watchedItem, $watchers, $timestamp = null)
 {
     $watchers = wfReturnArray($watchers);
     if (is_null($timestamp)) {
         self::removeWatchers($watchedItem, $watchers);
     } else {
         self::addWatchers($watchedItem, $watchers);
     }
     return true;
 }
 /**
  * Exposes the VideoHandlerHelper::getVideoDetail method from this controller. If fileTitle is passed
  * to this method as a string, return a single associative array containing details for that video. Otherwise,
  * return an indexed array containing one associative array per video.
  * @requestParam array|string fileTitle - The title of the file to get details for
  * @requestParam array videoOptions
  *   [ array( 'thumbWidth' => int, 'thumbHeight' => int, 'postedInArticles' => int, 'getThumbnail' => bool, 'thumbOptions' => array ) ]
  * @requestParam int articleLimit - The number of "posted in" article detail records to return
  * @responseParam array detail - The video details
  */
 public function getVideoDetail()
 {
     wfProfileIn(__METHOD__);
     $fileTitle = $this->getVal('fileTitle', []);
     $returnSingleVideo = is_string($fileTitle);
     $fileTitleAsArray = wfReturnArray($fileTitle);
     $videoOptions = $this->getVideoOptionsWithDefaults($this->getVal('videoOptions', []));
     // Key to cache the data under in memcache
     $memcKey = wfMemcKey(__FUNCTION__, md5(serialize([$fileTitleAsArray, $videoOptions])));
     // How we'll get the data on a cache miss
     $dataGenerator = function () use($fileTitleAsArray, $videoOptions) {
         $videos = $this->getDetailsForVideoTitles($fileTitleAsArray, $videoOptions);
         // Take note when we are unable to get any details for a set of videos
         if (empty($videos)) {
             $log = WikiaLogger::instance();
             $log->info(__METHOD__ . ' empty details', ['titleCount' => count($fileTitleAsArray), 'titleString' => implode('|', $fileTitleAsArray)]);
         }
         return $videos;
     };
     // Call the generator, caching the result, or not caching if we get null from the $dataGenerator
     $videos = WikiaDataAccess::cacheWithOptions($memcKey, $dataGenerator, ['cacheTTL' => WikiaResponse::CACHE_STANDARD, 'negativeCacheTTL' => 0]);
     // If file title was passed in as a string, return single associative array.
     $this->detail = !empty($videos) && $returnSingleVideo ? array_pop($videos) : $videos;
     $this->response->setCacheValidity(WikiaResponse::CACHE_STANDARD);
     wfProfileOut(__METHOD__);
 }