44 parent::__construct( $query, $moduleName,
'eu' );
46 $this->urlUtils = $urlUtils;
58 $this->run( $resultPageSet );
65 private function run( $resultPageSet =
null ) {
69 $query = $params[
'query'];
70 $protocol = LinkFilter::getProtocolPrefix( $params[
'protocol'] );
72 $this->
addTables( [
'externallinks',
'page' ] );
73 $this->
addJoinConds( [
'page' => [
'JOIN',
'page_id=el_from' ] ] );
74 $continueField =
'el_to_domain_index';
75 $fields = [
'el_to_domain_index',
'el_to_path' ];
78 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
79 $miser_ns = $params[
'namespace'] ?: [];
81 $this->
addWhereFld(
'page_namespace', $params[
'namespace'] );
83 if ( $query !==
null && $query !==
'' ) {
86 $conds = LinkFilter::getQueryConditions( $query, [
87 'protocol' => $protocol,
88 'oneWildcard' =>
true,
96 if ( $protocol !==
null ) {
97 $this->
addWhere( $continueField . $db->buildLike(
"$protocol", $db->anyString() ) );
100 $orderBy = [
'el_id' ];
102 $this->
addOption(
'ORDER BY', $orderBy );
105 $prop = array_fill_keys( $params[
'prop'],
true );
106 $fld_ids = isset( $prop[
'ids'] );
107 $fld_title = isset( $prop[
'title'] );
108 $fld_url = isset( $prop[
'url'] );
110 if ( $resultPageSet ===
null ) {
116 foreach ( $fields as $field ) {
120 $this->
addFields( $resultPageSet->getPageTableFields() );
123 $limit = $params[
'limit'];
129 if ( $params[
'continue'] !==
null ) {
131 array_fill( 0, count( $orderBy ),
'string' ) );
132 $conds = array_combine( $orderBy, array_map(
'rawurldecode', $cont ) );
133 $this->
addWhere( $db->buildComparison(
'>=', $conds ) );
136 $res = $this->
select( __METHOD__ );
140 if ( $resultPageSet ===
null ) {
145 foreach ( $res as $row ) {
146 if ( ++$count > $limit ) {
149 $this->setContinue( $orderBy, $row );
153 if ( count( $miser_ns ) && !in_array( $row->page_namespace, $miser_ns ) ) {
157 if ( $resultPageSet ===
null ) {
162 $vals[
'pageid'] = (int)$row->page_id;
165 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
169 $to = LinkFilter::reverseIndexes( $row->el_to_domain_index ) . $row->el_to_path;
171 if ( $params[
'expandurl'] ) {
176 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
178 $this->setContinue( $orderBy, $row );
182 $resultPageSet->processDbRow( $row );
186 if ( $resultPageSet ===
null ) {
187 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
192 private function setContinue( $orderBy, $row ) {
194 foreach ( $orderBy as $field ) {
195 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
203 ParamValidator::PARAM_ISMULTI =>
true,
204 ParamValidator::PARAM_DEFAULT =>
'ids|title|url',
205 ParamValidator::PARAM_TYPE => [
216 ParamValidator::PARAM_TYPE => LinkFilter::prepareProtocols(),
217 ParamValidator::PARAM_DEFAULT =>
'',
221 ParamValidator::PARAM_ISMULTI =>
true,
222 ParamValidator::PARAM_TYPE =>
'namespace'
225 ParamValidator::PARAM_DEFAULT => 10,
226 ParamValidator::PARAM_TYPE =>
'limit',
227 IntegerDef::PARAM_MIN => 1,
232 ParamValidator::PARAM_TYPE =>
'boolean',
233 ParamValidator::PARAM_DEFAULT =>
false,
234 ParamValidator::PARAM_DEPRECATED =>
true,
238 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
240 'api-help-param-limited-in-miser-mode',
249 'action=query&list=exturlusage&euquery=www.mediawiki.org'
250 =>
'apihelp-query+exturlusage-example-simple',
255 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Exturlusage';
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
getDB()
Get the Query database connection (read-only)
executeGenderCacheFromResultWrapper(IResultWrapper $res, $fname=__METHOD__, $fieldPrefix='page')
Preprocess the result set to fill the GenderCache with the necessary information before using self::a...
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
addWhere( $value)
Add a set of WHERE clauses to the internal array.
executeGenerator( $resultPageSet)
Execute this module as a generator.
__construct(ApiQuery $query, $moduleName, UrlUtils $urlUtils)
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getHelpUrls()
Return links to more detailed help pages about the module.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
This is the main query class.
const META_TYPE
Key for the 'type' metadata item.
A class containing constants representing the names of configuration variables.
static normalizeLinkUrl( $url)
Replace unusual escape codes in a URL with their equivalent characters.