39 parent::__construct( $query, $moduleName,
'lbl' );
47 $this->
run( $resultPageSet );
54 public function run( $resultPageSet =
null ) {
60 'apierror-invalidparammix-mustusewith',
68 if (
$params[
'continue'] !==
null ) {
71 $op =
$params[
'dir'] ==
'descending' ?
'<=' :
'>=';
72 $this->
addWhere( $db->buildComparison( $op, [
73 'll_lang' => $cont[0],
74 'll_title' => $cont[1],
75 'll_from' => $cont[2],
79 $prop = array_fill_keys(
$params[
'prop'],
true );
80 $lllang = isset( $prop[
'lllang'] );
81 $lltitle = isset( $prop[
'lltitle'] );
83 $this->
addTables( [
'langlinks',
'page' ] );
84 $this->
addWhere(
'll_from = page_id' );
86 $this->
addFields( [
'page_id',
'page_title',
'page_namespace',
'page_is_redirect',
87 'll_from',
'll_lang',
'll_title' ] );
89 $sort = (
$params[
'dir'] ==
'descending' ?
' DESC' :
'' );
90 if ( isset(
$params[
'lang'] ) ) {
92 if ( isset(
$params[
'title'] ) ) {
94 $this->
addOption(
'ORDER BY',
'll_from' . $sort );
111 $res = $this->
select( __METHOD__ );
118 if ( $resultPageSet ===
null ) {
122 foreach ( $res as $row ) {
123 if ( ++$count >
$params[
'limit'] ) {
129 "{$row->ll_lang}|{$row->ll_title}|{$row->ll_from}"
134 if ( $resultPageSet !==
null ) {
135 $pages[] = Title::newFromRow( $row );
137 $entry = [
'pageid' => (int)$row->page_id ];
139 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
142 if ( $row->page_is_redirect ) {
143 $entry[
'redirect'] =
true;
147 $entry[
'lllang'] = $row->ll_lang;
151 $entry[
'lltitle'] = $row->ll_title;
154 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $entry );
158 "{$row->ll_lang}|{$row->ll_title}|{$row->ll_from}"
165 if ( $resultPageSet ===
null ) {
166 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'll' );
168 $resultPageSet->populateFromTitles( $pages );
184 ParamValidator::PARAM_DEFAULT => 10,
185 ParamValidator::PARAM_TYPE =>
'limit',
186 IntegerDef::PARAM_MIN => 1,
191 ParamValidator::PARAM_ISMULTI =>
true,
192 ParamValidator::PARAM_DEFAULT =>
'',
193 ParamValidator::PARAM_TYPE => [
200 ParamValidator::PARAM_DEFAULT =>
'ascending',
201 ParamValidator::PARAM_TYPE => [
211 'action=query&list=langbacklinks&lbltitle=Test&lbllang=fr'
212 =>
'apihelp-query+langbacklinks-example-simple',
213 'action=query&generator=langbacklinks&glbltitle=Test&glbllang=fr&prop=info'
214 =>
'apihelp-query+langbacklinks-example-generator',
219 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Langbacklinks';
224class_alias( ApiQueryLangBacklinks::class,
'ApiQueryLangBacklinks' );
array $params
The job parameters.