Skip to content

Commit

Permalink
fix: get rid of (some) PHP deprecation warnings
Browse files Browse the repository at this point in the history
- CakeResponse.php strotime() and preg_split() warnings
  • Loading branch information
Jan Pešek authored and diegosurita committed Jan 26, 2024
1 parent 519b120 commit d3c0f5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ It means that composer will look at `master` branch of repository configured und

## Changelog

### 2024-01-19

- `strotime()` and `preg_split()` in CakeResponse deprecation warning fixes (passing null)

### 2024-01-11

- `preg_replace` deprecation warning fixes (passing null instead of `string`)
Expand Down
12 changes: 6 additions & 6 deletions lib/Cake/Network/CakeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -1164,19 +1164,19 @@ public function checkNotModified(CakeRequest $request) {
$ifNoneMatchHeader = $request->header('If-None-Match');
$etags = array();
if (is_string($ifNoneMatchHeader)) {
$etags = preg_split(
pattern: '/\s*,\s*/',
subject: $ifNoneMatchHeader,
flags: PREG_SPLIT_NO_EMPTY
);
$etags = preg_split('/\s*,\s*/', $ifNoneMatchHeader, 0, PREG_SPLIT_NO_EMPTY);
}
$modifiedSince = $request->header('If-Modified-Since');
$checks = array();
if ($responseTag = $this->etag()) {
$checks[] = in_array('*', $etags) || in_array($responseTag, $etags);
}
if ($modifiedSince) {
$checks[] = strtotime($this->modified()) === strtotime($modifiedSince);
if ($this->modified() === null) {
$checks[] = strtotime($modifiedSince) === false;
} else {
$checks[] = strtotime($this->modified()) === strtotime($modifiedSince);
}
}
if (empty($checks)) {
return false;
Expand Down

0 comments on commit d3c0f5c

Please sign in to comment.