/**
  * @dataProvider provideCategoryContent
  * @covers WikiCategoryPage::isHidden
  */
 public function testHiddenCategory_PropertyIsSet($isHidden)
 {
     $categoryTitle = Title::makeTitle(NS_CATEGORY, 'CategoryPage');
     $categoryPage = WikiCategoryPage::factory($categoryTitle);
     $pageProps = $this->getMockPageProps();
     $pageProps->expects($this->once())->method('getProperties')->with($categoryTitle, 'hiddencat')->will($this->returnValue($isHidden ? [$categoryTitle->getArticleID() => ''] : []));
     $scopedOverride = PageProps::overrideInstance($pageProps);
     $this->assertEquals($isHidden, $categoryPage->isHidden());
     ScopedCallback::consume($scopedOverride);
 }
Exemple #2
0
 function view()
 {
     $request = $this->getContext()->getRequest();
     $diff = $request->getVal('diff');
     $diffOnly = $request->getBool('diffonly', $this->getContext()->getUser()->getOption('diffonly'));
     if ($diff !== null && $diffOnly) {
         parent::view();
         return;
     }
     if (!Hooks::run('CategoryPageView', [&$this])) {
         return;
     }
     $title = $this->getTitle();
     if ($title->inNamespace(NS_CATEGORY)) {
         $this->openShowCategory();
     }
     parent::view();
     if ($title->inNamespace(NS_CATEGORY)) {
         $this->closeShowCategory();
     }
     # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often
     $outputPage = $this->getContext()->getOutput();
     $outputPage->adaptCdnTTL($this->mPage->getTouched(), IExpiringStore::TTL_MINUTE);
 }
 /**
  * Constructs a RecentChange object for the given categorization
  * This does not call save() on the object and thus does not write to the db
  *
  * @since 1.27
  *
  * @param string $timestamp Timestamp of the recent change to occur
  * @param Title $categoryTitle Title of the category a page is being added to or removed from
  * @param User $user User object of the user that made the change
  * @param string $comment Change summary
  * @param Title $pageTitle Title of the page that is being added or removed
  * @param int $oldRevId Parent revision ID of this change
  * @param int $newRevId Revision ID of this change
  * @param string $lastTimestamp Parent revision timestamp of this change
  * @param bool $bot true, if the change was made by a bot
  * @param string $ip IP address of the user, if the change was made anonymously
  * @param int $deleted Indicates whether the change has been deleted
  *
  * @return RecentChange
  */
 public static function newForCategorization($timestamp, Title $categoryTitle, User $user = null, $comment, Title $pageTitle, $oldRevId, $newRevId, $lastTimestamp, $bot, $ip = '', $deleted = 0)
 {
     $rc = new RecentChange();
     $rc->mTitle = $categoryTitle;
     $rc->mPerformer = $user;
     $rc->mAttribs = ['rc_timestamp' => $timestamp, 'rc_namespace' => $categoryTitle->getNamespace(), 'rc_title' => $categoryTitle->getDBkey(), 'rc_type' => RC_CATEGORIZE, 'rc_source' => self::SRC_CATEGORIZE, 'rc_minor' => 0, 'rc_cur_id' => $pageTitle->getArticleID(), 'rc_user' => $user ? $user->getId() : 0, 'rc_user_text' => $user ? $user->getName() : '', 'rc_comment' => $comment, 'rc_this_oldid' => $newRevId, 'rc_last_oldid' => $oldRevId, 'rc_bot' => $bot ? 1 : 0, 'rc_ip' => self::checkIPAddress($ip), 'rc_patrolled' => 1, 'rc_new' => 0, 'rc_old_len' => null, 'rc_new_len' => null, 'rc_deleted' => $deleted, 'rc_logid' => 0, 'rc_log_type' => null, 'rc_log_action' => '', 'rc_params' => serialize(['hidden-cat' => WikiCategoryPage::factory($categoryTitle)->isHidden()])];
     $rc->mExtra = ['prefixedDBkey' => $categoryTitle->getPrefixedDBkey(), 'lastTimestamp' => $lastTimestamp, 'oldSize' => 0, 'newSize' => 0, 'pageStatus' => 'changed'];
     return $rc;
 }