Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
GraphJob
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 getLog
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUser
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace MediaWiki\Extension\MathSearch\Graph\Job;
4
5use GenericParameterJob;
6use Job;
7use MediaWiki\Auth\AuthManager;
8use MediaWiki\Logger\LoggerFactory;
9use MediaWiki\MediaWikiServices;
10use MediaWiki\User\User;
11use Psr\Log\LoggerInterface;
12
13abstract 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}