Skip to content

Commit

Permalink
[5.5] Fix cache repository (#26497)
Browse files Browse the repository at this point in the history
* Fix a bug with PHP 7.2.12

PHP 7.2.12 broke the way Carbon's diffInSeconds method works. Using diffInRealSeconds instead fixes the problem.

See briannesbitt/Carbon#1503

* Clean up diff check in cache repository

We can pass the duration here directly.

Signed-off-by: Dries Vints <dries.vints@gmail.com>

* Upgrade minimum Carbon requirement

We need this for the diffInRealSeconds method.

Signed-off-by: Dries Vints <dries.vints@gmail.com>
  • Loading branch information
driesvints authored and taylorotwell committed Nov 13, 2018
1 parent da9ba5c commit a36b3a0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"league/flysystem": "^1.0.8",
"monolog/monolog": "~1.12",
"mtdowling/cron-expression": "~1.0",
"nesbot/carbon": "^1.24.1",
"nesbot/carbon": "^1.26.0",
"psr/container": "~1.0",
"psr/simple-cache": "^1.0",
"ramsey/uuid": "~3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ protected function getMinutes($duration)
$duration = $this->parseDateInterval($duration);

if ($duration instanceof DateTimeInterface) {
$duration = Carbon::now()->diffInSeconds(Carbon::createFromTimestamp($duration->getTimestamp()), false) / 60;
$duration = Carbon::now()->diffInRealSeconds($duration, false) / 60;
}

return (int) ($duration * 60) > 0 ? $duration : null;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"ext-mbstring": "*",
"doctrine/inflector": "~1.1",
"illuminate/contracts": "5.5.*",
"nesbot/carbon": "^1.24.1"
"nesbot/carbon": "^1.26.0"
},
"replace": {
"tightenco/collect": "<5.5.33"
Expand Down

0 comments on commit a36b3a0

Please sign in to comment.