33 parent::__construct( $query, $moduleName,
'eu' );
47 $this->run( $resultPageSet );
54 private function run( $resultPageSet =
null ) {
58 $query = $params[
'query'];
59 $protocol = LinkFilter::getProtocolPrefix( $params[
'protocol'] );
61 $this->
addTables( [
'externallinks',
'page' ] );
62 $this->
addJoinConds( [
'page' => [
'JOIN',
'page_id=el_from' ] ] );
63 $fields = [
'el_to_domain_index',
'el_to_path' ];
67 $miser_ns = $params[
'namespace'] ?: [];
69 $this->
addWhereFld(
'page_namespace', $params[
'namespace'] );
71 if ( $query !==
null && $query !==
'' ) {
73 $query = Parser::normalizeLinkUrl( $query );
74 $conds = LinkFilter::getQueryConditions( $query, [
75 'protocol' => $protocol,
76 'oneWildcard' =>
true,
84 if ( $protocol !==
null ) {
86 $db->expr(
'el_to_domain_index', IExpression::LIKE,
new LikeValue(
"$protocol", $db->anyString() ) )
90 $orderBy = [
'el_id' ];
95 $prop = array_fill_keys( $params[
'prop'],
true );
96 $fld_ids = isset( $prop[
'ids'] );
97 $fld_title = isset( $prop[
'title'] );
98 $fld_url = isset( $prop[
'url'] );
100 if ( $resultPageSet ===
null ) {
106 foreach ( $fields as $field ) {
110 $this->
addFields( $resultPageSet->getPageTableFields() );
119 if ( $params[
'continue'] !==
null ) {
121 array_fill( 0, count( $orderBy ),
'string' ) );
122 $conds = array_combine( $orderBy, array_map(
'rawurldecode', $cont ) );
123 $this->
addWhere( $db->buildComparison(
'>=', $conds ) );
127 $res = $this->
select( __METHOD__ );
132 if ( $resultPageSet ===
null ) {
137 foreach ( $res as $row ) {
138 if ( ++$count > $limit ) {
141 $this->setContinue( $orderBy, $row );
145 if ( count( $miser_ns ) && !in_array( $row->page_namespace, $miser_ns ) ) {
149 if ( $resultPageSet ===
null ) {
154 $vals[
'pageid'] = (int)$row->page_id;
161 $to = LinkFilter::reverseIndexes( $row->el_to_domain_index ) . $row->el_to_path;
163 if ( $params[
'expandurl'] ) {
168 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
170 $this->setContinue( $orderBy, $row );
174 $resultPageSet->processDbRow( $row );
178 if ( $resultPageSet ===
null ) {
179 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
184 private function setContinue( array $orderBy, \stdClass $row ) {
186 foreach ( $orderBy as $field ) {
187 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
196 ParamValidator::PARAM_ISMULTI =>
true,
197 ParamValidator::PARAM_DEFAULT =>
'ids|title|url',
198 ParamValidator::PARAM_TYPE => [
209 ParamValidator::PARAM_TYPE => LinkFilter::prepareProtocols(),
210 ParamValidator::PARAM_DEFAULT =>
'',
214 ParamValidator::PARAM_ISMULTI =>
true,
215 ParamValidator::PARAM_TYPE =>
'namespace'
218 ParamValidator::PARAM_DEFAULT => 10,
219 ParamValidator::PARAM_TYPE =>
'limit',
220 IntegerDef::PARAM_MIN => 1,
225 ParamValidator::PARAM_TYPE =>
'boolean',
226 ParamValidator::PARAM_DEFAULT =>
false,
227 ParamValidator::PARAM_DEPRECATED =>
true,
233 'api-help-param-limited-in-miser-mode',
243 'action=query&list=exturlusage&euquery=www.mediawiki.org'
244 =>
'apihelp-query+exturlusage-example-simple',
250 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Exturlusage';
255class_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()