API: Handle pltitles/tltemplates/clcategories/imimages with only invalid titles
If the parameter contains only invalid titles, it shouldn't be ignored. Bug: T162816 Change-Id: I3ee6aeab421db5732b652fed21292d8509f8d757
This commit is contained in:
parent
899b6de393
commit
61de3c3e61
3 changed files with 14 additions and 3 deletions
|
|
@ -69,7 +69,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
|
|||
|
||||
$this->addTables( 'categorylinks' );
|
||||
$this->addWhereFld( 'cl_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
|
||||
if ( !is_null( $params['categories'] ) ) {
|
||||
if ( $params['categories'] ) {
|
||||
$cats = [];
|
||||
foreach ( $params['categories'] as $cat ) {
|
||||
$title = Title::newFromText( $cat );
|
||||
|
|
@ -79,6 +79,10 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
|
|||
$cats[] = $title->getDBkey();
|
||||
}
|
||||
}
|
||||
if ( !$cats ) {
|
||||
// No titles so no results
|
||||
return;
|
||||
}
|
||||
$this->addWhereFld( 'cl_to', $cats );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
|
|||
}
|
||||
$this->addOption( 'LIMIT', $params['limit'] + 1 );
|
||||
|
||||
if ( !is_null( $params['images'] ) ) {
|
||||
if ( $params['images'] ) {
|
||||
$images = [];
|
||||
foreach ( $params['images'] as $img ) {
|
||||
$title = Title::newFromText( $img );
|
||||
|
|
@ -95,6 +95,10 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
|
|||
$images[] = $title->getDBkey();
|
||||
}
|
||||
}
|
||||
if ( !$images ) {
|
||||
// No titles so no results
|
||||
return;
|
||||
}
|
||||
$this->addWhereFld( 'il_to', $images );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
|
|||
$this->addWhereFld( $this->prefix . '_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
|
||||
$this->addWhereFld( $this->prefix . '_namespace', $params['namespace'] );
|
||||
|
||||
if ( !is_null( $params[$this->titlesParam] ) ) {
|
||||
if ( $params[$this->titlesParam] ) {
|
||||
$lb = new LinkBatch;
|
||||
foreach ( $params[$this->titlesParam] as $t ) {
|
||||
$title = Title::newFromText( $t );
|
||||
|
|
@ -102,6 +102,9 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
|
|||
$cond = $lb->constructSet( $this->prefix, $this->getDB() );
|
||||
if ( $cond ) {
|
||||
$this->addWhere( $cond );
|
||||
} else {
|
||||
// No titles so no results
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue