Merge "Use SettingsBuilder::overrideConfigValue to overwrite a config value"

This commit is contained in:
jenkins-bot 2024-11-10 14:01:10 +00:00 committed by Gerrit Code Review
commit 54716dd00c

View file

@ -17,9 +17,11 @@ use MediaWiki\Hook\EditFilterHook;
use MediaWiki\Hook\MovePageCheckPermissionsHook;
use MediaWiki\Hook\TitleGetEditNoticesHook;
use MediaWiki\Html\Html;
use MediaWiki\MainConfigNames;
use MediaWiki\Permissions\GrantsInfo;
use MediaWiki\Permissions\Hook\GetUserPermissionsErrorsExpensiveHook;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Settings\SettingsBuilder;
use MediaWiki\Status\Status;
use MediaWiki\Storage\EditResult;
use MediaWiki\Storage\Hook\PageSaveCompleteHook;
@ -43,13 +45,14 @@ class Hooks implements
PageSaveCompleteHook
{
public static function onRegistration() {
global $wgGrantRiskGroups;
public static function onRegistration( array $extInfo, SettingsBuilder $settings ) {
$grantRiskGroups = $settings->getConfig()->get( MainConfigNames::GrantRiskGroups );
// Make sure the risk rating is at least 'security'. TitleBlacklist adds the
// tboverride-account right to the createaccount grant, which makes it possible
// to use it for social engineering attacks with restricted usernames.
if ( $wgGrantRiskGroups['createaccount'] !== GrantsInfo::RISK_INTERNAL ) {
$wgGrantRiskGroups['createaccount'] = GrantsInfo::RISK_SECURITY;
if ( $grantRiskGroups['createaccount'] !== GrantsInfo::RISK_INTERNAL ) {
$grantRiskGroups['createaccount'] = GrantsInfo::RISK_SECURITY;
$settings->overrideConfigValue( MainConfigNames::GrantRiskGroups, $grantRiskGroups );
}
}