Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
GraphJob | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
getLog | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getUser | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\MathSearch\Graph\Job; |
4 | |
5 | use GenericParameterJob; |
6 | use Job; |
7 | use MediaWiki\Auth\AuthManager; |
8 | use MediaWiki\Logger\LoggerFactory; |
9 | use MediaWiki\MediaWikiServices; |
10 | use MediaWiki\User\User; |
11 | use Psr\Log\LoggerInterface; |
12 | |
13 | abstract class GraphJob extends Job implements GenericParameterJob { |
14 | |
15 | /** @var User */ |
16 | private $user; |
17 | |
18 | protected static function getLog(): LoggerInterface { |
19 | return LoggerFactory::getInstance( 'MathSearch' ); |
20 | } |
21 | |
22 | public function getUser() { |
23 | if ( !$this->user ) { |
24 | $user = MediaWikiServices::getInstance()->getUserFactory() |
25 | ->newFromName( $this->params['jobname'] ); |
26 | $exists = ( $user->idForName() !== 0 ); |
27 | if ( !$exists ) { |
28 | MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser( |
29 | $user, |
30 | AuthManager::AUTOCREATE_SOURCE_MAINT, |
31 | false |
32 | ); |
33 | } |
34 | $this->user = $user; |
35 | } |
36 | return $this->user; |
37 | } |
38 | } |