33 parent::__construct( $query, $moduleName,
'el' );
38 if ( $pages === [] ) {
45 $query = $params[
'query'];
46 $protocol = LinkFilter::getProtocolPrefix( $params[
'protocol'] );
48 $fields = [
'el_from' ];
49 $fields[] =
'el_to_domain_index';
50 $fields[] =
'el_to_path';
51 $continueField =
'el_to_domain_index';
55 $this->
addWhereFld(
'el_from', array_keys( $pages ) );
57 if ( $query !==
null && $query !==
'' ) {
59 $query = Parser::normalizeLinkUrl( $query );
61 $conds = LinkFilter::getQueryConditions( $query, [
62 'protocol' => $protocol,
63 'oneWildcard' =>
true,
71 if ( $protocol !==
null ) {
73 $db->expr( $continueField, IExpression::LIKE,
new LikeValue(
"$protocol", $db->anyString() ) )
78 $orderBy = [
'el_id' ];
83 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
85 if ( $params[
'continue'] !==
null ) {
87 array_fill( 0, count( $orderBy ),
'string' ) );
88 $conds = array_combine( $orderBy, array_map(
'rawurldecode', $cont ) );
89 $this->
addWhere( $db->buildComparison(
'>=', $conds ) );
93 $res = $this->
select( __METHOD__ );
97 foreach ( $res as $row ) {
98 if ( ++$count > $params[
'limit'] ) {
101 $this->setContinue( $orderBy, $row );
105 $to = LinkFilter::reverseIndexes( $row->el_to_domain_index ) . $row->el_to_path;
107 if ( $params[
'expandurl'] ) {
113 $this->setContinue( $orderBy, $row );
119 private function setContinue( array $orderBy, \stdClass $row ) {
121 foreach ( $orderBy as $field ) {
122 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
136 ParamValidator::PARAM_DEFAULT => 10,
137 ParamValidator::PARAM_TYPE =>
'limit',
138 IntegerDef::PARAM_MIN => 1,
146 ParamValidator::PARAM_TYPE => LinkFilter::prepareProtocols(),
147 ParamValidator::PARAM_DEFAULT =>
'',
151 ParamValidator::PARAM_TYPE =>
'boolean',
152 ParamValidator::PARAM_DEFAULT =>
false,
153 ParamValidator::PARAM_DEPRECATED =>
true,
160 $title = Title::newMainPage()->getPrefixedText();
161 $mp = rawurlencode( $title );
164 "action=query&prop=extlinks&titles={$mp}"
165 =>
'apihelp-query+extlinks-example-simple',
171 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Extlinks';
176class_alias( ApiQueryExternalLinks::class,
'ApiQueryExternalLinks' );