aboutsummaryrefslogtreecommitdiffstats
path: root/includes/jobqueue/Job.php
diff options
context:
space:
mode:
authorPetr Pchelko <ppchelko@wikimedia.org>2021-05-13 16:54:44 -0700
committerPetr Pchelko <ppchelko@wikimedia.org>2021-06-07 09:52:46 -0700
commita747229116f0cac120537fa2ce5c9f3ae92f2f46 (patch)
treec7e593701e98fe850e674adf211cde289dde9cc6 /includes/jobqueue/Job.php
parent5bc6425976414b17ecffe92dad4385dbf3802121 (diff)
downloadmediawikicore-a747229116f0cac120537fa2ce5c9f3ae92f2f46.tar.gz
mediawikicore-a747229116f0cac120537fa2ce5c9f3ae92f2f46.zip
Remove Title param typehints from jobs
Change-Id: I8d8407d704eac97d4b0574369e315e28e23a89a8
Diffstat (limited to 'includes/jobqueue/Job.php')
-rw-r--r--includes/jobqueue/Job.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/includes/jobqueue/Job.php b/includes/jobqueue/Job.php
index b049a847c8e8..108016288e7e 100644
--- a/includes/jobqueue/Job.php
+++ b/includes/jobqueue/Job.php
@@ -21,6 +21,8 @@
* @defgroup JobQueue JobQueue
*/
+use MediaWiki\Page\PageReference;
+
/**
* Class to both describe a background job and handle jobs.
* To push jobs onto queues, use JobQueueGroup::singleton()->push();
@@ -61,16 +63,16 @@ abstract class Job implements RunnableJob {
* Create the appropriate object to handle a specific job
*
* @param string $command Job command
- * @param array|Title $params Job parameters
+ * @param array|PageReference $params Job parameters
* @throws InvalidArgumentException
* @return Job
*/
public static function factory( $command, $params = [] ) {
global $wgJobClasses;
- if ( $params instanceof Title ) {
+ if ( $params instanceof PageReference ) {
// Backwards compatibility for old signature ($command, $title, $params)
- $title = $params;
+ $title = Title::castFromPageReference( $params );
$params = func_num_args() >= 3 ? func_get_arg( 2 ) : [];
} elseif ( isset( $params['namespace'] ) && isset( $params['title'] ) ) {
// Handle job classes that take title as constructor parameter.
@@ -118,16 +120,16 @@ abstract class Job implements RunnableJob {
* @stable to call
*
* @param string $command
- * @param array|Title|null $params
+ * @param array|PageReference|null $params
*/
public function __construct( $command, $params = null ) {
- if ( $params instanceof Title ) {
+ if ( $params instanceof PageReference ) {
// Backwards compatibility for old signature ($command, $title, $params)
- $title = $params;
+ $page = $params;
$params = func_num_args() >= 3 ? func_get_arg( 2 ) : [];
} else {
// Newer jobs may choose to not have a top-level title (e.g. GenericParameterJob)
- $title = null;
+ $page = null;
}
if ( !is_array( $params ) ) {
@@ -135,14 +137,14 @@ abstract class Job implements RunnableJob {
}
if (
- $title &&
+ $page &&
!isset( $params['namespace'] ) &&
!isset( $params['title'] )
) {
// When constructing this class for submitting to the queue,
- // normalise the $title arg of old job classes as part of $params.
- $params['namespace'] = $title->getNamespace();
- $params['title'] = $title->getDBkey();
+ // normalise the $page arg of old job classes as part of $params.
+ $params['namespace'] = $page->getNamespace();
+ $params['title'] = $page->getDBkey();
}
$this->command = $command;