Fixes #14033: Fixed yii\filters\AccessRule::matchIp() erroring in case IP is not defined under HHVM

This commit is contained in:
Kolyunya
2017-04-22 19:42:52 +03:00
committed by Alexander Makarov
parent d786b78f25
commit 1e65fc29ed
3 changed files with 18 additions and 2 deletions

View File

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.12 under development
--------------------------
- Bug #14033: Fixed `yii\filters\AccessRule::matchIp()` erroring in case IP is not defined under HHVM (Kolyunya)
- Bug #13848: `yii\di\Instance::ensure()` wasn't throwing an exception when `$type` is specified and `$reference` object isn't instance of `$type` (c-jonua)
- Enh #13226: `yii cache` command now warns about the fact that it's not able to flush APC cache from console (samdark)
- Bug #13689: Fixed handling of errors in closures (mikehaertl)

View File

@ -165,7 +165,7 @@ class AccessRule extends Component
}
/**
* @param string $ip the IP address
* @param string|null $ip the IP address
* @return bool whether the rule applies to the IP address
*/
protected function matchIP($ip)
@ -174,7 +174,14 @@ class AccessRule extends Component
return true;
}
foreach ($this->ips as $rule) {
if ($rule === '*' || $rule === $ip || (($pos = strpos($rule, '*')) !== false && !strncmp($ip, $rule, $pos))) {
if ($rule === '*' ||
$rule === $ip ||
(
$ip !== null &&
($pos = strpos($rule, '*')) !== false &&
strncmp($ip, $rule, $pos) === 0
)
) {
return true;
}
}