39 parent::__construct( $query, $moduleName,
'eu' );
51 $this->run( $resultPageSet );
58 private function run( $resultPageSet =
null ) {
62 $query = $params[
'query'];
65 $this->
addTables( [
'externallinks',
'page' ] );
66 $this->
addJoinConds( [
'page' => [
'JOIN',
'page_id=el_from' ] ] );
69 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
70 $miser_ns = $params[
'namespace'] ?: [];
72 $this->
addWhereFld(
'page_namespace', $params[
'namespace'] );
77 if ( $query !==
null && $query !==
'' ) {
78 if ( $protocol ===
null ) {
79 $protocol =
'http://';
87 'oneWildcard' =>
true,
94 if ( !isset( $conds[
'el_index_60'] ) ) {
95 $orderBy[] =
'el_index_60';
98 $orderBy[] =
'el_index_60';
100 if ( $protocol !==
null ) {
101 $this->
addWhere(
'el_index_60' . $db->buildLike(
"$protocol", $db->anyString() ) );
105 'el_to NOT' . $db->buildLike(
'//', $db->anyString() ),
106 'el_index_60 ' . $db->buildLike(
'http://', $db->anyString() ),
111 $orderBy[] =
'el_id';
112 $this->
addOption(
'ORDER BY', $orderBy );
115 $prop = array_fill_keys( $params[
'prop'],
true );
116 $fld_ids = isset( $prop[
'ids'] );
117 $fld_title = isset( $prop[
'title'] );
118 $fld_url = isset( $prop[
'url'] );
120 if ( $resultPageSet ===
null ) {
128 $this->
addFields( $resultPageSet->getPageTableFields() );
131 $limit = $params[
'limit'];
137 if ( $params[
'continue'] !==
null ) {
138 $cont = explode(
'|', $params[
'continue'] );
140 $i = count( $cont ) - 1;
141 $cond = $orderBy[$i] .
' >= ' . $db->addQuotes( rawurldecode( $cont[$i] ) );
143 $field = $orderBy[$i];
144 $v = $db->addQuotes( rawurldecode( $cont[$i] ) );
145 $cond =
"($field > $v OR ($field = $v AND $cond))";
154 if ( $resultPageSet ===
null ) {
159 foreach (
$res as $row ) {
160 if ( ++$count > $limit ) {
163 $this->setContinue( $orderBy, $row );
167 if ( count( $miser_ns ) && !in_array( $row->page_namespace, $miser_ns ) ) {
171 if ( $resultPageSet ===
null ) {
176 $vals[
'pageid'] = (int)$row->page_id;
185 if ( $params[
'expandurl'] ) {
190 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
192 $this->setContinue( $orderBy, $row );
196 $resultPageSet->processDbRow( $row );
200 if ( $resultPageSet ===
null ) {
201 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
206 private function setContinue( $orderBy, $row ) {
208 foreach ( $orderBy as $field ) {
209 $fields[] = strtr( $row->$field, [
'%' =>
'%25',
'|' =>
'%7C' ] );
217 ParamValidator::PARAM_ISMULTI =>
true,
218 ParamValidator::PARAM_DEFAULT =>
'ids|title|url',
219 ParamValidator::PARAM_TYPE => [
231 ParamValidator::PARAM_DEFAULT =>
'',
235 ParamValidator::PARAM_ISMULTI =>
true,
236 ParamValidator::PARAM_TYPE =>
'namespace'
239 ParamValidator::PARAM_DEFAULT => 10,
240 ParamValidator::PARAM_TYPE =>
'limit',
241 IntegerDef::PARAM_MIN => 1,
245 'expandurl' =>
false,
248 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
250 'api-help-param-limited-in-miser-mode',
258 $urlProtocols = MediaWikiServices::getInstance()->getMainConfig()
259 ->get( MainConfigNames::UrlProtocols );
261 foreach ( $urlProtocols as $p ) {
263 $protocols[] = substr( $p, 0, strpos( $p,
':' ) );
272 $urlProtocols = MediaWikiServices::getInstance()->getMainConfig()
273 ->get( MainConfigNames::UrlProtocols );
274 if ( $protocol && !in_array( $protocol, $urlProtocols ) ) {
275 foreach ( $urlProtocols as $p ) {
276 if ( str_starts_with( $p, $protocol ) ) {
290 'action=query&list=exturlusage&euquery=www.mediawiki.org'
291 =>
'apihelp-query+exturlusage-example-simple',
296 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Exturlusage';
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
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 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.
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()
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.
const META_TYPE
Key for the 'type' metadata item.
static getQueryConditions( $filterEntry, array $options=[])
Return query conditions which will match the specified string.
A class containing constants representing the names of configuration variables.
static normalizeLinkUrl( $url)
Replace unusual escape codes in a URL with their equivalent characters.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.