Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| LocalJobSubmitJob | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| run | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation, either version 3 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | namespace MediaWiki\GlobalUserPage; |
| 18 | |
| 19 | use LogicException; |
| 20 | use MediaWiki\JobQueue\Job; |
| 21 | use MediaWiki\JobQueue\JobQueueGroupFactory; |
| 22 | use MediaWiki\JobQueue\JobSpecification; |
| 23 | use MediaWiki\User\CentralId\CentralIdLookup; |
| 24 | |
| 25 | /** |
| 26 | * Job class that submits LocalCacheUpdateJob jobs |
| 27 | */ |
| 28 | class LocalJobSubmitJob extends Job { |
| 29 | public function __construct( |
| 30 | array $params, |
| 31 | private readonly CentralIdLookup $centralIdLookup, |
| 32 | private readonly JobQueueGroupFactory $jobQueueGroupFactory, |
| 33 | private readonly GlobalUserPageManager $globalUserPageManager, |
| 34 | ) { |
| 35 | parent::__construct( 'GlobalUserPageLocalJobSubmitJob', $params ); |
| 36 | } |
| 37 | |
| 38 | /** @inheritDoc */ |
| 39 | public function run() { |
| 40 | $job = new JobSpecification( 'LocalGlobalUserPageCacheUpdateJob', $this->params ); |
| 41 | $wikis = $this->globalUserPageManager->getEnabledWikis(); |
| 42 | $user = $this->globalUserPageManager->getUserIdentity( $this->params['username'] ); |
| 43 | if ( $user === null ) { |
| 44 | throw new LogicException( 'User instance could not be created for ' . $this->params['username'] ); |
| 45 | } |
| 46 | foreach ( $wikis as $wiki ) { |
| 47 | if ( $this->centralIdLookup->isAttached( $user, $wiki ) ) { |
| 48 | $this->jobQueueGroupFactory->makeJobQueueGroup( $wiki )->push( $job ); |
| 49 | } |
| 50 | } |
| 51 | return true; |
| 52 | } |
| 53 | } |