Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| SpecialLogTopic | |
0.00% |
0 / 14 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| afterHeaderImported | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| afterPostImported | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| afterTopicImported | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |||
| importAborted | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Flow\Import\Postprocessor; |
| 4 | |
| 5 | use Flow\Import\IImportHeader; |
| 6 | use Flow\Import\IImportPost; |
| 7 | use Flow\Import\IImportTopic; |
| 8 | use Flow\Import\PageImportState; |
| 9 | use Flow\Import\TopicImportState; |
| 10 | use Flow\Model\PostRevision; |
| 11 | use MediaWiki\Logging\ManualLogEntry; |
| 12 | use MediaWiki\User\User; |
| 13 | |
| 14 | /** |
| 15 | * Records topic imports to Special:Log. |
| 16 | */ |
| 17 | class SpecialLogTopic implements Postprocessor { |
| 18 | /** |
| 19 | * @var bool Indicates if new posts have been seen since the last commit operation |
| 20 | */ |
| 21 | protected $newPosts = false; |
| 22 | |
| 23 | /** |
| 24 | * @var User The user to attribute logs to |
| 25 | */ |
| 26 | protected $user; |
| 27 | |
| 28 | public function __construct( User $user ) { |
| 29 | $this->user = $user; |
| 30 | } |
| 31 | |
| 32 | public function afterHeaderImported( PageImportState $state, IImportHeader $topic ) { |
| 33 | // nothing to do |
| 34 | } |
| 35 | |
| 36 | public function afterPostImported( TopicImportState $state, IImportPost $post, PostRevision $newPost ) { |
| 37 | $this->newPosts = true; |
| 38 | } |
| 39 | |
| 40 | public function afterTopicImported( TopicImportState $state, IImportTopic $topic ) { |
| 41 | if ( !$this->newPosts ) { |
| 42 | return; |
| 43 | } |
| 44 | $logEntry = new ManualLogEntry( 'import', $topic->getLogType() ); |
| 45 | $logEntry->setTarget( $state->topicWorkflow->getOwnerTitle() ); |
| 46 | $logEntry->setPerformer( $this->user ); |
| 47 | $logEntry->setParameters( [ |
| 48 | 'topic' => $state->topicWorkflow->getArticleTitle()->getPrefixedText(), |
| 49 | ] + $topic->getLogParameters() ); |
| 50 | $logEntry->insert(); |
| 51 | |
| 52 | $this->newPosts = false; |
| 53 | } |
| 54 | |
| 55 | public function importAborted() { |
| 56 | $this->newPosts = false; |
| 57 | } |
| 58 | } |