MediaWiki master
FeatureShutdown.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki;
22
24
33 public const CONSTRUCTOR_OPTIONS = [
34 'FeatureShutdown',
35 ];
36
38 private $shutdowns;
39
43 public function __construct( ServiceOptions $options ) {
44 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
45 $this->shutdowns = $options->get( 'FeatureShutdown' );
46 }
47
52 public function findForFeature( string $featureName ): ?array {
53 if ( !isset( $this->shutdowns[$featureName] ) ) {
54 return null;
55 }
56
57 $time = time();
58 foreach ( $this->shutdowns[$featureName] as $shutdown ) {
59 if ( strtotime( $shutdown['start'] ) > $time || strtotime( $shutdown['end'] ) < $time ) {
60 continue;
61 }
62
63 if ( isset( $shutdown['percentage'] ) && rand( 0, 99 ) > $shutdown['percentage'] ) {
64 continue;
65 }
66
67 return $shutdown;
68 }
69
70 return null;
71 }
72}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:82
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Helper to check if certain features should be temporarily disabled.
findForFeature(string $featureName)
__construct(ServiceOptions $options)
A helper class for throttling authentication attempts.