47 parent::__construct( $query, $moduleName,
'el' );
49 $this->urlUtils = $urlUtils;
54 if ( $pages === [] ) {
62 $protocol = LinkFilter::getProtocolPrefix(
$params[
'protocol'] );
64 $fields = [
'el_from' ];
65 $fields[] =
'el_to_domain_index';
66 $fields[] =
'el_to_path';
67 $continueField =
'el_to_domain_index';
71 $this->
addWhereFld(
'el_from', array_keys( $pages ) );
73 if ( $query !==
null && $query !==
'' ) {
75 $query = Parser::normalizeLinkUrl( $query );
77 $conds = LinkFilter::getQueryConditions( $query, [
78 'protocol' => $protocol,
79 'oneWildcard' =>
true,
87 if ( $protocol !==
null ) {
89 $db->expr( $continueField, IExpression::LIKE,
new LikeValue(
"$protocol", $db->anyString() ) )
94 $orderBy = [
'el_id' ];
101 if (
$params[
'continue'] !==
null ) {
103 array_fill( 0, count( $orderBy ),
'string' ) );
104 $conds = array_combine( $orderBy, array_map(
'rawurldecode', $cont ) );
105 $this->
addWhere( $db->buildComparison(
'>=', $conds ) );
108 $res = $this->
select( __METHOD__ );
111 foreach ( $res as $row ) {
112 if ( ++$count >
$params[
'limit'] ) {
115 $this->setContinue( $orderBy, $row );
119 $to = LinkFilter::reverseIndexes( $row->el_to_domain_index ) . $row->el_to_path;
124 ApiResult::setContentValue( $entry,
'url', $to );
127 $this->setContinue( $orderBy, $row );
133 private function setContinue( $orderBy, $row ) {
135 foreach ( $orderBy as $field ) {
136 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
148 ParamValidator::PARAM_DEFAULT => 10,
149 ParamValidator::PARAM_TYPE =>
'limit',
150 IntegerDef::PARAM_MIN => 1,
158 ParamValidator::PARAM_TYPE => LinkFilter::prepareProtocols(),
159 ParamValidator::PARAM_DEFAULT =>
'',
163 ParamValidator::PARAM_TYPE =>
'boolean',
164 ParamValidator::PARAM_DEFAULT =>
false,
165 ParamValidator::PARAM_DEPRECATED =>
true,
171 $title = Title::newMainPage()->getPrefixedText();
172 $mp = rawurlencode( $title );
175 "action=query&prop=extlinks&titles={$mp}"
176 =>
'apihelp-query+extlinks-example-simple',
181 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Extlinks';
array $params
The job parameters.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
const LIMIT_BIG1
Fast query, standard limit.
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.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
addFields( $value)
Add a set of fields to select to the internal array.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
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)
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
getPageSet()
Get the PageSet object to work on.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
A query module to list all external URLs found on a given set of pages.
getExamplesMessages()
Returns usage examples for this module.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
__construct(ApiQuery $query, $moduleName, UrlUtils $urlUtils)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
This is the main query class.