Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ApiImportReporter | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| reportPage | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| getData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Copyright © 2009 Roan Kattouw <roan.kattouw@gmail.com> |
| 4 | * |
| 5 | * @license GPL-2.0-or-later |
| 6 | * @file |
| 7 | */ |
| 8 | |
| 9 | namespace MediaWiki\Api; |
| 10 | |
| 11 | use ImportReporter; |
| 12 | use MediaWiki\MediaWikiServices; |
| 13 | use MediaWiki\Page\PageIdentity; |
| 14 | use MediaWiki\Title\ForeignTitle; |
| 15 | |
| 16 | /** |
| 17 | * Import reporter for the API |
| 18 | * @ingroup API |
| 19 | */ |
| 20 | class ApiImportReporter extends ImportReporter { |
| 21 | /** @var array[] */ |
| 22 | private $mResultArr = []; |
| 23 | |
| 24 | /** |
| 25 | * @param ?PageIdentity $pageIdentity |
| 26 | * @param ForeignTitle $foreignTitle |
| 27 | * @param int $revisionCount |
| 28 | * @param int $successCount |
| 29 | * @param array $pageInfo |
| 30 | * @return void |
| 31 | */ |
| 32 | public function reportPage( ?PageIdentity $pageIdentity, $foreignTitle, $revisionCount, $successCount, $pageInfo ) { |
| 33 | // Add a result entry |
| 34 | $r = []; |
| 35 | |
| 36 | if ( $pageIdentity === null ) { |
| 37 | # Invalid or non-importable title |
| 38 | $r['title'] = $pageInfo['title']; |
| 39 | $r['invalid'] = true; |
| 40 | } else { |
| 41 | $titleFactory = MediaWikiServices::getInstance()->getTitleFactory(); |
| 42 | ApiQueryBase::addTitleInfo( $r, $titleFactory->newFromPageIdentity( $pageIdentity ) ); |
| 43 | $r['revisions'] = (int)$successCount; |
| 44 | } |
| 45 | |
| 46 | $this->mResultArr[] = $r; |
| 47 | |
| 48 | // Piggyback on the parent to do the logging |
| 49 | parent::reportPage( $pageIdentity, $foreignTitle, $revisionCount, $successCount, $pageInfo ); |
| 50 | } |
| 51 | |
| 52 | public function getData(): array { |
| 53 | return $this->mResultArr; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /** @deprecated class alias since 1.43 */ |
| 58 | class_alias( ApiImportReporter::class, 'ApiImportReporter' ); |