MediaWiki master
WikiCategoryPage.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Page;
8
12
17
25 public function hasViewableContent() {
26 if ( parent::hasViewableContent() ) {
27 return true;
28 } else {
29 $cat = Category::newFromTitle( $this->mTitle );
30 // If any of these are not 0, then has members
31 if ( $cat->getMemberCount()
32 || $cat->getSubcatCount()
33 || $cat->getFileCount()
34 ) {
35 return true;
36 }
37 }
38 return false;
39 }
40
47 public function isHidden() {
48 $pageId = $this->getTitle()->getArticleID();
50 ->getPageProps()
51 ->getProperties( $this->getTitle(), 'hiddencat' );
52
53 return isset( $pageProps[$pageId] );
54 }
55
62 public function isExpectedUnusedCategory() {
63 $pageId = $this->getTitle()->getArticleID();
65 ->getPageProps()
66 ->getProperties( $this->getTitle(), 'expectunusedcategory' );
67
68 return isset( $pageProps[$pageId] );
69 }
70
76 public function doPurge() {
77 if ( !parent::doPurge() ) {
78 // Aborted by hook most likely
79 return false;
80 }
81
82 $title = $this->mTitle;
83 DeferredUpdates::addCallableUpdate(
84 static function () use ( $title ) {
85 $cat = Category::newFromTitle( $title );
86 // If the category has less than 5000 pages, refresh the counts.
87 // 5000 was chosen based on the discussion at T85696.
88 $cat->refreshCountsIfSmall( 5000 );
89 },
90 // Explicitly PRESEND so that counts are correct before we try to
91 // re-render the page on the next load so {{PAGESINCAT:...}} will
92 // be using the correct new values, not the old ones.
93 DeferredUpdates::PRESEND
94 );
95
96 return true;
97 }
98}
99
101class_alias( WikiCategoryPage::class, 'WikiCategoryPage' );
Category objects are immutable, strictly speaking.
Definition Category.php:28
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:81
getTitle()
Get the title object of the article.
Definition WikiPage.php:249