mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts
synced 2024-11-27 09:30:09 +00:00
Remove not needed count() and "return true" from hook handlers
This patch fixes two styls issues I could not separate: * Hook handler functions do not need to return true. This is the default anyway, and meaningless. * Counting is possibly expensive and not needed when all we need to know is if an array is empty or not. Change-Id: I460776c981638806a606d9bf88fc8579d6da8c0e
This commit is contained in:
parent
f607ff8d6c
commit
60cd40b975
|
@ -81,7 +81,7 @@ class ApiQueryExtracts extends ApiQueryBase {
|
|||
*/
|
||||
public function execute() {
|
||||
$titles = $this->getPageSet()->getGoodTitles();
|
||||
if ( count( $titles ) == 0 ) {
|
||||
if ( $titles === [] ) {
|
||||
return;
|
||||
}
|
||||
$isXml = $this->getMain()->isInternalMode()
|
||||
|
|
|
@ -13,13 +13,13 @@ class Hooks {
|
|||
/**
|
||||
* ApiOpenSearchSuggest hook handler
|
||||
* @param array &$results Array of search results
|
||||
* @return bool
|
||||
*/
|
||||
public static function onApiOpenSearchSuggest( &$results ) {
|
||||
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'textextracts' );
|
||||
if ( !$config->get( 'ExtractsExtendOpenSearchXml' ) || !count( $results ) ) {
|
||||
return true;
|
||||
if ( !$config->get( 'ExtractsExtendOpenSearchXml' ) || $results === [] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( array_chunk( array_keys( $results ), ApiBase::LIMIT_SML1 ) as $pageIds ) {
|
||||
$api = new ApiMain( new FauxRequest(
|
||||
[
|
||||
|
@ -43,6 +43,5 @@ class Hooks {
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue