Code Duplication    Length = 15-19 lines in 2 locations

includes/user/User.php 2 locations

@@ 1396-1410 (lines=15) @@
1393
	/**
1394
	 * Load the groups from the database if they aren't already loaded.
1395
	 */
1396
	private function loadGroups() {
1397
		if ( is_null( $this->mGroups ) ) {
1398
			$db = ( $this->queryFlagsUsed & self::READ_LATEST )
1399
				? wfGetDB( DB_MASTER )
1400
				: wfGetDB( DB_SLAVE );
1401
			$res = $db->select( 'user_groups',
1402
				[ 'ug_group' ],
1403
				[ 'ug_user' => $this->mId ],
1404
				__METHOD__ );
1405
			$this->mGroups = [];
1406
			foreach ( $res as $row ) {
1407
				$this->mGroups[] = $row->ug_group;
1408
			}
1409
		}
1410
	}
1411
1412
	/**
1413
	 * Add the user to the group if he/she meets given criteria.
@@ 3329-3347 (lines=19) @@
3326
	 *
3327
	 * @return array Names of the groups the user has belonged to.
3328
	 */
3329
	public function getFormerGroups() {
3330
		$this->load();
3331
3332
		if ( is_null( $this->mFormerGroups ) ) {
3333
			$db = ( $this->queryFlagsUsed & self::READ_LATEST )
3334
				? wfGetDB( DB_MASTER )
3335
				: wfGetDB( DB_SLAVE );
3336
			$res = $db->select( 'user_former_groups',
3337
				[ 'ufg_group' ],
3338
				[ 'ufg_user' => $this->mId ],
3339
				__METHOD__ );
3340
			$this->mFormerGroups = [];
3341
			foreach ( $res as $row ) {
3342
				$this->mFormerGroups[] = $row->ufg_group;
3343
			}
3344
		}
3345
3346
		return $this->mFormerGroups;
3347
	}
3348
3349
	/**
3350
	 * Get the user's edit count.