public function delete($key)
 {
     $db = $this->getSpecialsDB(DB_MASTER);
     $result = $db->delete(self::TABLE_NAME, [self::DB_KEY_FIELD => $key], __METHOD__);
     WikiaDataAccess::cachePurge($this->getMemcacheKey($key));
     return $result;
 }
 /**
  * @desc Returns an array with all available components configuration
  *
  * @return array
  */
 public function getAllComponents()
 {
     $components = WikiaDataAccess::cache(wfSharedMemcKey(__CLASS__, 'all_components_list_with_details', self::MEMCACHE_VERSION_KEY, $this->userLangCode), Wikia\UI\Factory::MEMCACHE_EXPIRATION, [$this, 'getAllComponentsFromDirectories']);
     $this->initComponents($components);
     $this->includeComponentsAssets($components);
     return $components;
 }
 protected static function getFileInfo($name)
 {
     $info = \WikiaDataAccess::cache(self::getFileKey($name), self::ICON_CACHE_TTL, function () use($name) {
         $file = \GlobalFile::newFromText($name . '.gif', \Wikia::NEWSLETTER_WIKI_ID);
         return ['name' => $name, 'url' => $file->getUrlGenerator()->url(), 'height' => $file->getHeight(), 'width' => $file->getWidth()];
     });
     return $info;
 }
 public function getCommercialUseNotAllowedWikis()
 {
     if (empty(self::$wikiList)) {
         self::$wikiList = WikiaDataAccess::cache(wfSharedMemcKey(self::CACHE_KEY_COMMERCIAL_NOT_ALLOWED), self::CACHE_VALID_TIME, function () {
             return $this->getWikisWithVar();
         });
     }
     return self::$wikiList;
 }
 public function getCollection(Category $category)
 {
     return WikiaDataAccess::cache($this->getItemsCollectionCacheKey($category->getID()), self::CACHE_TTL_ITEMSCOLLECTION, function () use($category) {
         wfProfileIn(__METHOD__);
         $viewer = new WikiaMobileCategoryViewer($category);
         $viewer->doCategoryQuery();
         wfProfileOut(__METHOD__);
         return $viewer->getData();
     });
 }
 public function saveWikiaStatsInWF()
 {
     $statsValues = $this->request->getVal('statsValues');
     if ($this->wg->User->isAllowed('wikifactory')) {
         WikiaDataAccess::cachePurge($this->getStatsMemcacheKey());
         WikiaStatsModel::setWikiaStatsInWF($statsValues);
     } else {
         throw new PermissionsException('wikifactory');
     }
 }
 public function loadData(EditHubModel $model, $params)
 {
     $hubParams = $this->getHubsParams();
     $lastTimestamp = $model->getLastPublishedTimestamp($hubParams, $params['ts']);
     $structuredData = WikiaDataAccess::cache($this->getMemcacheKey($lastTimestamp, $this->skinName), 6 * 60 * 60, function () use($model, $params) {
         return $this->loadStructuredData($model, $params);
     });
     if ($this->getShouldFilterCommercialData()) {
         $structuredData = $this->filterCommercialData($structuredData);
     }
     return $structuredData;
 }
 /**
  * @param int $limit limit number of results.
  * @param array $namespaces list of namespaces to filter by. No filter applied if null
  * @return array
  */
 public function getLatestRevisions($limit, $namespaces)
 {
     $key = self::createCacheKey($this->queryLimit, $namespaces);
     $listOfRevisions = WikiaDataAccess::cache($key, $this->cacheTime, function () use($namespaces) {
         return $this->getLatestRevisionsNoCacheAllowDuplicates($this->queryLimit, $namespaces);
     });
     $filterMethod = $this->getFilterMethod();
     if ($filterMethod !== self::DEFAULT_FILTERING_METHOD) {
         $listOfRevisions = $this->{$filterMethod}($listOfRevisions);
     }
     $listOfRevisions = $this->limitCount($listOfRevisions, $limit);
     return $listOfRevisions;
 }
 /**
  * @param int $articleId
  * @param int $limit - max limit = 10
  * @return array of articles with details
  */
 public function get($articleId, $limit)
 {
     wfProfileIn(__METHOD__);
     $hubName = $this->getHubName();
     $lang = $this->getContentLangCode();
     $out = \WikiaDataAccess::cache(\wfSharedMemcKey('RecommendationApi', self::RECOMMENDATION_ENGINE, $hubName, $lang, self::MCACHE_VERSION), \WikiaResponse::CACHE_STANDARD, function () use($hubName, $lang) {
         $topArticles = $this->getTopArticles($hubName, $lang);
         return $this->getArticlesInfo($topArticles);
     });
     shuffle($out);
     $out = array_slice($out, 0, $limit);
     wfProfileOut(__METHOD__);
     return $out;
 }
 /**
  * @desc Fetch all time top contributors for article
  *
  * @param int $articleId - Article id
  * @param $limit - maximum number of contributors to fetch
  * @return array
  */
 public function topContributorsPerArticle($articleId, $limit)
 {
     $key = self::getTopContributorsKey($articleId, $limit);
     $method = __METHOD__;
     $contributions = WikiaDataAccess::cache($key, self::CACHE_TIME_TOP_CONTRIBUTORS, function () use($articleId, $limit, $method) {
         // Log DB hit
         Wikia::log($method, false, sprintf('Cache for articleId: %d was empty', $articleId));
         $db = wfGetDB(DB_SLAVE);
         $res = $db->select('revision', ['rev_user', 'count(1) AS cntr'], ['rev_page = ' . $articleId, 'rev_deleted = 0', 'rev_user != 0'], $method, ['GROUP BY' => 'rev_user', 'ORDER BY' => 'count(1) DESC', 'LIMIT' => $limit]);
         $result = [];
         while ($row = $db->fetchObject($res)) {
             $result[(int) $row->rev_user] = (int) $row->cntr;
         }
         return $result;
     });
     // Cached results may contain more than the $limit results
     $contributions = array_slice($contributions, 0, $limit, true);
     return array_keys($contributions);
 }
 function testCacheHit()
 {
     $key = 'TESTKEY';
     $value = 'TESTVALUE' . rand();
     $ttl = 568;
     // Mock our memcache class
     $memc = $this->getMock('MemcachedPhpBagOStuff');
     // 'get' should be called and return our value
     $memc->expects($this->once())->method('get')->willReturn($value);
     // 'set' should never be called
     $memc->expects($this->never())->method('set');
     // Set the memc used to our mock object
     F::app()->wg->Memc = $memc;
     // Cache backed data access
     $returnValue = WikiaDataAccess::cache($key, $ttl, function () use($value) {
         return $value;
     });
     // Make sure we get back what we expect
     $this->assertEquals($value, $returnValue, 'Cache MISS test');
 }
 /**
  * Gets data from ArticlesApi and renders it
  */
 public function index()
 {
     $this->response->setTemplateEngine(WikiaResponse::TEMPLATE_ENGINE_MUSTACHE);
     if ($this->wg->Request->getVal('action', 'view') == 'view' && $this->wg->Title->getArticleId() != 0) {
         $trendingArticles = WikiaDataAccess::cache(wfMemcKey(__METHOD__, self::MAX_TRENDING_ARTICLES), 86400, function () {
             $trendingArticles = [];
             //fetch Trending Articles
             try {
                 $trendingArticlesData = $this->app->sendRequest('ArticlesApi', 'getTop')->getVal('items');
             } catch (Exception $e) {
                 $trendingArticlesData = false;
             }
             if (!empty($trendingArticlesData)) {
                 $items = array_slice($trendingArticlesData, 0, self::MAX_TRENDING_ARTICLES);
                 //load data from response to template
                 $trendingArticles = [];
                 foreach ($items as $item) {
                     $img = $this->app->sendRequest('ImageServing', 'getImages', ['ids' => [$item['id']], 'height' => self::IMG_HEIGHT, 'width' => self::IMG_WIDTH, 'count' => 1])->getVal('result');
                     $thumbnail = $img[$item['id']][0]['url'];
                     if (empty($thumbnail)) {
                         $thumbnail = false;
                     }
                     $trendingArticles[] = ['url' => $item['url'], 'title' => $item['title'], 'imgUrl' => $thumbnail, 'width' => self::IMG_WIDTH, 'height' => self::IMG_HEIGHT];
                 }
             }
             return $trendingArticles;
         });
         if (!empty($trendingArticles)) {
             $this->response->setVal('trendingArticles', $trendingArticles);
             $this->response->setVal('blankImg', $this->wg->BlankImgUrl);
             $this->response->setVal('trendingArticlesHeading', wfMessage('wikiamobile-trending-articles-heading')->plain());
         } else {
             $this->skipRendering();
         }
     } else {
         $this->skipRendering();
     }
 }
