Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| PrintingRemediator | |
0.00% |
0 / 14 |
|
0.00% |
0 / 8 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| redirectInIndex | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| pageNotInIndex | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| ghostPageInIndex | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| pageInWrongIndex | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| oldVersionInIndex | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| oldDocument | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| log | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace CirrusSearch\Sanity; |
| 4 | |
| 5 | use MediaWiki\Page\WikiPage; |
| 6 | use MediaWiki\Title\Title; |
| 7 | |
| 8 | /** |
| 9 | * Decorating Remediator that logs the prints the errors. |
| 10 | */ |
| 11 | class PrintingRemediator implements Remediator { |
| 12 | private Remediator $next; |
| 13 | |
| 14 | /** |
| 15 | * Build the remediator. |
| 16 | * @param Remediator $next the remediator that this one decorates |
| 17 | */ |
| 18 | public function __construct( Remediator $next ) { |
| 19 | $this->next = $next; |
| 20 | } |
| 21 | |
| 22 | public function redirectInIndex( string $docId, WikiPage $page, string $indexSuffix ) { |
| 23 | $this->log( $page->getId(), $page->getTitle(), "Redirect in index: $indexSuffix" ); |
| 24 | $this->next->redirectInIndex( $docId, $page, $indexSuffix ); |
| 25 | } |
| 26 | |
| 27 | public function pageNotInIndex( WikiPage $page ) { |
| 28 | $this->log( $page->getId(), $page->getTitle(), 'Page not in index' ); |
| 29 | $this->next->pageNotInIndex( $page ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @param string $docId |
| 34 | * @param Title $title |
| 35 | */ |
| 36 | public function ghostPageInIndex( $docId, Title $title ) { |
| 37 | $this->log( $docId, $title, 'Deleted page in index' ); |
| 38 | $this->next->ghostPageInIndex( $docId, $title ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @param string $docId |
| 43 | * @param WikiPage $page |
| 44 | * @param string $indexSuffix |
| 45 | */ |
| 46 | public function pageInWrongIndex( $docId, WikiPage $page, $indexSuffix ) { |
| 47 | $this->log( $page->getId(), $page->getTitle(), "Page in wrong index: $indexSuffix" ); |
| 48 | $this->next->pageInWrongIndex( $docId, $page, $indexSuffix ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @param string $docId elasticsearch document id |
| 53 | * @param WikiPage $page page with outdated document in index |
| 54 | * @param string $indexSuffix index contgaining outdated document |
| 55 | */ |
| 56 | public function oldVersionInIndex( $docId, WikiPage $page, $indexSuffix ) { |
| 57 | $this->log( $page->getId(), $page->getTitle(), "Outdated page in index: $indexSuffix" ); |
| 58 | $this->next->oldVersionInIndex( $docId, $page, $indexSuffix ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @param WikiPage $page Page considered too old in index |
| 63 | */ |
| 64 | public function oldDocument( WikiPage $page ) { |
| 65 | $this->log( $page->getId(), $page->getTitle(), "Old page in index" ); |
| 66 | $this->next->oldDocument( $page ); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * @param int|string $pageOrDocId |
| 71 | * @param Title $title |
| 72 | * @param string $message |
| 73 | */ |
| 74 | private function log( $pageOrDocId, $title, $message ) { |
| 75 | printf( "%30s %10d %s\n", $message, $pageOrDocId, $title ); |
| 76 | } |
| 77 | } |