39 parent::__construct( $query, $moduleName,
'iwbl' );
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 'iwl_prefix' => $cont[0],
74 'iwl_title' => $cont[1],
75 'iwl_from' => $cont[2],
79 $prop = array_fill_keys(
$params[
'prop'],
true );
80 $iwprefix = isset( $prop[
'iwprefix'] );
81 $iwtitle = isset( $prop[
'iwtitle'] );
83 $this->
addTables( [
'iwlinks',
'page' ] );
84 $this->
addWhere(
'iwl_from = page_id' );
86 $this->
addFields( [
'page_id',
'page_title',
'page_namespace',
'page_is_redirect',
87 'iwl_from',
'iwl_prefix',
'iwl_title' ] );
89 $sort = (
$params[
'dir'] ==
'descending' ?
' DESC' :
'' );
90 if ( isset(
$params[
'prefix'] ) ) {
92 if ( isset(
$params[
'title'] ) ) {
94 $this->
addOption(
'ORDER BY',
'iwl_from' . $sort );
103 'iwl_prefix' . $sort,
111 $res = $this->
select( __METHOD__ );
118 if ( $resultPageSet ===
null ) {
122 foreach ( $res as $row ) {
123 if ( ++$count >
$params[
'limit'] ) {
130 "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}"
135 if ( $resultPageSet !==
null ) {
136 $pages[] = Title::newFromRow( $row );
138 $entry = [
'pageid' => (int)$row->page_id ];
140 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
143 if ( $row->page_is_redirect ) {
144 $entry[
'redirect'] =
true;
148 $entry[
'iwprefix'] = $row->iwl_prefix;
152 $entry[
'iwtitle'] = $row->iwl_title;
155 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $entry );
159 "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}"
166 if ( $resultPageSet ===
null ) {
167 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'iw' );
169 $resultPageSet->populateFromTitles( $pages );
185 ParamValidator::PARAM_DEFAULT => 10,
186 ParamValidator::PARAM_TYPE =>
'limit',
187 IntegerDef::PARAM_MIN => 1,
192 ParamValidator::PARAM_ISMULTI =>
true,
193 ParamValidator::PARAM_DEFAULT =>
'',
194 ParamValidator::PARAM_TYPE => [
201 ParamValidator::PARAM_DEFAULT =>
'ascending',
202 ParamValidator::PARAM_TYPE => [
212 'action=query&list=iwbacklinks&iwbltitle=Test&iwblprefix=wikibooks'
213 =>
'apihelp-query+iwbacklinks-example-simple',
214 'action=query&generator=iwbacklinks&giwbltitle=Test&giwblprefix=wikibooks&prop=info'
215 =>
'apihelp-query+iwbacklinks-example-generator',
220 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Iwbacklinks';
225class_alias( ApiQueryIWBacklinks::class,
'ApiQueryIWBacklinks' );
array $params
The job parameters.