Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| PageRevisionedObject | |
0.00% |
0 / 15 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getRevisionData | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
| getRevisions | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Flow\Import\LiquidThreadsApi; |
| 4 | |
| 5 | use Flow\Import\IRevisionableObject; |
| 6 | |
| 7 | abstract class PageRevisionedObject implements IRevisionableObject { |
| 8 | /** @var int */ |
| 9 | protected $pageId; |
| 10 | |
| 11 | /** |
| 12 | * @var ImportSource |
| 13 | */ |
| 14 | protected $importSource; |
| 15 | |
| 16 | /** |
| 17 | * @param ImportSource $source |
| 18 | * @param int $pageId ID of the remote page |
| 19 | */ |
| 20 | public function __construct( $source, $pageId ) { |
| 21 | $this->importSource = $source; |
| 22 | $this->pageId = $pageId; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Gets the raw revisions, after filtering but before being converted to |
| 27 | * ImportRevision. |
| 28 | * |
| 29 | * @return array Page data with filtered revisions |
| 30 | */ |
| 31 | protected function getRevisionData() { |
| 32 | $pageData = $this->importSource->getPageData( $this->pageId ); |
| 33 | // filter revisions without content (deleted) |
| 34 | foreach ( $pageData['revisions'] as $key => $value ) { |
| 35 | if ( isset( $value['texthidden'] ) ) { |
| 36 | unset( $pageData['revisions'][$key] ); |
| 37 | } |
| 38 | if ( $value['user'] == 'Flow talk page manager' ) { |
| 39 | // Ignore revs by Flow talk page manager (caused by screwups in earlier imports) |
| 40 | unset( $pageData['revisions'][$key] ); |
| 41 | } |
| 42 | } |
| 43 | // the iterators expect this to be a 0 indexed list |
| 44 | $pageData['revisions'] = array_values( $pageData['revisions'] ); |
| 45 | return $pageData; |
| 46 | } |
| 47 | |
| 48 | public function getRevisions() { |
| 49 | $pageData = $this->getRevisionData(); |
| 50 | $scriptUser = $this->importSource->getScriptUser(); |
| 51 | return new RevisionIterator( $pageData, $this, static function ( $data, $parent ) use ( $scriptUser ) { |
| 52 | return new ImportRevision( $data, $parent, $scriptUser ); |
| 53 | } ); |
| 54 | } |
| 55 | } |