[5.6] Fix cache repository (#26496)

* 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 https://github.com/briannesbitt/Carbon/issues/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 mimum Carbon version

This fixes a problem with working with DateTimeImmutable instances in the cache repository.

Signed-off-by: Dries Vints <dries.vints@gmail.com>
This commit is contained in:
Dries Vints 2018-11-13 15:14:53 +01:00 committed by Taylor Otwell
parent 372dcf3ed1
commit b12feabda7
3 changed files with 3 additions and 3 deletions

View File

@ -23,7 +23,7 @@
"erusev/parsedown": "~1.7",
"league/flysystem": "^1.0.8",
"monolog/monolog": "~1.12",
"nesbot/carbon": "1.25.*",
"nesbot/carbon": "1.26.*",
"psr/container": "~1.0",
"psr/simple-cache": "^1.0",
"ramsey/uuid": "^3.7",

View File

@ -552,7 +552,7 @@ class Repository implements CacheContract, ArrayAccess
$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;

View File

@ -18,7 +18,7 @@
"ext-mbstring": "*",
"doctrine/inflector": "~1.1",
"illuminate/contracts": "5.6.*",
"nesbot/carbon": "1.25.*"
"nesbot/carbon": "1.26.*"
},
"conflict": {
"tightenco/collect": "<5.5.33"