Go to the documentation of this file.
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 ) ) {
158 $vals[
'pageid'] = (int)$row->page_id;
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';
getCacheMode( $params)
Get the cache mode for the data generated by this module.
addFields( $value)
Add a set of fields to select to the internal array.
This is the main query class.
static getQueryConditions( $filterEntry, array $options=[])
Return query conditions which will match the specified string.
const META_TYPE
Key for the 'type' metadata item.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
getHelpUrls()
Return links to more detailed help pages about the module.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
static prepareProtocols()
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
const LIMIT_BIG1
Fast query, standard limit.
getDB()
Get the Query database connection (read-only)
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
setContinue( $orderBy, $row)
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
run( $resultPageSet=null)
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
__construct(ApiQuery $query, $moduleName)
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
$wgUrlProtocols
URL schemes that should be recognized as valid by wfParseUrl().
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getExamplesMessages()
Returns usage examples for this module.
const LIMIT_BIG2
Fast query, apihighlimits limit.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
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.
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
addWhere( $value)
Add a set of WHERE clauses to the internal array.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
executeGenerator( $resultPageSet)
Execute this module as a generator.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
static getProtocolPrefix( $protocol)