Skip to content

Commit 765e1bd

Browse files
feat(*): Fix some psalm warning
1 parent f1d4e4d commit 765e1bd

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77

8+
## [0.34.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v0.34.0) - 2022-11-24
9+
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v0.33.0...v0.34.0)
10+
11+
### Changed
12+
- Do not cache bypass decision in stream mode
13+
- Replace unauthorized chars by underscore `_` in cache key
14+
15+
### Fixed
16+
- Fix decision duration parsing when it uses milliseconds
17+
18+
---
19+
20+
821
## [0.33.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v0.33.0) - 2022-11-10
922
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v0.32.0...v0.33.0)
1023

src/AbstractCache.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ protected function addRemediationToCacheItem(
292292
]; // erase previous decision with the same id
293293

294294
// Build the item lifetime in cache and sort remediations by priority
295-
$maxLifetime = max(array_column($remediations, 1));
295+
$exps = array_column($remediations, 1);
296+
$maxLifetime = $exps ? max($exps) : 0;
296297
$prioritizedRemediations = Remediation::sortRemediationByPriority($remediations);
297298

298299
$item->set($prioritizedRemediations);
@@ -427,7 +428,7 @@ protected function miss(string $value, string $cacheScope): string
427428
}
428429
}
429430
// In stream mode, we do not save bypass decision in cache
430-
if($this->streamMode && !$decisions){
431+
if ($this->streamMode && !$decisions) {
431432
return Constants::REMEDIATION_BYPASS;
432433
}
433434

@@ -469,7 +470,8 @@ protected function removeDecisionFromRemediationItem(string $cacheKey, int $deci
469470
return true;
470471
}
471472
// Build the item lifetime in cache and sort remediations by priority
472-
$maxLifetime = max(array_column($remediations, 1));
473+
$exps = array_column($remediations, 1);
474+
$maxLifetime = $exps ? max($exps) : 0;
473475
$cacheContent = Remediation::sortRemediationByPriority($remediations);
474476
$item->expiresAt(new DateTime('@' . $maxLifetime));
475477
$item->set($cacheContent);

src/RestClient/Curl.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ public function request(
5151
}
5252

5353
/**
54-
* @param $handle
55-
*
5654
* @return bool|string
5755
*/
5856
protected function exec($handle)
@@ -61,8 +59,6 @@ protected function exec($handle)
6159
}
6260

6361
/**
64-
* @param $handle
65-
*
6662
* @return mixed
6763
*/
6864
protected function getResponseHttpCode($handle)

0 commit comments

Comments
 (0)