match( $this->getRequest()->getIP() ) ) { $this->dieUsage( 'Your IP address has not been whitelisted to report lint errors', 'invalid-ip' ); } $params = $this->extractRequestParams(); $data = FormatJson::decode( $params['data'], true ); if ( !is_array( $data ) ) { $this->dieUsage( 'Invalid data', 'invalid-data' ); } $errors = []; $title = Title::newFromText( $params['page'] ); if ( !$title || !$title->getArticleID() || $title->getLatestRevID() != $params['revision'] ) { $this->dieUsage( 'Invalid, non-existent, or outdated title', 'invalid-title' ); } $categoryMgr = new CategoryManager(); foreach ( $data as $info ) { if ( !$categoryMgr->isKnownCategory( $info['type'] ) ) { continue; } if ( !isset( $info['dsr'] ) ) { LoggerFactory::getInstance( 'Linter' )->warning( 'dsr for {page} @ rev {revid}, for lint: {lint} is missing', [ 'page' => $params['page'], 'revid' => $params['revision'], 'lint' => $info['type'], ] ); continue; } $info['location'] = array_slice( $info['dsr'], 0, 2 ); if ( isset( $info['templateInfo'] ) && $info['templateInfo'] ) { $info['params']['templateInfo'] = $info['templateInfo']; } $errors[] = $info; } $job = new RecordLintJob( $title, [ 'errors' => $errors, 'revision' => $params['revision'], ] ); JobQueueGroup::singleton()->push( $job ); $this->getResult()->addValue( $this->getModuleName(), 'success', true ); } public function isInternal() { return true; } public function getAllowedParams() { return [ 'data' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, ], 'page' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, ], 'revision' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_REQUIRED => true, ], ]; } }