Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4145354
NullJob.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
NullJob.php
View Options
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
use
MediaWiki\MediaWikiServices
;
/**
* No-op job that does nothing.
*
* This is used for testing purposes, e.g. to measure overall system
* performance of the JobQueue system, lock contention, etc.
*
* This job can optionally recursively re-queue itself a number of times
* or spend a fixed amount of time idling in execution time.
*
* @par Example:
* Inserting a null job in the configured job queue:
* @code
* $ php maintenance/eval.php
* > $queue = MediaWikiServices::getInstance()->getJobQueueGroup();
* > $job = new NullJob( [ 'lives' => 10 ] );
* > $queue->push( $job );
* @endcode
*
* You can confirm the job has been enqueued via maintenance/showJobs.php:
*
* @code
* $ php maintenance/showJobs.php --group
* null: 1 queue; 0 claimed (0 active, 0 abandoned)
* @endcode
*
* @ingroup JobQueue
*/
class
NullJob
extends
Job
implements
GenericParameterJob
{
/**
* @param array $params Job parameters (lives, usleep)
*/
public
function
__construct
(
array
$params
)
{
parent
::
__construct
(
'null'
,
$params
);
if
(
!
isset
(
$this
->
params
[
'lives'
]
)
)
{
$this
->
params
[
'lives'
]
=
1
;
}
if
(
!
isset
(
$this
->
params
[
'usleep'
]
)
)
{
$this
->
params
[
'usleep'
]
=
0
;
}
$this
->
removeDuplicates
=
!
empty
(
$this
->
params
[
'removeDuplicates'
]
);
}
public
function
run
()
{
if
(
$this
->
params
[
'usleep'
]
>
0
)
{
usleep
(
$this
->
params
[
'usleep'
]
);
}
if
(
$this
->
params
[
'lives'
]
>
1
)
{
$params
=
$this
->
params
;
$params
[
'lives'
]--;
$job
=
new
self
(
$params
);
MediaWikiServices
::
getInstance
()->
getJobQueueGroup
()->
push
(
$job
);
}
return
true
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 17:36 (5 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6f/be/7afd8620dfabf5a4ed60d9a0fb24
Default Alt Text
NullJob.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment