35 parent::__construct( $query, $moduleName,
'eu' );
37 $this->urlUtils = $urlUtils;
51 $this->run( $resultPageSet );
58 private function run( $resultPageSet =
null ) {
62 $query = $params[
'query'];
63 $protocol = LinkFilter::getProtocolPrefix( $params[
'protocol'] );
65 $this->
addTables( [
'externallinks',
'page' ] );
66 $this->
addJoinConds( [
'page' => [
'JOIN',
'page_id=el_from' ] ] );
67 $fields = [
'el_to_domain_index',
'el_to_path' ];
71 $miser_ns = $params[
'namespace'] ?: [];
73 $this->
addWhereFld(
'page_namespace', $params[
'namespace'] );
75 if ( $query !==
null && $query !==
'' ) {
77 $query = Parser::normalizeLinkUrl( $query );
78 $conds = LinkFilter::getQueryConditions( $query, [
79 'protocol' => $protocol,
80 'oneWildcard' =>
true,
88 if ( $protocol !==
null ) {
90 $db->expr(
'el_to_domain_index', IExpression::LIKE,
new LikeValue(
"$protocol", $db->anyString() ) )
94 $orderBy = [
'el_id' ];
99 $prop = array_fill_keys( $params[
'prop'],
true );
100 $fld_ids = isset( $prop[
'ids'] );
101 $fld_title = isset( $prop[
'title'] );
102 $fld_url = isset( $prop[
'url'] );
104 if ( $resultPageSet ===
null ) {
110 foreach ( $fields as $field ) {
114 $this->
addFields( $resultPageSet->getPageTableFields() );
123 if ( $params[
'continue'] !==
null ) {
125 array_fill( 0, count( $orderBy ),
'string' ) );
126 $conds = array_combine( $orderBy, array_map(
'rawurldecode', $cont ) );
127 $this->
addWhere( $db->buildComparison(
'>=', $conds ) );
131 $res = $this->
select( __METHOD__ );
136 if ( $resultPageSet ===
null ) {
141 foreach ( $res as $row ) {
142 if ( ++$count > $limit ) {
145 $this->setContinue( $orderBy, $row );
149 if ( count( $miser_ns ) && !in_array( $row->page_namespace, $miser_ns ) ) {
153 if ( $resultPageSet ===
null ) {
158 $vals[
'pageid'] = (int)$row->page_id;
165 $to = LinkFilter::reverseIndexes( $row->el_to_domain_index ) . $row->el_to_path;
167 if ( $params[
'expandurl'] ) {
172 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
174 $this->setContinue( $orderBy, $row );
178 $resultPageSet->processDbRow( $row );
182 if ( $resultPageSet ===
null ) {
183 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
188 private function setContinue( array $orderBy, \stdClass $row ) {
190 foreach ( $orderBy as $field ) {
191 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
200 ParamValidator::PARAM_ISMULTI =>
true,
201 ParamValidator::PARAM_DEFAULT =>
'ids|title|url',
202 ParamValidator::PARAM_TYPE => [
213 ParamValidator::PARAM_TYPE => LinkFilter::prepareProtocols(),
214 ParamValidator::PARAM_DEFAULT =>
'',
218 ParamValidator::PARAM_ISMULTI =>
true,
219 ParamValidator::PARAM_TYPE =>
'namespace'
222 ParamValidator::PARAM_DEFAULT => 10,
223 ParamValidator::PARAM_TYPE =>
'limit',
224 IntegerDef::PARAM_MIN => 1,
229 ParamValidator::PARAM_TYPE =>
'boolean',
230 ParamValidator::PARAM_DEFAULT =>
false,
231 ParamValidator::PARAM_DEPRECATED =>
true,
237 'api-help-param-limited-in-miser-mode',
247 'action=query&list=exturlusage&euquery=www.mediawiki.org'
248 =>
'apihelp-query+exturlusage-example-simple',
254 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Exturlusage';
259class_alias( ApiQueryExtLinksUsage::class,
'ApiQueryExtLinksUsage' );
A class containing constants representing the names of configuration variables.
const MiserMode
Name constant for the MiserMode setting, for use with Config::get()