26 parent::__construct( $query, $moduleName,
'lbl' );
35 $this->
run( $resultPageSet );
42 public function run( $resultPageSet =
null ) {
45 if ( isset( $params[
'title'] ) && !isset( $params[
'lang'] ) ) {
48 'apierror-invalidparammix-mustusewith',
56 if ( $params[
'continue'] !==
null ) {
59 $op = $params[
'dir'] ==
'descending' ?
'<=' :
'>=';
60 $this->
addWhere( $db->buildComparison( $op, [
61 'll_lang' => $cont[0],
62 'll_title' => $cont[1],
63 'll_from' => $cont[2],
67 $prop = array_fill_keys( $params[
'prop'],
true );
68 $lllang = isset( $prop[
'lllang'] );
69 $lltitle = isset( $prop[
'lltitle'] );
71 $this->
addTables( [
'langlinks',
'page' ] );
72 $this->
addWhere(
'll_from = page_id' );
74 $this->
addFields( [
'page_id',
'page_title',
'page_namespace',
'page_is_redirect',
75 'll_from',
'll_lang',
'll_title' ] );
77 $sort = ( $params[
'dir'] ==
'descending' ?
' DESC' :
'' );
78 if ( isset( $params[
'lang'] ) ) {
80 if ( isset( $params[
'title'] ) ) {
82 $this->
addOption(
'ORDER BY',
'll_from' . $sort );
97 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
100 $res = $this->
select( __METHOD__ );
107 if ( $resultPageSet ===
null ) {
111 foreach ( $res as $row ) {
112 if ( ++$count > $params[
'limit'] ) {
118 "{$row->ll_lang}|{$row->ll_title}|{$row->ll_from}"
123 if ( $resultPageSet !==
null ) {
124 $pages[] = Title::newFromRow( $row );
126 $entry = [
'pageid' => (int)$row->page_id ];
131 if ( $row->page_is_redirect ) {
132 $entry[
'redirect'] =
true;
136 $entry[
'lllang'] = $row->ll_lang;
140 $entry[
'lltitle'] = $row->ll_title;
143 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $entry );
147 "{$row->ll_lang}|{$row->ll_title}|{$row->ll_from}"
154 if ( $resultPageSet ===
null ) {
155 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'll' );
157 $resultPageSet->populateFromTitles( $pages );
175 ParamValidator::PARAM_DEFAULT => 10,
176 ParamValidator::PARAM_TYPE =>
'limit',
177 IntegerDef::PARAM_MIN => 1,
182 ParamValidator::PARAM_ISMULTI =>
true,
183 ParamValidator::PARAM_DEFAULT =>
'',
184 ParamValidator::PARAM_TYPE => [
191 ParamValidator::PARAM_DEFAULT =>
'ascending',
192 ParamValidator::PARAM_TYPE => [
203 'action=query&list=langbacklinks&lbltitle=Test&lbllang=fr'
204 =>
'apihelp-query+langbacklinks-example-simple',
205 'action=query&generator=langbacklinks&glbltitle=Test&glbllang=fr&prop=info'
206 =>
'apihelp-query+langbacklinks-example-generator',
212 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Langbacklinks';
217class_alias( ApiQueryLangBacklinks::class,
'ApiQueryLangBacklinks' );