Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| RegistrationCallback | n/a |
0 / 0 |
n/a |
0 / 0 |
12 | n/a |
0 / 0 |
|||
| onRegistration | n/a |
0 / 0 |
n/a |
0 / 0 |
12 | |||||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\AbuseFilter\Hooks\Handlers; |
| 4 | |
| 5 | /** |
| 6 | * This class runs a callback when the extension is registered, right after configuration has been |
| 7 | * loaded (not really a hook, but almost). |
| 8 | * @codeCoverageIgnore Mainly deprecation warnings and other things that can be tested by running the updater |
| 9 | */ |
| 10 | class RegistrationCallback { |
| 11 | |
| 12 | public static function onRegistration(): void { |
| 13 | global $wgAbuseFilterProfile, |
| 14 | $wgAbuseFilterProfiling, $wgAbuseFilterPrivateLog, $wgAbuseFilterForceSummary, |
| 15 | $wgGroupPermissions, $wgAbuseFilterRestrictions, $wgAbuseFilterDisallowGlobalLocalBlocks, |
| 16 | $wgAbuseFilterActionRestrictions, $wgAbuseFilterLocallyDisabledGlobalActions; |
| 17 | |
| 18 | // @todo Remove this in a future release (added in 1.33) |
| 19 | if ( $wgAbuseFilterProfile !== null || $wgAbuseFilterProfiling !== null ) { |
| 20 | wfWarn( '$wgAbuseFilterProfile and $wgAbuseFilterProfiling have been removed and ' . |
| 21 | 'profiling is now enabled by default.' ); |
| 22 | } |
| 23 | |
| 24 | if ( $wgAbuseFilterPrivateLog !== null ) { |
| 25 | global $wgAbuseFilterLogPrivateDetailsAccess; |
| 26 | $wgAbuseFilterLogPrivateDetailsAccess = $wgAbuseFilterPrivateLog; |
| 27 | wfWarn( '$wgAbuseFilterPrivateLog has been renamed to $wgAbuseFilterLogPrivateDetailsAccess. ' . |
| 28 | 'Please make the change in your settings; the format is identical.' |
| 29 | ); |
| 30 | } |
| 31 | if ( $wgAbuseFilterForceSummary !== null ) { |
| 32 | global $wgAbuseFilterPrivateDetailsForceReason; |
| 33 | $wgAbuseFilterPrivateDetailsForceReason = $wgAbuseFilterForceSummary; |
| 34 | wfWarn( '$wgAbuseFilterForceSummary has been renamed to ' . |
| 35 | '$wgAbuseFilterPrivateDetailsForceReason. Please make the change in your settings; ' . |
| 36 | 'the format is identical.' |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | $found = false; |
| 41 | foreach ( $wgGroupPermissions as &$perms ) { |
| 42 | if ( array_key_exists( 'abusefilter-private', $perms ) ) { |
| 43 | $perms['abusefilter-privatedetails'] = $perms[ 'abusefilter-private' ]; |
| 44 | unset( $perms[ 'abusefilter-private' ] ); |
| 45 | $found = true; |
| 46 | } |
| 47 | if ( array_key_exists( 'abusefilter-private-log', $perms ) ) { |
| 48 | $perms['abusefilter-privatedetails-log'] = $perms[ 'abusefilter-private-log' ]; |
| 49 | unset( $perms[ 'abusefilter-private-log' ] ); |
| 50 | $found = true; |
| 51 | } |
| 52 | } |
| 53 | unset( $perms ); |
| 54 | |
| 55 | if ( $found ) { |
| 56 | wfWarn( 'The group permissions "abusefilter-private-log" and "abusefilter-private" have ' . |
| 57 | 'been renamed, respectively, to "abusefilter-privatedetails-log" and ' . |
| 58 | '"abusefilter-privatedetails". Please update the names in your settings.' |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | // @todo Remove this in a future release (added in 1.36) |
| 63 | if ( $wgAbuseFilterDisallowGlobalLocalBlocks !== null ) { |
| 64 | wfWarn( '$wgAbuseFilterDisallowGlobalLocalBlocks has been removed and replaced by ' . |
| 65 | '$wgAbuseFilterLocallyDisabledGlobalActions. You can now specify which actions to disable. ' . |
| 66 | 'If you had set the former to true, you should set to true all of the actions in ' . |
| 67 | '$wgAbuseFilterRestrictions (if you were manually setting the variable) or ' . |
| 68 | 'ConsequencesRegistry::DANGEROUS_ACTIONS. ' . |
| 69 | 'If you had set it to false (or left the default), just remove it from your wiki settings.' |
| 70 | ); |
| 71 | if ( $wgAbuseFilterDisallowGlobalLocalBlocks === true ) { |
| 72 | $wgAbuseFilterLocallyDisabledGlobalActions = [ |
| 73 | 'throttle' => false, |
| 74 | 'warn' => false, |
| 75 | 'disallow' => false, |
| 76 | 'blockautopromote' => true, |
| 77 | 'block' => true, |
| 78 | 'rangeblock' => true, |
| 79 | 'degroup' => true, |
| 80 | 'tag' => false |
| 81 | ]; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // @todo Remove this in a future release (added in 1.36) |
| 86 | if ( $wgAbuseFilterRestrictions !== null ) { |
| 87 | wfWarn( '$wgAbuseFilterRestrictions has been renamed to $wgAbuseFilterActionRestrictions.' ); |
| 88 | $wgAbuseFilterActionRestrictions = $wgAbuseFilterRestrictions; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | } |