29 parent::__construct( $query, $moduleName,
'eu' );
41 $this->
run( $resultPageSet );
48 private function run( $resultPageSet =
null ) {
52 $query = $params[
'query'];
55 $this->
addTables( [
'page',
'externallinks' ] );
56 $this->
addWhere(
'page_id=el_from' );
59 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
60 $miser_ns = $params[
'namespace'] ?: [];
62 $this->
addWhereFld(
'page_namespace', $params[
'namespace'] );
67 if ( $query !==
null && $query !==
'' ) {
68 if ( $protocol ===
null ) {
69 $protocol =
'http://';
73 $query = Parser::normalizeLinkUrl( $protocol . $query );
77 'oneWildcard' =>
true,
84 if ( !isset( $conds[
'el_index_60'] ) ) {
85 $orderBy[] =
'el_index_60';
88 $orderBy[] =
'el_index_60';
90 if ( $protocol !==
null ) {
91 $this->
addWhere(
'el_index_60' . $db->buildLike(
"$protocol", $db->anyString() ) );
95 'el_to NOT' . $db->buildLike(
'//', $db->anyString() ),
96 'el_index_60 ' . $db->buildLike(
'http://', $db->anyString() ),
101 $orderBy[] =
'el_id';
102 $this->
addOption(
'ORDER BY', $orderBy );
105 $prop = array_flip( $params[
'prop'] );
106 $fld_ids = isset( $prop[
'ids'] );
107 $fld_title = isset( $prop[
'title'] );
108 $fld_url = isset( $prop[
'url'] );
110 if ( is_null( $resultPageSet ) ) {
118 $this->
addFields( $resultPageSet->getPageTableFields() );
121 $limit = $params[
'limit'];
124 if ( $params[
'continue'] !==
null ) {
125 $cont = explode(
'|', $params[
'continue'] );
127 $i = count( $cont ) - 1;
128 $cond = $orderBy[$i] .
' >= ' . $db->addQuotes( rawurldecode( $cont[$i] ) );
130 $field = $orderBy[$i];
131 $v = $db->addQuotes( rawurldecode( $cont[$i] ) );
132 $cond =
"($field > $v OR ($field = $v AND $cond))";
141 foreach (
$res as $row ) {
142 if ( ++$count > $limit ) {
149 if ( count( $miser_ns ) && !in_array( $row->page_namespace, $miser_ns ) ) {
153 if ( is_null( $resultPageSet ) ) {
155 ApiResult::META_TYPE =>
'assoc',
158 $vals[
'pageid'] = (int)$row->page_id;
161 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
167 if ( $params[
'expandurl'] ) {
172 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
178 $resultPageSet->processDbRow( $row );
182 if ( is_null( $resultPageSet ) ) {
183 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
190 foreach ( $orderBy as $field ) {
191 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
227 'expandurl' =>
false,
230 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
232 'api-help-param-limited-in-miser-mode',
244 $protocols[] = substr( $p, 0, strpos( $p,
':' ) );
256 if ( substr( $p, 0, strlen( $protocol ) ) === $protocol ) {
270 'action=query&list=exturlusage&euquery=www.mediawiki.org'
271 =>
'apihelp-query+exturlusage-example-simple',
276 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Exturlusage';
$wgUrlProtocols
URL schemes that should be recognized as valid by wfParseUrl().
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
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.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
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)
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.
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.
setContinue( $orderBy, $row)
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.
static prepareProtocols()
run( $resultPageSet=null)
static getProtocolPrefix( $protocol)
__construct(ApiQuery $query, $moduleName)
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.
static getQueryConditions( $filterEntry, array $options=[])
Return query conditions which will match the specified string.