35 parent::__construct( $query, $moduleName,
'el' );
37 $this->urlUtils = $urlUtils;
42 if ( $pages === [] ) {
49 $query = $params[
'query'];
50 $protocol = LinkFilter::getProtocolPrefix( $params[
'protocol'] );
52 $fields = [
'el_from' ];
53 $fields[] =
'el_to_domain_index';
54 $fields[] =
'el_to_path';
55 $continueField =
'el_to_domain_index';
59 $this->
addWhereFld(
'el_from', array_keys( $pages ) );
61 if ( $query !==
null && $query !==
'' ) {
63 $query = Parser::normalizeLinkUrl( $query );
65 $conds = LinkFilter::getQueryConditions( $query, [
66 'protocol' => $protocol,
67 'oneWildcard' =>
true,
75 if ( $protocol !==
null ) {
77 $db->expr( $continueField, IExpression::LIKE,
new LikeValue(
"$protocol", $db->anyString() ) )
82 $orderBy = [
'el_id' ];
87 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
89 if ( $params[
'continue'] !==
null ) {
91 array_fill( 0, count( $orderBy ),
'string' ) );
92 $conds = array_combine( $orderBy, array_map(
'rawurldecode', $cont ) );
93 $this->
addWhere( $db->buildComparison(
'>=', $conds ) );
97 $res = $this->
select( __METHOD__ );
101 foreach ( $res as $row ) {
102 if ( ++$count > $params[
'limit'] ) {
105 $this->setContinue( $orderBy, $row );
109 $to = LinkFilter::reverseIndexes( $row->el_to_domain_index ) . $row->el_to_path;
111 if ( $params[
'expandurl'] ) {
117 $this->setContinue( $orderBy, $row );
123 private function setContinue( array $orderBy, \stdClass $row ) {
125 foreach ( $orderBy as $field ) {
126 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
140 ParamValidator::PARAM_DEFAULT => 10,
141 ParamValidator::PARAM_TYPE =>
'limit',
142 IntegerDef::PARAM_MIN => 1,
150 ParamValidator::PARAM_TYPE => LinkFilter::prepareProtocols(),
151 ParamValidator::PARAM_DEFAULT =>
'',
155 ParamValidator::PARAM_TYPE =>
'boolean',
156 ParamValidator::PARAM_DEFAULT =>
false,
157 ParamValidator::PARAM_DEPRECATED =>
true,
164 $title = Title::newMainPage()->getPrefixedText();
165 $mp = rawurlencode( $title );
168 "action=query&prop=extlinks&titles={$mp}"
169 =>
'apihelp-query+extlinks-example-simple',
175 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Extlinks';
180class_alias( ApiQueryExternalLinks::class,
'ApiQueryExternalLinks' );