diff --git a/extension.json b/extension.json index ae8745d7..ce616c9c 100644 --- a/extension.json +++ b/extension.json @@ -14,6 +14,7 @@ "MediaWiki\\Linter\\LintError": "includes/LintError.php", "MediaWiki\\Linter\\ApiRecordLint": "includes/ApiRecordLint.php", "MediaWiki\\Linter\\ApiQueryLintErrors": "includes/ApiQueryLintErrors.php", + "MediaWiki\\Linter\\RecordLintJob": "includes/RecordLintJob.php", "MediaWiki\\Linter\\SpecialLintErrors": "includes/SpecialLintErrors.php", "MediaWiki\\Linter\\LintErrorsPager": "includes/LintErrorsPager.php" }, @@ -33,6 +34,9 @@ "SpecialPages": { "LintErrors": "MediaWiki\\Linter\\SpecialLintErrors" }, + "JobClasses": { + "RecordLintJob": "MediaWiki\\Linter\\RecordLintJob" + }, "ResourceModules": { "ext.linter.edit": { "scripts": "ext.linter.edit.js", diff --git a/includes/ApiRecordLint.php b/includes/ApiRecordLint.php index 7d48b92a..99e7fff9 100644 --- a/includes/ApiRecordLint.php +++ b/includes/ApiRecordLint.php @@ -23,6 +23,7 @@ namespace MediaWiki\Linter; use ApiBase; use FormatJson; use IPSet\IPSet; +use JobQueueGroup; use Title; /** @@ -61,15 +62,15 @@ class ApiRecordLint extends ApiBase { if ( isset( $info['templateInfo'] ) && $info['templateInfo'] ) { $info['params']['templateInfo'] = $info['templateInfo']; } - $errors[] = new LintError( - $info['type'], - $info['params'] - ); + $errors[] = $info; } - $lintDb = new Database( $title->getArticleID() ); - $result = $lintDb->setForPage( $errors ); - $this->getResult()->addValue( $this->getModuleName(), 'success', $result ); + $job = new RecordLintJob( $title, [ + 'errors' => $errors, + 'revision' => $params['revision'], + ] ); + JobQueueGroup::singleton()->push( $job ); + $this->getResult()->addValue( $this->getModuleName(), 'success', true ); } public function isInternal() { diff --git a/includes/RecordLintJob.php b/includes/RecordLintJob.php new file mode 100644 index 00000000..01e26511 --- /dev/null +++ b/includes/RecordLintJob.php @@ -0,0 +1,54 @@ +title->getLatestRevID() != $this->params['revision'] ) { + // Outdated now, let a later job handle it + return true; + } + + $errors = []; + foreach ( $this->params['errors'] as $error ) { + $errors[] = new LintError( + $error['type'], + $error['params'] + ); + } + $lintDb = new Database( $this->title->getArticleID() ); + $lintDb->setForPage( $errors ); + return true; + } + +}