Merge "Drop Autopromote class, deprecated since 1.35"
This commit is contained in:
commit
e6c71e9877
4 changed files with 2 additions and 137 deletions
|
|
@ -87,6 +87,8 @@ because of Phabricator reports.
|
|||
handler without changing the status, the edit form will now be displayed.
|
||||
* User::clearNotification() which had been deprecated in 1.35 has been removed.
|
||||
Use WatchlistManager::clearTitleUserNotification() instead.
|
||||
* Autopromote class, deprecated since 1.35, was removed. Use
|
||||
UserGroupManager instead.
|
||||
|
||||
=== Deprecations in 1.37 ===
|
||||
* JobQueue::getWiki, deprecated in 1.33, now emits deprecation warnings.
|
||||
|
|
|
|||
|
|
@ -170,7 +170,6 @@ $wgAutoloadLocalClasses = [
|
|||
'AuthManagerSpecialPage' => __DIR__ . '/includes/specialpage/AuthManagerSpecialPage.php',
|
||||
'AutoCommitUpdate' => __DIR__ . '/includes/deferred/AutoCommitUpdate.php',
|
||||
'AutoloadGenerator' => __DIR__ . '/includes/utils/AutoloadGenerator.php',
|
||||
'Autopromote' => __DIR__ . '/includes/Autopromote.php',
|
||||
'BacklinkCache' => __DIR__ . '/includes/cache/BacklinkCache.php',
|
||||
'BacklinkJobUtils' => __DIR__ . '/includes/jobqueue/utils/BacklinkJobUtils.php',
|
||||
'BackupDumper' => __DIR__ . '/maintenance/includes/BackupDumper.php',
|
||||
|
|
|
|||
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Automatic user rights promotion based on conditions specified
|
||||
* in $wgAutopromote.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* This class checks if user can get extra rights
|
||||
* because of conditions specified in $wgAutopromote
|
||||
* @deprecated since 1.35 Use UserGroupManager instead.
|
||||
*/
|
||||
class Autopromote {
|
||||
/**
|
||||
* Get the groups for the given user based on $wgAutopromote.
|
||||
*
|
||||
* @param User $user The user to get the groups for
|
||||
* @return string[] Array of groups to promote to.
|
||||
*
|
||||
* @deprecated since 1.35 (hard deprecated since 1.36). Use UserGroupManager::getUserAutopromoteGroups.
|
||||
*/
|
||||
public static function getAutopromoteGroups( User $user ) {
|
||||
wfDeprecated( __METHOD__, '1.35' );
|
||||
|
||||
return MediaWikiServices::getInstance()
|
||||
->getUserGroupManager()
|
||||
->getUserAutopromoteGroups( $user );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the groups for the given user based on the given criteria.
|
||||
*
|
||||
* Does not return groups the user already belongs to or has once belonged.
|
||||
*
|
||||
*
|
||||
* @param User $user The user to get the groups for
|
||||
* @param string $event Key in $wgAutopromoteOnce (each one has groups/criteria)
|
||||
*
|
||||
* @return string[] Groups the user should be promoted to.
|
||||
*
|
||||
* @see $wgAutopromoteOnce
|
||||
*
|
||||
* @deprecated since 1.35 (hard deprecated since 1.36). Use UserGroupManager::getUserAutopromoteOnceGroups.
|
||||
*/
|
||||
public static function getAutopromoteOnceGroups( User $user, $event ) {
|
||||
wfDeprecated( __METHOD__, '1.35' );
|
||||
|
||||
return MediaWikiServices::getInstance()
|
||||
->getUserGroupManager()
|
||||
->getUserAutopromoteOnceGroups( $user, $event );
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\User\UserEditTracker;
|
||||
|
||||
/**
|
||||
* @covers Autopromote
|
||||
*/
|
||||
class AutopromoteTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
/**
|
||||
* Autopromote must not perform edit count lookup if requirement is 0 or invalid (T157718).
|
||||
*
|
||||
* @see Autopromote::getAutopromoteGroups()
|
||||
* @dataProvider provideEditCountsAndRequirements
|
||||
* @param int $editCount edit count of user to be checked by Autopromote
|
||||
* @param int $requirement edit count required to autopromote user
|
||||
*/
|
||||
public function testEditCountLookupIsSkippedIfRequirementIsZero( $editCount, $requirement ) {
|
||||
$this->hideDeprecated( 'Autopromote::getAutopromoteGroups' );
|
||||
|
||||
$this->setMwGlobals( [
|
||||
'wgAutopromote' => [
|
||||
'autoconfirmed' => [ APCOND_EDITCOUNT, $requirement ]
|
||||
]
|
||||
] );
|
||||
|
||||
$user = $this->getTestUser()->getUser();
|
||||
$userEditTrackerMock = $this->createNoOpMock(
|
||||
UserEditTracker::class,
|
||||
[ 'getUserEditCount' ]
|
||||
);
|
||||
if ( $requirement > 0 ) {
|
||||
$userEditTrackerMock->expects( $this->once() )
|
||||
->method( 'getUserEditCount' )
|
||||
->with( $user )
|
||||
->willReturn( $editCount );
|
||||
} else {
|
||||
$userEditTrackerMock->expects( $this->never() )
|
||||
->method( 'getUserEditCount' );
|
||||
}
|
||||
$this->setService( 'UserEditTracker', $userEditTrackerMock );
|
||||
|
||||
$result = Autopromote::getAutopromoteGroups( $user );
|
||||
if ( $editCount >= $requirement ) {
|
||||
$this->assertContains(
|
||||
'autoconfirmed',
|
||||
$result,
|
||||
'User must be promoted if they meet edit count requirement'
|
||||
);
|
||||
} else {
|
||||
$this->assertNotContains(
|
||||
'autoconfirmed',
|
||||
$result,
|
||||
'User must not be promoted if they fail edit count requirement'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function provideEditCountsAndRequirements() {
|
||||
return [
|
||||
'user with sufficient editcount' => [ 100, 10 ],
|
||||
'user with insufficient editcount' => [ 4, 10 ],
|
||||
'edit count requirement set to 0' => [ 1, 0 ],
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue