Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ArticleCompileRecreated | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| compile | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\PageTriage\ArticleCompile; |
| 4 | |
| 5 | /** |
| 6 | * Whether or not the page was previously deleted. |
| 7 | * FIXME: Ideally we wouldn't redundantly re-query the deletion log on every edit, |
| 8 | * but it's a lot of work to get around this, and we're querying the replica in |
| 9 | * a deferred update anyway. |
| 10 | */ |
| 11 | class ArticleCompileRecreated extends ArticleCompile { |
| 12 | |
| 13 | /** |
| 14 | * Implements ArticleCompileInterface::compile(), called when generating tags. |
| 15 | * @return bool |
| 16 | */ |
| 17 | public function compile() { |
| 18 | $conds = [ |
| 19 | 'page_id' => $this->mPageId, |
| 20 | 'log_type' => 'delete', |
| 21 | |
| 22 | // We only care about full-page deletions, not revision deletions. |
| 23 | // 'delete_redir' and 'delete_redir2' are the same as 'delete' except for |
| 24 | // redirects, which we do want. |
| 25 | 'log_action' => [ 'delete', 'delete_redir', 'delete_redir2' ], |
| 26 | ]; |
| 27 | |
| 28 | $res = $this->db->newSelectQueryBuilder() |
| 29 | ->select( [ 'DISTINCT page_id' ] ) |
| 30 | ->from( 'logging' ) |
| 31 | ->join( 'page', 'page', [ 'page_title = log_title', 'page_namespace = log_namespace' ] ) |
| 32 | ->where( $conds ) |
| 33 | ->caller( __METHOD__ ) |
| 34 | ->fetchResultSet(); |
| 35 | |
| 36 | $wasPreviouslyDeleted = []; |
| 37 | |
| 38 | foreach ( $res as $row ) { |
| 39 | $wasPreviouslyDeleted[$row->page_id] = true; |
| 40 | } |
| 41 | |
| 42 | foreach ( $this->mPageId as $pageId ) { |
| 43 | if ( array_key_exists( $pageId, $wasPreviouslyDeleted ) ) { |
| 44 | $this->metadata[$pageId]['recreated'] = true; |
| 45 | } else { |
| 46 | $this->metadata[$pageId]['recreated'] = false; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return true; |
| 51 | } |
| 52 | |
| 53 | } |