Exemple #13
0
 public function createDefaultBoard()
 {
     wfProfileIn(__METHOD__);
     $app = F::App();
     if (!$this->hasAtLeast(NS_WIKIA_FORUM_BOARD, 0)) {
         WikiaDataAccess::cachePurge(wfMemcKey('Forum_hasAtLeast', NS_WIKIA_FORUM_BOARD, 0));
         /* the wgUser swap is the only way to create page as other user then current */
         $tmpUser = $app->wg->User;
         $app->wg->User = User::newFromName(Forum::AUTOCREATE_USER);
         for ($i = 1; $i <= 5; $i++) {
             $body = wfMessage('forum-autoboard-body-' . $i, $app->wg->Sitename)->inContentLanguage()->text();
             $title = wfMessage('forum-autoboard-title-' . $i, $app->wg->Sitename)->inContentLanguage()->text();
             $this->createBoard($title, $body, true);
         }
         $app->wg->User = $tmpUser;
         wfProfileOut(__METHOD__);
         return true;
     }
     wfProfileOut(__METHOD__);
     return false;
 }
 /**
  * Update Restricted wiki list if necessary
  *
  * @param $city_id integer Wiki id in wikicities
  * @param $is_restricted bool True if wiki is restricted
  */
 public static function updateRestrictedWikis($city_id, $is_restricted)
 {
     $changed = false;
     $restrictedWikis = self::getRestrictedWikisIds();
     if ($is_restricted) {
         if (!in_array($city_id, $restrictedWikis)) {
             $restrictedWikis[] = $city_id;
             $changed = true;
         }
     } else {
         if (($index = array_search($city_id, $restrictedWikis)) !== false) {
             unset($restrictedWikis[$index]);
             $changed = true;
         }
     }
     if ($changed) {
         self::saveRestrictedWikisDB($restrictedWikis);
         WikiaDataAccess::cachePurge(self::getRestrictedWikisKey());
     }
 }
 protected function getTopArticles($wikiId, $lang)
 {
     return \WikiaDataAccess::cache(wfSharedMemcKey("CombinedSearchService", $wikiId, $lang), self::TOP_ARTICLES_CACHE_TIME, function () use($wikiId, $lang) {
         $timer = Time::start(["CombinedSearchService", "getTopArticles"]);
         $requestedFields = ["title", "url", "id", "score", "pageid", "lang", "wid", "article_quality_i", Utilities::field('html', $lang)];
         $topArticlesMap = \DataMartService::getTopArticlesByPageview($wikiId, null, [NS_MAIN], false, self::TOP_ARTICLES_PER_WIKI + 1);
         $query = " +(" . Utilities::valueForField("wid", $wikiId) . ") ";
         $query .= " +( " . implode(" OR ", array_map(function ($x) {
             return Utilities::valueForField("pageid", $x);
         }, array_keys($topArticlesMap))) . ") ";
         $query .= " +(is_main_page:false) ";
         $searchConfig = new Config();
         $searchConfig->setLimit(self::TOP_ARTICLES_PER_WIKI)->setQuery($query)->setPage(1)->setRequestedFields($requestedFields)->setDirectLuceneQuery(true)->setWikiId($wikiId);
         $resultSet = (new Factory())->getFromConfig($searchConfig)->search();
         $currentResults = $resultSet->toArray($requestedFields);
         $articles = [];
         foreach ($currentResults as $article) {
             $articles[$article['pageid']] = $this->processArticle($article);
             if (sizeof($articles) >= self::TOP_ARTICLES_PER_WIKI) {
                 break;
             }
         }
         $result = [];
         foreach ($topArticlesMap as $id => $a) {
             if (isset($articles[$id])) {
                 $result[] = $articles[$id];
             }
         }
         $timer->stop();
         return $result;
     });
 }
