Skip to content

Commit 7c185dd

Browse files
committed
Merge remote-tracking branch 'upstream/8.x' into 8.x
2 parents 1bc1d8d + dffcec0 commit 7c185dd

File tree

11 files changed

+59
-9
lines changed

11 files changed

+59
-9
lines changed

src/Illuminate/Cache/Repository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ protected function getSeconds($ttl)
529529
$duration = Carbon::now()->diffInRealSeconds($duration, false);
530530
}
531531

532-
return (int) $duration > 0 ? $duration : 0;
532+
return (int) ($duration > 0 ? $duration : 0);
533533
}
534534

535535
/**

src/Illuminate/Collections/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,8 @@ public function nth($step, $offset = 0)
806806

807807
$position = 0;
808808

809-
foreach ($this->items as $item) {
810-
if ($position % $step === $offset) {
809+
foreach ($this->slice($offset)->items as $item) {
810+
if ($position % $step === 0) {
811811
$new[] = $item;
812812
}
813813

src/Illuminate/Collections/LazyCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,8 @@ public function nth($step, $offset = 0)
796796
return new static(function () use ($step, $offset) {
797797
$position = 0;
798798

799-
foreach ($this as $item) {
800-
if ($position % $step === $offset) {
799+
foreach ($this->slice($offset) as $item) {
800+
if ($position % $step === 0) {
801801
yield $item;
802802
}
803803

src/Illuminate/Database/Connection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,8 @@ protected function reconnectIfMissingConnection()
825825
public function disconnect()
826826
{
827827
$this->setPdo(null)->setReadPdo(null);
828+
829+
$this->doctrineConnection = null;
828830
}
829831

830832
/**

src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,10 @@ protected function handleLazyLoadingViolation($key)
519519
return call_user_func(static::$lazyLoadingViolationCallback, $this, $key);
520520
}
521521

522+
if (! $this->exists || $this->wasRecentlyCreated) {
523+
return;
524+
}
525+
522526
throw new LazyLoadingViolationException($this, $key);
523527
}
524528

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,10 @@ public static function preventLazyLoading($value = true)
384384
/**
385385
* Register a callback that is responsible for handling lazy loading violations.
386386
*
387-
* @param callable $callback
387+
* @param callable|null $callback
388388
* @return void
389389
*/
390-
public static function handleLazyLoadingViolationUsing(callable $callback)
390+
public static function handleLazyLoadingViolationUsing(?callable $callback)
391391
{
392392
static::$lazyLoadingViolationCallback = $callback;
393393
}

src/Illuminate/Foundation/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
3333
*
3434
* @var string
3535
*/
36-
const VERSION = '8.83.5';
36+
const VERSION = '8.83.6';
3737

3838
/**
3939
* The base path for the Laravel installation.

src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function bootstrap(Application $app)
2424
// First we will see if we have a cache configuration file. If we do, we'll load
2525
// the configuration items from that file so that it is very quick. Otherwise
2626
// we will need to spin through every configuration file and load them all.
27-
if (is_file($cached = $app->getCachedConfigPath())) {
27+
if (file_exists($cached = $app->getCachedConfigPath())) {
2828
$items = require $cached;
2929

3030
$loadedFromCache = true;

tests/Encryption/EncrypterTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ public function testExceptionThrownWhenPayloadIsInvalid()
160160
$e->decrypt($payload);
161161
}
162162

163+
public function testDecryptionExceptionIsThrownWhenUnexpectedTagIsAdded()
164+
{
165+
$this->expectException(DecryptException::class);
166+
$this->expectExceptionMessage('Unable to use tag because the cipher algorithm does not support AEAD.');
167+
168+
$e = new Encrypter(str_repeat('a', 16));
169+
$payload = $e->encrypt('foo');
170+
$decodedPayload = json_decode(base64_decode($payload));
171+
$decodedPayload->tag = 'set-manually';
172+
$e->decrypt(base64_encode(json_encode($decodedPayload)));
173+
}
174+
163175
public function testExceptionThrownWithDifferentKey()
164176
{
165177
$this->expectException(DecryptException::class);

tests/Integration/Database/EloquentStrictLoadingTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ public function testStrictModeWithCustomCallbackOnLazyLoading()
127127
$models = EloquentStrictLoadingTestModel1::get();
128128

129129
$models[0]->modelTwos;
130+
131+
Model::handleLazyLoadingViolationUsing(null);
130132
}
131133

132134
public function testStrictModeWithOverriddenHandlerOnLazyLoading()
@@ -141,6 +143,21 @@ public function testStrictModeWithOverriddenHandlerOnLazyLoading()
141143

142144
$models[0]->modelTwos;
143145
}
146+
147+
public function testStrictModeDoesntThrowAnExceptionOnManuallyMadeModel()
148+
{
149+
$model1 = EloquentStrictLoadingTestModel1WithLocalPreventsLazyLoading::make();
150+
$model2 = EloquentStrictLoadingTestModel2::make();
151+
$model1->modelTwos->push($model2);
152+
153+
$this->assertInstanceOf(Collection::class, $model1->modelTwos);
154+
}
155+
156+
public function testStrictModeDoesntThrowAnExceptionOnRecentlyCreatedModel()
157+
{
158+
$model1 = EloquentStrictLoadingTestModel1WithLocalPreventsLazyLoading::create();
159+
$this->assertInstanceOf(Collection::class, $model1->modelTwos);
160+
}
144161
}
145162

146163
class EloquentStrictLoadingTestModel1 extends Model
@@ -172,6 +189,19 @@ protected function handleLazyLoadingViolation($key)
172189
}
173190
}
174191

192+
class EloquentStrictLoadingTestModel1WithLocalPreventsLazyLoading extends Model
193+
{
194+
public $table = 'test_model1';
195+
public $timestamps = false;
196+
public $preventsLazyLoading = true;
197+
protected $guarded = [];
198+
199+
public function modelTwos()
200+
{
201+
return $this->hasMany(EloquentStrictLoadingTestModel2::class, 'model_1_id');
202+
}
203+
}
204+
175205
class EloquentStrictLoadingTestModel2 extends Model
176206
{
177207
public $table = 'test_model2';

0 commit comments

Comments
 (0)