=== New features in 1.33 ===
* The 'GetPreferences' hook now receives an additional $context parameter.
+* (T96041) __EXPECT_UNUSED_CATEGORY__ on a category page causes the category
+ to be hidden on Special:UnusedCategories.
* …
=== External library changes in 1.33 ===
'newsectionlink',
'nonewsectionlink',
'hiddencat',
+ 'expectunusedcategory',
'index',
'noindex',
'staticredirect',
$pageId = $this->getTitle()->getArticleID();
$pageProps = PageProps::getInstance()->getProperties( $this->getTitle(), 'hiddencat' );
- return isset( $pageProps[$pageId] ) ? true : false;
+ return isset( $pageProps[$pageId] );
+ }
+
+ /**
+ * Checks if a category is expected to be an unused category.
+ *
+ * @since 1.33
+ *
+ * @return bool
+ */
+ public function isExpectedUnusedCategory() {
+ $pageId = $this->getTitle()->getArticleID();
+ $pageProps = PageProps::getInstance()->getProperties( $this->getTitle(), 'expectunusedcategory' );
+
+ return isset( $pageProps[$pageId] );
}
}
public function getQueryInfo() {
return [
- 'tables' => [ 'page', 'categorylinks' ],
+ 'tables' => [ 'page', 'categorylinks', 'page_props' ],
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
'conds' => [
'cl_from IS NULL',
'page_namespace' => NS_CATEGORY,
- 'page_is_redirect' => 0
+ 'page_is_redirect' => 0,
+ 'pp_page IS NULL'
],
- 'join_conds' => [ 'categorylinks' => [ 'LEFT JOIN', 'cl_to = page_title' ] ]
+ 'join_conds' => [
+ 'categorylinks' => [ 'LEFT JOIN', 'cl_to = page_title' ],
+ 'page_props' => [ 'LEFT JOIN', [
+ 'page_id = pp_page',
+ 'pp_propname' => 'expectunusedcategory'
+ ] ]
+ ]
];
}
'filepath' => [ 0, 'FILEPATH:' ],
'tag' => [ 0, 'tag' ],
'hiddencat' => [ 1, '__HIDDENCAT__' ],
+ 'expectunusedcategory' => [ 1, '__EXPECT_UNUSED_CATEGORY__', '__EXPECT_UNUSED_CAT__', '__EXPECTUNUSEDCATEGORY__', '__EXPECTUNUSEDCAT__' ],
'pagesincategory' => [ 1, 'PAGESINCATEGORY', 'PAGESINCAT' ],
'pagesize' => [ 1, 'PAGESIZE' ],
'index' => [ 1, '__INDEX__' ],
ScopedCallback::consume( $scopedOverride );
}
+
+ /**
+ * @covers WikiCategoryPage::isExpectedUnusedCategory
+ */
+ public function testExpectUnusedCategory_PropertyNotSet() {
+ $title = Title::makeTitle( NS_CATEGORY, 'CategoryPage' );
+ $categoryPage = WikiCategoryPage::factory( $title );
+
+ $pageProps = $this->getMockPageProps();
+ $pageProps->expects( $this->once() )
+ ->method( 'getProperties' )
+ ->with( $title, 'expectunusedcategory' )
+ ->will( $this->returnValue( [] ) );
+
+ $scopedOverride = PageProps::overrideInstance( $pageProps );
+
+ $this->assertFalse( $categoryPage->isExpectedUnusedCategory() );
+
+ ScopedCallback::consume( $scopedOverride );
+ }
+
+ /**
+ * @dataProvider provideCategoryContent
+ * @covers WikiCategoryPage::isExpectedUnusedCategory
+ */
+ public function testExpectUnusedCategory_PropertyIsSet( $isExpectedUnusedCategory ) {
+ $categoryTitle = Title::makeTitle( NS_CATEGORY, 'CategoryPage' );
+ $categoryPage = WikiCategoryPage::factory( $categoryTitle );
+ $returnValue = $isExpectedUnusedCategory ? [ $categoryTitle->getArticleID() => '' ] : [];
+
+ $pageProps = $this->getMockPageProps();
+ $pageProps->expects( $this->once() )
+ ->method( 'getProperties' )
+ ->with( $categoryTitle, 'expectunusedcategory' )
+ ->will( $this->returnValue( $returnValue ) );
+
+ $scopedOverride = PageProps::overrideInstance( $pageProps );
+
+ $this->assertEquals( $isExpectedUnusedCategory, $categoryPage->isExpectedUnusedCategory() );
+
+ ScopedCallback::consume( $scopedOverride );
+ }
}