MediaWiki master
WikiCategoryPage.php
Go to the documentation of this file.
1<?php
24
29
37 public function hasViewableContent() {
38 if ( parent::hasViewableContent() ) {
39 return true;
40 } else {
41 $cat = Category::newFromTitle( $this->mTitle );
42 // If any of these are not 0, then has members
43 if ( $cat->getMemberCount()
44 || $cat->getSubcatCount()
45 || $cat->getFileCount()
46 ) {
47 return true;
48 }
49 }
50 return false;
51 }
52
59 public function isHidden() {
60 $pageId = $this->getTitle()->getArticleID();
61 $pageProps = MediaWikiServices::getInstance()
62 ->getPageProps()
63 ->getProperties( $this->getTitle(), 'hiddencat' );
64
65 return isset( $pageProps[$pageId] );
66 }
67
74 public function isExpectedUnusedCategory() {
75 $pageId = $this->getTitle()->getArticleID();
76 $pageProps = MediaWikiServices::getInstance()
77 ->getPageProps()
78 ->getProperties( $this->getTitle(), 'expectunusedcategory' );
79
80 return isset( $pageProps[$pageId] );
81 }
82
88 public function doPurge() {
89 if ( !parent::doPurge() ) {
90 // Aborted by hook most likely
91 return false;
92 }
93
94 $title = $this->mTitle;
95 DeferredUpdates::addCallableUpdate(
96 static function () use ( $title ) {
97 $cat = Category::newFromTitle( $title );
98 // If the category has less than 5000 pages, refresh the counts.
99 // 5000 was chosen based on the discussion at T85696.
100 $cat->refreshCountsIfSmall( 5000 );
101 },
102 // Explicitly PRESEND so that counts are correct before we try to
103 // re-render the page on the next load so {{PAGESINCAT:...}} will
104 // be using the correct new values, not the old ones.
105 DeferredUpdates::PRESEND
106 );
107
108 return true;
109 }
110}
Title null $mTitle
Category objects are immutable, strictly speaking.
Definition Category.php:42
Defer callable updates to run later in the PHP process.
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:79