Exemple #16
0
 /**
  * @return string
  * @throws GWTAuthenticationException
  */
 private function getAuthToken()
 {
     $cacheKey = $this->mEmail;
     return WikiaDataAccess::cache($cacheKey, 60 * 60, function () {
         $content = Http::post('https://www.google.com/accounts/ClientLogin', array('postData' => array("Email" => $this->mEmail, "Passwd" => $this->mPass, "accountType" => $this->mType, "source" => $this->mSource, "service" => $this->mService)));
         if (preg_match('/Auth=(\\S+)/', $content, $matches)) {
             return $matches[1];
         } else {
             throw new GWTAuthenticationException();
         }
     });
 }
 private function getTextSnippetSource($articleId)
 {
     // Memoize to avoid Memcache access overhead when the same article needs to be processed
     // more than once in the same process
     if (array_key_exists($articleId, self::$localCache)) {
         $text = self::$localCache[$articleId];
     } else {
         $key = self::getCacheKey($articleId);
         $service = $this;
         $text = self::$localCache[$articleId] = WikiaDataAccess::cache($key, 86400, function () use($service) {
             $content = '';
             if (!$this->wg->DevelEnvironment && !empty($this->wg->SolrMaster)) {
                 $content = $service->getTextFromSolr();
             }
             if ($content === '') {
                 // back-off is to use mediawiki
                 $content = $service->getUncachedSnippetFromArticle();
             }
             return $content;
         });
     }
     return $text;
 }
 public function getWikiAdmins($wikiId, $avatarSize, $limit = null)
 {
     return WikiaDataAccess::cacheWithLock(wfsharedMemcKey('get_wiki_admins', $wikiId, $avatarSize, $limit), 3 * 60 * 60, function () use($wikiId, $avatarSize, $limit) {
         $admins = array();
         try {
             $admins = $this->getWikiAdminIds($wikiId, false, true, $limit, false);
             $checkUserCallback = function ($user) {
                 return true;
             };
             foreach ($admins as &$admin) {
                 $userInfo = $this->getUserInfo($admin, $wikiId, $avatarSize, $checkUserCallback);
                 $admin = $userInfo;
             }
         } catch (Exception $e) {
             // for devboxes
         }
         return $admins;
     });
 }
 /**
  *
  * Returns list of categories on a wiki in batches by self::LIMIT
  *
  * @requestParam Integer limit
  * @requestParam String offset
  *
  * @response categories
  * @response offset
  */
 private function getCategories()
 {
     wfProfileIn(__METHOD__);
     $limit = $this->request->getVal('limit', self::LIMIT * 2);
     $offset = $this->request->getVal('offset', '');
     $categories = WikiaDataAccess::cache(wfMemcKey(__METHOD__, $offset, $limit, self::NEW_API_VERSION), 6 * self::HOURS, function () use($limit, $offset) {
         return ApiService::call(array('action' => 'query', 'list' => 'allcategories', 'redirects' => true, 'aclimit' => $limit, 'acfrom' => $offset, 'acprop' => 'id|size', 'acmin' => 1));
     });
     $allCategories = $categories['query']['allcategories'];
     if (!empty($allCategories)) {
         $ret = [];
         foreach ($allCategories as $value) {
             if ($value['size'] - $value['files'] > 0) {
                 $ret[] = array('title' => $value['*'], 'id' => isset($value['pageid']) ? (int) $value['pageid'] : 0);
             }
         }
         $this->response->setVal('items', $ret);
         if (!empty($categories['query-continue'])) {
             $this->response->setVal('offset', $categories['query-continue']['allcategories']['acfrom']);
         }
     } else {
         wfProfileOut(__METHOD__);
         throw new NotFoundApiException('No Categories');
     }
     wfProfileOut(__METHOD__);
 }
 private function getCuratedContentData($section = null)
 {
     try {
         $data = WikiaDataAccess::cache(self::curatedContentDataMemcKey($section), WikiaResponse::CACHE_STANDARD, function () use($section) {
             $rawData = $this->sendRequest('CuratedContent', 'getList', empty($section) ? [] : ['section' => $section])->getData();
             return $this->mercuryApi->processCuratedContent($rawData);
         });
     } catch (NotFoundException $ex) {
         WikiaLogger::instance()->info('Curated content and categories are empty');
     }
     return $data;
 }
 /**
  * @desc Returns "CSS Updates" headline for selected language
  *
  * @return String | null
  */
 protected function getCssUpdateHeadline()
 {
     $lang = $this->getCssUpdateLang();
     $headline = WikiaDataAccess::cache(wfSharedMemcKey(self::MEMC_KEY, self::MEMC_KEY_HEADLINE_SUFFIX, $lang), 60 * 60 * 24, function () use($lang) {
         $headline = $this->wg->Lang->getMessageFor('special-css-community-update-headline', $lang);
         return $headline;
     });
     return $headline;
 }
 /**
  * @param $category
  * @return array|null|string
  */
 private static function getCategoryMembers($category, $limit = 5000, $offset = '', $namespaces = '', $sort = 'sortkey', $dir = 'asc')
 {
     return WikiaDataAccess::cache(self::getCacheKey($category, self::CATEGORY_CACHE_ID, [$limit, $offset, $namespaces, $dir]), self::getMetadataCacheTime(), function () use($category, $limit, $offset, $namespaces, $sort, $dir) {
         $ids = ApiService::call(array('action' => 'query', 'list' => 'categorymembers', 'cmprop' => 'ids|title', 'cmsort' => $sort, 'cmnamespace' => $namespaces, 'cmdir' => $dir, 'cmtitle' => $category, 'cmlimit' => $limit, 'cmcontinue' => $offset));
         if (!empty($ids)) {
             return array($ids['query']['categorymembers'], !empty($ids['query-continue']) ? $ids['query-continue']['categorymembers']['cmcontinue'] : null);
         } else {
             return null;
         }
     });
 }
 public function getLastMessage()
 {
     $key = wfMemcKey(__CLASS__, '-thread-lastreply-key', $this->mThreadId);
     $threadId = $this->mThreadId;
     $data = WikiaDataAccess::cache($key, 30 * 24 * 60 * 60, function () use($threadId) {
         $db = wfGetDB(DB_SLAVE);
         $row = $db->selectRow(array('comments_index'), array('max(first_rev_id) rev_id'), array('parent_comment_id' => $threadId, 'archived' => 0, 'deleted' => 0, 'removed' => 0), __METHOD__);
         return $row;
     });
     // get last post info
     $revision = Revision::newFromId($data->rev_id);
     if ($revision instanceof Revision) {
         $title = $revision->getTitle();
         $wallMessage = WallMessage::newFromId($title->getArticleId());
         if (!empty($wallMessage)) {
             $wallMessage->load();
             return $wallMessage;
         }
     }
     return null;
 }
 public function getWikisIncludedInCorporateFooterDropdown()
 {
     $wikiFactoryList = [];
     $varId = WikiFactory::getVarIdByName(self::IS_WIKI_INCLUDED_IN_CORPORATE_FOOTER_DROPDOWN_VAR_NAME);
     if (is_int($varId)) {
         $wikiFactoryList = WikiaDataAccess::cache(wfMemcKey('wikis_included_in_corporate_footer_dropdown', self::WIKIA_HOME_PAGE_HELPER_MEMC_VERSION), 24 * 60 * 60, function () use($varId) {
             $list = WikiFactory::getListOfWikisWithVar($varId, 'bool', '=', true);
             return $this->cleanWikisDataArray($list);
         }, WikiaDataAccess::REFRESH_CACHE);
     }
     return $wikiFactoryList;
 }
