25 parent::__construct( $query, $moduleName,
'lbl' );
34 $this->
run( $resultPageSet );
41 public function run( $resultPageSet =
null ) {
44 if ( isset( $params[
'title'] ) && !isset( $params[
'lang'] ) ) {
47 'apierror-invalidparammix-mustusewith',
55 if ( $params[
'continue'] !==
null ) {
58 $op = $params[
'dir'] ==
'descending' ?
'<=' :
'>=';
59 $this->
addWhere( $db->buildComparison( $op, [
60 'll_lang' => $cont[0],
61 'll_title' => $cont[1],
62 'll_from' => $cont[2],
66 $prop = array_fill_keys( $params[
'prop'],
true );
67 $lllang = isset( $prop[
'lllang'] );
68 $lltitle = isset( $prop[
'lltitle'] );
70 $this->
addTables( [
'langlinks',
'page' ] );
71 $this->
addWhere(
'll_from = page_id' );
73 $this->
addFields( [
'page_id',
'page_title',
'page_namespace',
'page_is_redirect',
74 'll_from',
'll_lang',
'll_title' ] );
76 $sort = ( $params[
'dir'] ==
'descending' ?
' DESC' :
'' );
77 if ( isset( $params[
'lang'] ) ) {
79 if ( isset( $params[
'title'] ) ) {
81 $this->
addOption(
'ORDER BY',
'll_from' . $sort );
96 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
98 $res = $this->
select( __METHOD__ );
105 if ( $resultPageSet ===
null ) {
109 foreach ( $res as $row ) {
110 if ( ++$count > $params[
'limit'] ) {
116 "{$row->ll_lang}|{$row->ll_title}|{$row->ll_from}"
121 if ( $resultPageSet !==
null ) {
122 $pages[] = Title::newFromRow( $row );
124 $entry = [
'pageid' => (int)$row->page_id ];
129 if ( $row->page_is_redirect ) {
130 $entry[
'redirect'] =
true;
134 $entry[
'lllang'] = $row->ll_lang;
138 $entry[
'lltitle'] = $row->ll_title;
141 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $entry );
145 "{$row->ll_lang}|{$row->ll_title}|{$row->ll_from}"
152 if ( $resultPageSet ===
null ) {
153 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'll' );
155 $resultPageSet->populateFromTitles( $pages );
173 ParamValidator::PARAM_DEFAULT => 10,
174 ParamValidator::PARAM_TYPE =>
'limit',
175 IntegerDef::PARAM_MIN => 1,
180 ParamValidator::PARAM_ISMULTI =>
true,
181 ParamValidator::PARAM_DEFAULT =>
'',
182 ParamValidator::PARAM_TYPE => [
189 ParamValidator::PARAM_DEFAULT =>
'ascending',
190 ParamValidator::PARAM_TYPE => [
201 'action=query&list=langbacklinks&lbltitle=Test&lbllang=fr'
202 =>
'apihelp-query+langbacklinks-example-simple',
203 'action=query&generator=langbacklinks&glbltitle=Test&glbllang=fr&prop=info'
204 =>
'apihelp-query+langbacklinks-example-generator',
210 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Langbacklinks';
215class_alias( ApiQueryLangBacklinks::class,
'ApiQueryLangBacklinks' );