MediaWiki
master
Toggle main menu visibility
FeatureShutdown.php
Go to the documentation of this file.
1
<?php
6
7
namespace
MediaWiki
;
8
9
use
MediaWiki\Config\ServiceOptions
;
10
17
class
FeatureShutdown
{
19
public
const
CONSTRUCTOR_OPTIONS
= [
20
MainConfigNames::FeatureShutdown
,
21
];
22
24
private
$shutdowns;
25
29
public
function
__construct
(
ServiceOptions
$options ) {
30
$options->
assertRequiredOptions
( self::CONSTRUCTOR_OPTIONS );
31
$this->shutdowns = $options->
get
(
MainConfigNames::FeatureShutdown
);
32
}
33
38
public
function
findForFeature
(
string
$featureName ): ?array {
39
if
( !isset( $this->shutdowns[$featureName] ) ) {
40
return
null
;
41
}
42
43
$time = time();
44
foreach
( $this->shutdowns[$featureName] as $shutdown ) {
45
if
( strtotime( $shutdown[
'start'
] ) > $time || strtotime( $shutdown[
'end'
] ) < $time ) {
46
continue
;
47
}
48
49
if
( isset( $shutdown[
'percentage'
] ) && rand( 0, 99 ) > $shutdown[
'percentage'
] ) {
50
continue
;
51
}
52
53
return
$shutdown;
54
}
55
56
return
null
;
57
}
58
}
if
if(!defined('MW_SETUP_CALLBACK'))
Definition
WebStart.php:72
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition
ServiceOptions.php:27
MediaWiki\Config\ServiceOptions\assertRequiredOptions
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Definition
ServiceOptions.php:70
MediaWiki\Config\ServiceOptions\get
get( $key)
Definition
ServiceOptions.php:92
MediaWiki\FeatureShutdown
Helper to check if certain features should be temporarily disabled.
Definition
FeatureShutdown.php:17
MediaWiki\FeatureShutdown\findForFeature
findForFeature(string $featureName)
Definition
FeatureShutdown.php:38
MediaWiki\FeatureShutdown\__construct
__construct(ServiceOptions $options)
Definition
FeatureShutdown.php:29
MediaWiki\FeatureShutdown\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition
FeatureShutdown.php:19
MediaWiki\MainConfigNames\FeatureShutdown
const FeatureShutdown
Name constant for the FeatureShutdown setting, for use with Config\get().
Definition
MainConfigNames.php:4673
MediaWiki
includes
FeatureShutdown.php
Generated on
for MediaWiki by
1.18.0