MediaWiki master
WikiCategoryPage.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Page;
22
26
31
39 public function hasViewableContent() {
40 if ( parent::hasViewableContent() ) {
41 return true;
42 } else {
43 $cat = Category::newFromTitle( $this->mTitle );
44 // If any of these are not 0, then has members
45 if ( $cat->getMemberCount()
46 || $cat->getSubcatCount()
47 || $cat->getFileCount()
48 ) {
49 return true;
50 }
51 }
52 return false;
53 }
54
61 public function isHidden() {
62 $pageId = $this->getTitle()->getArticleID();
64 ->getPageProps()
65 ->getProperties( $this->getTitle(), 'hiddencat' );
66
67 return isset( $pageProps[$pageId] );
68 }
69
76 public function isExpectedUnusedCategory() {
77 $pageId = $this->getTitle()->getArticleID();
79 ->getPageProps()
80 ->getProperties( $this->getTitle(), 'expectunusedcategory' );
81
82 return isset( $pageProps[$pageId] );
83 }
84
90 public function doPurge() {
91 if ( !parent::doPurge() ) {
92 // Aborted by hook most likely
93 return false;
94 }
95
96 $title = $this->mTitle;
97 DeferredUpdates::addCallableUpdate(
98 static function () use ( $title ) {
99 $cat = Category::newFromTitle( $title );
100 // If the category has less than 5000 pages, refresh the counts.
101 // 5000 was chosen based on the discussion at T85696.
102 $cat->refreshCountsIfSmall( 5000 );
103 },
104 // Explicitly PRESEND so that counts are correct before we try to
105 // re-render the page on the next load so {{PAGESINCAT:...}} will
106 // be using the correct new values, not the old ones.
107 DeferredUpdates::PRESEND
108 );
109
110 return true;
111 }
112}
113
115class_alias( WikiCategoryPage::class, 'WikiCategoryPage' );
Category objects are immutable, strictly speaking.
Definition Category.php:44
Defer callable updates to run later in the PHP process.
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Special handling for representing category pages.
hasViewableContent()
Don't return a 404 for categories in use.
doPurge()
Update category counts on purge (T85696)
isHidden()
Checks if a category is hidden.
isExpectedUnusedCategory()
Checks if a category is expected to be an unused category.
Base representation for an editable wiki page.
Definition WikiPage.php:92
getTitle()
Get the title object of the article.
Definition WikiPage.php:260