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\Title\Title; |
6 | use Psr\Log\LoggerInterface; |
7 | use Psr\Log\LogLevel; |
8 | use WikiPage; |
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 | * This program is free software; you can redistribute it and/or modify |
17 | * it under the terms of the GNU General Public License as published by |
18 | * the Free Software Foundation; either version 2 of the License, or |
19 | * (at your option) any later version. |
20 | * |
21 | * This program is distributed in the hope that it will be useful, |
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24 | * GNU General Public License for more details. |
25 | * |
26 | * You should have received a copy of the GNU General Public License along |
27 | * with this program; if not, write to the Free Software Foundation, Inc., |
28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
29 | * http://www.gnu.org/copyleft/gpl.html |
30 | */ |
31 | class LogOnlyRemediator implements Remediator { |
32 | |
33 | private LoggerInterface $logger; |
34 | private string $level; |
35 | private string $prefix; |
36 | |
37 | public function __construct( LoggerInterface $logger, string $level = LogLevel::INFO ) { |
38 | $this->logger = $logger; |
39 | $this->level = $level; |
40 | $this->prefix = str_replace( __NAMESPACE__ . '\\', '', __CLASS__ ); |
41 | } |
42 | |
43 | /** |
44 | * @inheritDoc |
45 | */ |
46 | public function redirectInIndex( string $docId, WikiPage $page, string $indexSuffix ) { |
47 | $this->logger->log( $this->level, $this->prefix . '::' . __FUNCTION__, |
48 | [ 'page' => $page->getId(), 'indexSuffix' => $indexSuffix, 'title' => $page->getTitle()->getPrefixedText() ] ); |
49 | } |
50 | |
51 | /** |
52 | * @inheritDoc |
53 | */ |
54 | public function pageNotInIndex( WikiPage $page ) { |
55 | $this->logger->log( $this->level, $this->prefix . '::' . __FUNCTION__, |
56 | [ 'page' => $page->getId(), 'title' => $page->getTitle()->getPrefixedText() ] ); |
57 | } |
58 | |
59 | /** |
60 | * @inheritDoc |
61 | */ |
62 | public function ghostPageInIndex( $docId, Title $title ) { |
63 | $this->logger->log( $this->level, $this->prefix . '::' . __FUNCTION__, |
64 | [ 'doc' => $docId, 'title' => $title->getPrefixedText() ] ); |
65 | } |
66 | |
67 | /** |
68 | * @inheritDoc |
69 | */ |
70 | public function pageInWrongIndex( $docId, WikiPage $page, $indexSuffix ) { |
71 | $this->logger->log( $this->level, $this->prefix . '::' . __FUNCTION__, |
72 | [ 'doc' => $docId, 'page' => $page->getId(), 'title' => $page->getTitle()->getPrefixedText(), 'indexSuffix' => $indexSuffix ] ); |
73 | } |
74 | |
75 | /** |
76 | * @inheritDoc |
77 | */ |
78 | public function oldVersionInIndex( $docId, WikiPage $page, $indexSuffix ) { |
79 | $this->logger->log( $this->level, $this->prefix . '::' . __FUNCTION__, |
80 | [ 'doc' => $docId, 'page' => $page->getId(), 'title' => $page->getTitle()->getPrefixedText(), 'indexSuffix' => $indexSuffix ] ); |
81 | } |
82 | |
83 | /** |
84 | * @inheritDoc |
85 | */ |
86 | public function oldDocument( WikiPage $page ) { |
87 | // do not log, see https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CirrusSearch/+/991599/comments/33ecb273_74895cf2 |
88 | } |
89 | |
90 | } |