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