mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Merge "Avoid counting where not necessary"
This commit is contained in:
commit
855497c3ba
|
@ -573,7 +573,7 @@ abstract class EchoDiscussionParser {
|
|||
}
|
||||
}
|
||||
}
|
||||
} elseif ( count( $signedUsers ) >= 1 ) {
|
||||
} elseif ( $signedUsers !== [] ) {
|
||||
$actions[] = [
|
||||
'type' => 'unknown-multi-signed-addition',
|
||||
'content' => $content,
|
||||
|
|
|
@ -109,7 +109,7 @@ class EchoHooks {
|
|||
}
|
||||
}
|
||||
// if test files exist for given module, create a corresponding test module
|
||||
if ( count( $testFiles ) > 0 ) {
|
||||
if ( $testFiles !== [] ) {
|
||||
$testModules['qunit']["$key.tests"] = $testModuleBoilerplate + [
|
||||
'dependencies' => [ $key ],
|
||||
'scripts' => $testFiles,
|
||||
|
@ -1288,7 +1288,7 @@ class EchoHooks {
|
|||
|
||||
$ids = self::mapToInt( $ids );
|
||||
|
||||
if ( count( $ids ) > 0 ) {
|
||||
if ( $ids !== [] ) {
|
||||
$user->setOption( 'echo-notifications-blacklist', $ids );
|
||||
$options['echo-notifications-blacklist'] = implode( "\n", $user->getOption( 'echo-notifications-blacklist' ) );
|
||||
} else {
|
||||
|
|
|
@ -304,7 +304,7 @@ class MWEchoNotifUser {
|
|||
$categoryMap = $attributeManager->getEventsByCategory();
|
||||
$usertalkTypes = $categoryMap['edit-user-talk'];
|
||||
$unreadEditUserTalk = $this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, null, DB_MASTER );
|
||||
if ( count( $unreadEditUserTalk ) === 0 ) {
|
||||
if ( $unreadEditUserTalk === [] ) {
|
||||
$this->mUser->setNewtalk( false );
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ class MWEchoNotifUser {
|
|||
$categoryMap = $attributeManager->getEventsByCategory();
|
||||
$usertalkTypes = $categoryMap['edit-user-talk'];
|
||||
$unreadEditUserTalk = $this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, null, DB_MASTER );
|
||||
if ( count( $unreadEditUserTalk ) > 0 ) {
|
||||
if ( $unreadEditUserTalk !== [] ) {
|
||||
$this->mUser->setNewtalk( true );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -398,7 +398,7 @@ class ApiEchoNotifications extends ApiCrossWikiBase {
|
|||
}
|
||||
}
|
||||
|
||||
if ( $count === 0 || count( $wikis ) === 0 ) {
|
||||
if ( $count === 0 || $wikis === [] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,9 +75,9 @@ class EchoUserRightsPresentationModel extends EchoEventPresentationModel {
|
|||
public function getPrimaryLink() {
|
||||
$addedGroups = array_values( $this->event->getExtraParam( 'add', [] ) );
|
||||
$removedGroups = array_values( $this->event->getExtraParam( 'remove', [] ) );
|
||||
if ( count( $addedGroups ) >= 1 && count( $removedGroups ) === 0 ) {
|
||||
if ( $addedGroups !== [] && $removedGroups === [] ) {
|
||||
$fragment = $addedGroups[0];
|
||||
} elseif ( count( $addedGroups ) === 0 && count( $removedGroups ) >= 1 ) {
|
||||
} elseif ( $addedGroups === [] && $removedGroups !== [] ) {
|
||||
$fragment = $removedGroups[0];
|
||||
} else {
|
||||
$fragment = '';
|
||||
|
|
|
@ -159,7 +159,7 @@ class SpecialNotifications extends SpecialPage {
|
|||
$heading->appendContent( $dateTitle );
|
||||
|
||||
// Mark all read button
|
||||
if ( count( $data[ 'unread' ] ) > 0 ) {
|
||||
if ( $data[ 'unread' ] !== [] ) {
|
||||
// tell the UI to show 'unread' notifications only (instead of 'all')
|
||||
$out->addJsConfigVars( 'wgEchoReadState', 'unread' );
|
||||
|
||||
|
|
2
tests/phpunit/cache/TitleLocalCacheTest.php
vendored
2
tests/phpunit/cache/TitleLocalCacheTest.php
vendored
|
@ -81,7 +81,7 @@ class EchoTitleLocalCacheTest extends MediaWikiTestCase {
|
|||
$lookups->setValue( $cache, [ '1' => '1', '2' => '2' ] );
|
||||
|
||||
$cache->clearAll();
|
||||
$this->assertTrue( count( $cache->getLookups() ) == 0 );
|
||||
$this->assertEmpty( $cache->getLookups() );
|
||||
$this->assertEquals( false, $cache->getTargets()->get( 1 ) );
|
||||
$this->assertEquals( false, $cache->getTargets()->get( '1' ) );
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ class EchoNotificationMapperTest extends MediaWikiTestCase {
|
|||
|
||||
$notifMapper = new EchoNotificationMapper( $this->mockMWEchoDbFactory( [ 'select' => $dbResult ] ) );
|
||||
$res = $notifMapper->fetchUnreadByUser( $this->mockUser(), 10, null, '', [ 'test_event' ] );
|
||||
$this->assertTrue( is_array( $res ) );
|
||||
$this->assertGreaterThan( 0, count( $res ) );
|
||||
$this->assertInternalType( 'array', $res );
|
||||
$this->assertNotEmpty( $res );
|
||||
foreach ( $res as $row ) {
|
||||
$this->assertInstanceOf( 'EchoNotification', $row );
|
||||
}
|
||||
|
@ -93,8 +93,8 @@ class EchoNotificationMapperTest extends MediaWikiTestCase {
|
|||
)
|
||||
);
|
||||
$res = $notifMapper->fetchByUser( $this->mockUser(), 10, '', [ 'test_event' ] );
|
||||
$this->assertTrue( is_array( $res ) );
|
||||
$this->assertGreaterThan( 0, count( $res ) );
|
||||
$this->assertInternalType( 'array', $res );
|
||||
$this->assertNotEmpty( $res );
|
||||
foreach ( $res as $row ) {
|
||||
$this->assertInstanceOf( 'EchoNotification', $row );
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class EchoNotificationTest extends MediaWikiTestCase {
|
|||
$notif = EchoNotification::newFromRow( (object)$row, [
|
||||
EchoTargetPage::newFromRow( (object)$this->mockTargetPageRow() )
|
||||
] );
|
||||
$this->assertGreaterThan( 0, count( $notif->getTargetPages() ) );
|
||||
$this->assertNotEmpty( $notif->getTargetPages() );
|
||||
foreach ( $notif->getTargetPages() as $targetPage ) {
|
||||
$this->assertInstanceOf( 'EchoTargetPage', $targetPage );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue