29 parent::__construct( $query, $moduleName,
'im' );
30 $this->linksMigration = $linksMigration;
39 $this->run( $resultPageSet );
45 private function run( $resultPageSet =
null ) {
47 if ( $pages === [] ) {
54 $queryInfo = $this->linksMigration->getQueryInfo(
'imagelinks' );
59 $this->
addFields( [
'il_from',
'il_to' =>
'lt_title' ] );
62 $this->
addFields( [
'il_from',
'il_to' ] );
65 $this->
addWhereFld(
'il_from', array_keys( $pages ) );
66 if ( $params[
'continue'] !==
null ) {
68 $op =
$params[
'dir'] ==
'descending' ?
'<=' :
'>=';
69 $comparison = [
'il_from' => $cont[0] ];
71 $comparison[
'lt_namespace'] =
NS_FILE;
72 $comparison[
'lt_title'] = $cont[1];
74 $comparison[
'il_to'] = $cont[1];
76 $this->
addWhere( $this->
getDB()->buildComparison( $op, $comparison ) );
79 $sort = (
$params[
'dir'] ==
'descending' ?
' DESC' :
'' );
81 if ( count( $pages ) === 1 ) {
82 $this->
addOption(
'ORDER BY',
'il_to' . $sort );
89 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
91 if ( $params[
'images'] ) {
93 foreach ( $params[
'images'] as $img ) {
94 $title = Title::newFromText( $img );
95 if ( !$title || $title->getNamespace() !==
NS_FILE ) {
98 $images[] = $title->getDBkey();
114 $res = $this->
select( __METHOD__ );
117 if ( $resultPageSet ===
null ) {
119 foreach ( $res as $row ) {
120 if ( ++$count > $params[
'limit'] ) {
137 foreach ( $res as $row ) {
138 if ( ++$count > $params[
'limit'] ) {
146 $resultPageSet->populateFromTitles( $titles );
159 ParamValidator::PARAM_DEFAULT => 10,
160 ParamValidator::PARAM_TYPE =>
'limit',
161 IntegerDef::PARAM_MIN => 1,
169 ParamValidator::PARAM_ISMULTI =>
true,
172 ParamValidator::PARAM_DEFAULT =>
'ascending',
173 ParamValidator::PARAM_TYPE => [
183 $title = Title::newMainPage()->getPrefixedText();
184 $mp = rawurlencode( $title );
187 "action=query&prop=images&titles={$mp}"
188 =>
'apihelp-query+images-example-simple',
189 "action=query&generator=images&titles={$mp}&prop=info"
190 =>
'apihelp-query+images-example-generator',
196 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Images';
201class_alias( ApiQueryImages::class,
'ApiQueryImages' );
const SCHEMA_COMPAT_READ_NEW
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
A class containing constants representing the names of configuration variables.
const ImageLinksSchemaMigrationStage
Name constant for the ImageLinksSchemaMigrationStage setting, for use with Config::get()