44 parent::__construct( $query, $moduleName,
'el' );
46 $this->urlUtils = $urlUtils;
51 if ( $pages === [] ) {
59 $protocol = LinkFilter::getProtocolPrefix(
$params[
'protocol'] );
61 $fields = [
'el_from' ];
62 $fields[] =
'el_to_domain_index';
63 $fields[] =
'el_to_path';
64 $continueField =
'el_to_domain_index';
68 $this->
addWhereFld(
'el_from', array_keys( $pages ) );
70 if ( $query !==
null && $query !==
'' ) {
72 $query = Parser::normalizeLinkUrl( $query );
74 $conds = LinkFilter::getQueryConditions( $query, [
75 'protocol' => $protocol,
76 'oneWildcard' =>
true,
84 if ( $protocol !==
null ) {
86 $db->expr( $continueField, IExpression::LIKE,
new LikeValue(
"$protocol", $db->anyString() ) )
91 $orderBy = [
'el_id' ];
98 if (
$params[
'continue'] !==
null ) {
100 array_fill( 0, count( $orderBy ),
'string' ) );
101 $conds = array_combine( $orderBy, array_map(
'rawurldecode', $cont ) );
102 $this->
addWhere( $db->buildComparison(
'>=', $conds ) );
105 $res = $this->
select( __METHOD__ );
108 foreach ( $res as $row ) {
109 if ( ++$count >
$params[
'limit'] ) {
112 $this->setContinue( $orderBy, $row );
116 $to = LinkFilter::reverseIndexes( $row->el_to_domain_index ) . $row->el_to_path;
124 $this->setContinue( $orderBy, $row );
130 private function setContinue( $orderBy, $row ) {
132 foreach ( $orderBy as $field ) {
133 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
145 ParamValidator::PARAM_DEFAULT => 10,
146 ParamValidator::PARAM_TYPE =>
'limit',
147 IntegerDef::PARAM_MIN => 1,
155 ParamValidator::PARAM_TYPE => LinkFilter::prepareProtocols(),
156 ParamValidator::PARAM_DEFAULT =>
'',
160 ParamValidator::PARAM_TYPE =>
'boolean',
161 ParamValidator::PARAM_DEFAULT =>
false,
162 ParamValidator::PARAM_DEPRECATED =>
true,
168 $title = Title::newMainPage()->getPrefixedText();
169 $mp = rawurlencode( $title );
172 "action=query&prop=extlinks&titles={$mp}"
173 =>
'apihelp-query+extlinks-example-simple',
178 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Extlinks';
183class_alias( ApiQueryExternalLinks::class,
'ApiQueryExternalLinks' );
array $params
The job parameters.