Exemple #25
0
 /**
  * loadVariableFromDB
  *
  * Read variable data from database in most efficient way. If you've found
  * faster version - fix this one.
  *
  * @author eloy@wikia
  * @access private
  * @static
  *
  * @param integer $cv_id        variable id in city_variables_pool
  * @param string $cv_name    variable name in city_variables_pool
  * @param integer $city_id    wiki id in city_list
  * @param boolean $master        use master or slave connection
  *
  * @return string: path to file or null if id is not a number
  */
 private static function loadVariableFromDB($cv_id, $cv_name, $city_id, $master = false)
 {
     if (!self::isUsed()) {
         Wikia::log(__METHOD__, "", "WikiFactory is not used.");
         return false;
     }
     /**
      * $wiki could be empty, but we have to know which variable read
      */
     if (!$cv_id && !$cv_name) {
         return false;
     }
     wfProfileIn(__METHOD__);
     /**
      * if both are defined cv_id has precedence
      */
     if ($cv_id) {
         $condition = ["cv_id" => $cv_id];
         $cacheKey = "id:{$cv_id}";
     } else {
         $condition = ["cv_name" => $cv_name];
         $cacheKey = "name:{$cv_name}";
     }
     $dbr = $master ? self::db(DB_MASTER) : self::db(DB_SLAVE);
     $caller = wfGetCallerClassMethod(__CLASS__);
     $fname = __METHOD__ . " (from {$caller})";
     if ($master || !isset(self::$variablesCache[$cacheKey])) {
         $oRow = WikiaDataAccess::cache(self::getVarMetadataKey($cacheKey), WikiaResponse::CACHE_STANDARD, function () use($dbr, $condition, $fname) {
             $oRow = $dbr->selectRow(["city_variables_pool"], ["cv_id", "cv_name", "cv_description", "cv_variable_type", "cv_variable_group", "cv_access_level", "cv_is_unique"], $condition, $fname);
             // log typos in calls to WikiFactory::loadVariableFromDB
             if (!is_object($oRow)) {
                 WikiaLogger::instance()->error('WikiFactory - variable not found', ['condition' => $condition, 'exception' => new Exception()]);
             }
             return $oRow;
         }, $master ? WikiaDataAccess::REFRESH_CACHE : WikiaDataAccess::USE_CACHE);
         self::$variablesCache[$cacheKey] = $oRow;
     }
     $oRow = self::$variablesCache[$cacheKey];
     if (is_object($oRow)) {
         $oRow = clone $oRow;
     }
     if (!isset($oRow->cv_id)) {
         /**
          * variable doesn't exist
          */
         wfProfileOut(__METHOD__);
         return null;
     }
     if (!empty($city_id)) {
         $oRow2 = WikiaDataAccess::cache(self::getVarValueKey($city_id, $oRow->cv_id), 3600, function () use($dbr, $oRow, $city_id, $fname) {
             return $dbr->selectRow(["city_variables"], ["cv_city_id", "cv_variable_id", "cv_value"], ["cv_variable_id" => $oRow->cv_id, "cv_city_id" => $city_id], $fname);
         });
         if (isset($oRow2->cv_variable_id)) {
             $oRow->cv_city_id = $oRow2->cv_city_id;
             $oRow->cv_variable_id = $oRow2->cv_variable_id;
             $oRow->cv_value = $oRow2->cv_value;
         } else {
             $oRow->cv_city_id = $city_id;
             $oRow->cv_variable_id = $oRow->cv_id;
             $oRow->cv_value = null;
         }
     } else {
         $oRow->cv_city_id = null;
         $oRow->cv_variable_id = $oRow->cv_id;
         $oRow->cv_value = null;
     }
     wfProfileOut(__METHOD__);
     return $oRow;
 }
 /**
  * @param User $user
  * @param $group
  * @return bool true, it's a hook
  * @throws DBUnexpectedError
  */
 static function removeGlobalGroup(User $user, $group)
 {
     global $wgWikiaGlobalUserGroups;
     if (!in_array($group, $wgWikiaGlobalUserGroups)) {
         return true;
     }
     $dbw = self::getDB(DB_MASTER);
     $dbw->delete('user_groups', ['ug_user' => $user->getID(), 'ug_group' => $group], __METHOD__);
     // Remember that the user was in this group
     $dbw->insert('user_former_groups', ['ufg_user' => $user->getID(), 'ufg_group' => $group], __METHOD__, ['IGNORE']);
     WikiaDataAccess::cachePurge(self::getMemcKey($user));
     wfRunHooks('AfterUserRemoveGlobalGroup', [$user, $group]);
     // return true to let the User class clean up any residual staff rights stored locally
     return true;
 }
 protected function getIdsBlacklistedWikis()
 {
     $blacklistIds = WikiaDataAccess::cache(wfSharedMemcKey('wam_blacklist', self::MEMCACHE_VER), self::CACHE_DURATION, function () {
         $contentWarningWikis = $excludedWikis = [];
         // Exlude wikias with ContentWarning extension enabled
         $blacklistExtVarId = WikiFactory::getVarIdByName(self::WAM_BLACKLIST_EXT_VAR_NAME);
         if ($blacklistExtVarId) {
             $contentWarningWikis = array_keys(WikiFactory::getListOfWikisWithVar($blacklistExtVarId, 'bool', '=', true));
         }
         // Exclude wikias with an exclusion flag set to true
         $blacklistFlagVarId = WikiFactory::getVarIdByName(self::WAM_EXCLUDE_FLAG_NAME);
         if ($blacklistFlagVarId) {
             $excludedWikis = array_keys(WikiFactory::getListOfWikisWithVar($blacklistFlagVarId, 'bool', '=', true));
         }
         return array_merge($contentWarningWikis, $excludedWikis);
     });
     return $blacklistIds;
 }
 /**
  * @param Array $collectionsList 2d array in example: [$collection1, $collection2, ...] where $collection1 = [$wikiId1, $wikiId2, ..., $wikiId17]
  * @param String $lang language code
  */
 public function getCollectionsWikisData(array $collectionsList)
 {
     $collectionsWikisData = [];
     $helper = $this->getWikiaHomePageHelper();
     foreach ($collectionsList as $collection => $collectionsWikis) {
         $collectionsWikisData[$collection] = WikiaDataAccess::cache($this->getCollectionCacheKey($collection), 6 * 60 * 60, function () use($collection, $collectionsWikis) {
             $wikiListConditioner = new WikiListConditionerForCollection($collectionsWikis);
             return $this->getWikisList($wikiListConditioner);
         });
     }
     $collectionsWikisData = $helper->prepareBatchesForVisualization($collectionsWikisData);
     return $collectionsWikisData;
 }
 private static function purgeCacheDependingOnCats($title, $reason = null)
 {
     $app = F::app();
     $purged = false;
     wfDebugLog(__CLASS__, __METHOD__ . 'fetching categories from MASTER');
     $categories = self::getCategoriesFromTitle($title, true);
     if (self::hasCssUpdatesCat($categories)) {
         wfDebugLog(__CLASS__, __METHOD__ . $reason);
         WikiaDataAccess::cachePurge(wfSharedMemcKey(SpecialCssModel::MEMC_KEY, $app->wg->DBname));
         $purged = true;
     }
     return $purged;
 }
 /**
  * Get last timestamp when vertical was published (before selected timestamp)
  *
  * @param int $cityId
  * @param int $timestamp - max timestamp that we should search for published hub
  *
  * @return int timestamp
  */
 public function getLastPublishedTimestamp($cityId, $timestamp = null, $useMaster = false)
 {
     if ($timestamp === null) {
         $timestamp = time();
     }
     $timestamp = strtotime(self::STRTOTIME_MIDNIGHT, $timestamp);
     if ($timestamp == strtotime(self::STRTOTIME_MIDNIGHT)) {
         $lastPublishedTimestamp = WikiaDataAccess::cache($this->getMKeyForLastPublishedTimestamp($cityId, $timestamp), 6 * 60 * 60, function () use($cityId, $timestamp, $useMaster) {
             return $this->getLastPublishedTimestampFromDB($cityId, $timestamp, $useMaster);
         });
     } else {
         $lastPublishedTimestamp = $this->getLastPublishedTimestampFromDB($cityId, $timestamp, $useMaster);
     }
     return $lastPublishedTimestamp;
 }