mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge remote-tracking branch 'origin/4.0' into 4.1
This commit is contained in:
commit
c2123f772f
@ -1181,8 +1181,6 @@ warnings:
|
||||
message: 'Renamed to restoreFormState()'
|
||||
'SilverStripe\Forms\Form->resetValidation()':
|
||||
message: 'Renamed to clearFormState()'
|
||||
'SilverStripe\Forms\Form->transformTo()':
|
||||
message: 'Removed'
|
||||
'SilverStripe\Forms\Form->callfieldmethod()':
|
||||
message: 'Removed'
|
||||
'SilverStripe\Forms\Form->addErrorMessage()':
|
||||
|
@ -43,7 +43,8 @@ class CanonicalURLMiddleware implements HTTPMiddleware
|
||||
|
||||
/**
|
||||
* Environment variables this middleware is enabled in, or a fixed boolean flag to
|
||||
* apply to all environments
|
||||
* apply to all environments. cli is disabled unless present here as `cli`, or set to true
|
||||
* to force enabled.
|
||||
*
|
||||
* @var array|bool
|
||||
*/
|
||||
@ -292,7 +293,7 @@ class CanonicalURLMiddleware implements HTTPMiddleware
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enabled flag, or list of environments to enable in
|
||||
* Get enabled flag, or list of environments to enable in.
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
@ -302,6 +303,10 @@ class CanonicalURLMiddleware implements HTTPMiddleware
|
||||
}
|
||||
|
||||
/**
|
||||
* Set enabled flag, or list of environments to enable in.
|
||||
* Note: CLI is disabled by default, so `"cli"(string)` or `true(bool)` should be specified if you wish to
|
||||
* enable for testing.
|
||||
*
|
||||
* @param array|bool $enabledEnvs
|
||||
* @return $this
|
||||
*/
|
||||
@ -326,6 +331,13 @@ class CanonicalURLMiddleware implements HTTPMiddleware
|
||||
if (is_bool($enabledEnvs)) {
|
||||
return $enabledEnvs;
|
||||
}
|
||||
|
||||
// If CLI, EnabledEnvs must contain CLI
|
||||
if (Director::is_cli() && !in_array('cli', $enabledEnvs)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check other envs
|
||||
return empty($enabledEnvs) || in_array(Director::get_environment_type(), $enabledEnvs);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user