Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| LogOnlyRemediator | |
0.00% |
0 / 15 |
|
0.00% |
0 / 7 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 4 |
|
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 / 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 | use Psr\Log\LoggerInterface; |
| 8 | use Psr\Log\LogLevel; |
| 9 | |
| 10 | /** |
| 11 | * {@link Remediator} that only logs events. |
| 12 | * |
| 13 | * Intended to visualize deviations without remediating them, |
| 14 | * in case CirrusSearch is not in charge of writing. |
| 15 | * |
| 16 | * @license GPL-2.0-or-later |
| 17 | */ |
| 18 | class LogOnlyRemediator implements Remediator { |
| 19 | |
| 20 | private LoggerInterface $logger; |
| 21 | private string $level; |
| 22 | private string $prefix; |
| 23 | |
| 24 | public function __construct( LoggerInterface $logger, string $level = LogLevel::INFO ) { |
| 25 | $this->logger = $logger; |
| 26 | $this->level = $level; |
| 27 | $this->prefix = str_replace( __NAMESPACE__ . '\\', '', __CLASS__ ); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @inheritDoc |
| 32 | */ |
| 33 | public function redirectInIndex( string $docId, WikiPage $page, string $indexSuffix ) { |
| 34 | $this->logger->log( $this->level, $this->prefix . '::' . __FUNCTION__, |
| 35 | [ 'page' => $page->getId(), 'indexSuffix' => $indexSuffix, 'title' => $page->getTitle()->getPrefixedText() ] ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * @inheritDoc |
| 40 | */ |
| 41 | public function pageNotInIndex( WikiPage $page ) { |
| 42 | $this->logger->log( $this->level, $this->prefix . '::' . __FUNCTION__, |
| 43 | [ 'page' => $page->getId(), 'title' => $page->getTitle()->getPrefixedText() ] ); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @inheritDoc |
| 48 | */ |
| 49 | public function ghostPageInIndex( $docId, Title $title ) { |
| 50 | $this->logger->log( $this->level, $this->prefix . '::' . __FUNCTION__, |
| 51 | [ 'doc' => $docId, 'title' => $title->getPrefixedText() ] ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @inheritDoc |
| 56 | */ |
| 57 | public function pageInWrongIndex( $docId, WikiPage $page, $indexSuffix ) { |
| 58 | $this->logger->log( $this->level, $this->prefix . '::' . __FUNCTION__, |
| 59 | [ 'doc' => $docId, 'page' => $page->getId(), 'title' => $page->getTitle()->getPrefixedText(), 'indexSuffix' => $indexSuffix ] ); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * @inheritDoc |
| 64 | */ |
| 65 | public function oldVersionInIndex( $docId, WikiPage $page, $indexSuffix ) { |
| 66 | $this->logger->log( $this->level, $this->prefix . '::' . __FUNCTION__, |
| 67 | [ 'doc' => $docId, 'page' => $page->getId(), 'title' => $page->getTitle()->getPrefixedText(), 'indexSuffix' => $indexSuffix ] ); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @inheritDoc |
| 72 | */ |
| 73 | public function oldDocument( WikiPage $page ) { |
| 74 | // do not log, see https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CirrusSearch/+/991599/comments/33ecb273_74895cf2 |
| 75 | } |
| 76 | |
| 77 | } |