MediaWiki  master
WikiCategoryPage.php
Go to the documentation of this file.
1 <?php
22 
26 class WikiCategoryPage extends WikiPage {
27 
35  public function hasViewableContent() {
36  if ( parent::hasViewableContent() ) {
37  return true;
38  } else {
39  $cat = Category::newFromTitle( $this->mTitle );
40  // If any of these are not 0, then has members
41  if ( $cat->getMemberCount()
42  || $cat->getSubcatCount()
43  || $cat->getFileCount()
44  ) {
45  return true;
46  }
47  }
48  return false;
49  }
50 
57  public function isHidden() {
58  $pageId = $this->getTitle()->getArticleID();
59  $pageProps = MediaWikiServices::getInstance()
60  ->getPageProps()
61  ->getProperties( $this->getTitle(), 'hiddencat' );
62 
63  return isset( $pageProps[$pageId] );
64  }
65 
72  public function isExpectedUnusedCategory() {
73  $pageId = $this->getTitle()->getArticleID();
74  $pageProps = MediaWikiServices::getInstance()
75  ->getPageProps()
76  ->getProperties( $this->getTitle(), 'expectunusedcategory' );
77 
78  return isset( $pageProps[$pageId] );
79  }
80 
86  public function doPurge() {
87  if ( !parent::doPurge() ) {
88  // Aborted by hook most likely
89  return false;
90  }
91 
94  static function () use ( $title ) {
96  // If the category has less than 5000 pages, refresh the counts.
97  // 5000 was chosen based on the discussion at T85696.
98  $cat->refreshCountsIfSmall( 5000 );
99  },
100  // Explicitly PRESEND so that counts are correct before we try to
101  // re-render the page on the next load so {{PAGESINCAT:...}} will
102  // be using the correct new values, not the old ones.
103  DeferredUpdates::PRESEND
104  );
105 
106  return true;
107  }
108 }
static newFromTitle(PageIdentity $page)
Factory function.
Definition: Category.php:169
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add an update to the pending update queue that invokes the specified callback when run.
Service locator for MediaWiki core services.
Special handling for representing category pages.
isHidden()
Checks if a category is hidden.
isExpectedUnusedCategory()
Checks if a category is expected to be an unused category.
doPurge()
Update category counts on purge (T85696)
hasViewableContent()
Don't return a 404 for categories in use.
Base representation for an editable wiki page.
Definition: WikiPage.php:70
Title $mTitle
Definition: WikiPage.php:81
getTitle()
Get the title object of the article.
Definition: WikiPage.php:311