Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ArticleCompileDeletionTag
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 2
90
0.00% covered (danger)
0.00%
0 / 1
 getDeletionTags
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 compile
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
72
1<?php
2
3namespace MediaWiki\Extension\PageTriage\ArticleCompile;
4
5/**
6 * Article Deletion Tag
7 */
8class ArticleCompileDeletionTag extends ArticleCompile {
9
10    /**
11     * Returns the category to deletion tag map
12     *
13     * @return array
14     */
15    public static function getDeletionTags() {
16        return [
17            'All_articles_proposed_for_deletion' => 'prod_status',
18            'BLP_articles_proposed_for_deletion' => 'blp_prod_status',
19            'Candidates_for_speedy_deletion' => 'csd_status',
20            // The next two are both treated as deletion nominations,
21            // because RfD pages are not actual redirects. See T157046.
22            'Articles_for_deletion' => 'afd_status',
23            'All_redirects_for_discussion' => 'afd_status',
24        ];
25    }
26
27    public function compile() {
28        $deletionTags = self::getDeletionTags();
29        foreach ( $this->mPageId as $pageId ) {
30            $parserOutput = $this->getParserOutputByPageId( $pageId );
31            if ( $parserOutput ) {
32                $deleted = false;
33                foreach ( $deletionTags as $category => $tag ) {
34                    if ( !isset( $this->metadata[$pageId][$tag] )
35                        || $this->metadata[$pageId][$tag] === "0"
36                    ) {
37                        $hasCategory = $parserOutput->getCategorySortKey( $category ) !== null;
38                        $this->metadata[$pageId][$tag] = $hasCategory ? '1' : '0';
39                        $deleted = $hasCategory || $deleted;
40                    }
41                }
42                $this->metadata[$pageId]['deleted'] = $deleted;
43            }
44        }
45        return true;
46    }
47
48}