Skip to content

Commit 89b7a52

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 01d6896 + 330dbe7 commit 89b7a52

35 files changed

+505
-176
lines changed

CHANGELOG-5.5.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
- Removed `build` scripts ([7c16b15](https://github.com/laravel/framework/pull/17048/commits/7c16b154ede10ff9a37756e32d7dddf317524634))
1010
- Removed usages of the `with()` helper ([#17888](https://github.com/laravel/framework/pull/17888))
1111
- Support callable/invokable objects in `Pipeline` ([#18264](https://github.com/laravel/framework/pull/18264))
12+
- ⚠️ Prevent access to protected properties using array access on `Model` and `Fluent` ([#18403](https://github.com/laravel/framework/pull/18403))
13+
- Show custom 500 error page for all exception types when not in debug mode ([#18481](https://github.com/laravel/framework/pull/18481), [3cb7b0f](https://github.com/laravel/framework/commit/3cb7b0f4304274f209ed0f776ef70ccd4f9fe5dd))
1214

1315
### Console
1416
- Add interactive prompt to `vendor:publish` ([#18230](https://github.com/laravel/framework/pull/18230))
1517

1618
### Eloquent
1719
- ⚠️ Indicate soft deleted models as existing ([#17613](https://github.com/laravel/framework/pull/17613))
1820
- ⚠️ Added `$localKey` parameter to `HasRelationships::belongsToMany()` and `BelongsToMany` ([#17903](https://github.com/laravel/framework/pull/17903), [7c7c3bc](https://github.com/laravel/framework/commit/7c7c3bc4be3052afe0889fe323230dfd92f81000))
19-
- Renamed `$parent` property to `$pivotParent` in `Pivot` class ([#17933](https://github.com/laravel/framework/pull/17933), [#18150](https://github.com/laravel/framework/pull/18150))
21+
- ⚠️ Renamed `$parent` property to `$pivotParent` in `Pivot` class ([#17933](https://github.com/laravel/framework/pull/17933), [#18150](https://github.com/laravel/framework/pull/18150))
2022
- ⚠️ Don't add `_count` suffix to column name when using `withCount()` with an alias ([#17871](https://github.com/laravel/framework/pull/17871))
2123
- ⚠️ Renamed `$events` to `$dispatchesEvents` ([#17961](https://github.com/laravel/framework/pull/17961), [b6472bf](https://github.com/laravel/framework/commit/b6472bf6fec1af6e76604aaf3f7fed665440ac66), [3dbe12f](https://github.com/laravel/framework/commit/3dbe12f16f470e3bca868576d517d57876bc50af))
2224
- ⚠️ Added `$parentKey` parameter to `belongsToMany()`, `BelongsToMany` and `MorphToMany` ([#17915](https://github.com/laravel/framework/pull/17915), [#18380](https://github.com/laravel/framework/pull/18380))
@@ -50,7 +52,8 @@
5052
### Testing
5153
- ⚠️ Switched to PHPUnit 6 ([#17755](https://github.com/laravel/framework/pull/17755), [#17864](https://github.com/laravel/framework/pull/17864))
5254
- ⚠️ Renamed authentication assertion methods ([#17924](https://github.com/laravel/framework/pull/17924), [494a177](https://github.com/laravel/framework/commit/494a1774f217f0cd6b4efade63e200e3ac65f201))
53-
- Added POC of integration testing the framework itself ([182027d](https://github.com/laravel/framework/commit/182027d3290e9a2e1bd9e2d52c125177ef6c6af6))
55+
- Added POC of integration testing the framework itself ([182027d](https://github.com/laravel/framework/commit/182027d3290e9a2e1bd9e2d52c125177ef6c6af6), [#18438](https://github.com/laravel/framework/pull/18438))
5456

5557
### Views
5658
- ⚠️ Camel case variables names passed to views ([#18083](https://github.com/laravel/framework/pull/18083))
59+
- Added pagination template for Semantic UI ([#18463](https://github.com/laravel/framework/pull/18463))
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace Illuminate\Console\Scheduling;
4+
5+
use Illuminate\Contracts\Cache\Repository as Cache;
6+
7+
class CacheMutex implements Mutex
8+
{
9+
/**
10+
* The cache repository implementation.
11+
*
12+
* @var \Illuminate\Contracts\Cache\Repository
13+
*/
14+
public $cache;
15+
16+
/**
17+
* Create a new overlapping strategy.
18+
*
19+
* @param \Illuminate\Contracts\Cache\Repository $cache
20+
* @return void
21+
*/
22+
public function __construct(Cache $cache)
23+
{
24+
$this->cache = $cache;
25+
}
26+
27+
/**
28+
* Attempt to obtain a mutex for the given event.
29+
*
30+
* @param \Illuminate\Console\Scheduling\Event $event
31+
* @return bool
32+
*/
33+
public function create(Event $event)
34+
{
35+
return $this->cache->add($event->mutexName(), true, 1440);
36+
}
37+
38+
/**
39+
* Determine if a mutex exists for the given event.
40+
*
41+
* @param \Illuminate\Console\Scheduling\Event $event
42+
* @return bool
43+
*/
44+
public function exists(Event $event)
45+
{
46+
return $this->cache->has($event->mutexName());
47+
}
48+
49+
/**
50+
* Clear the mutex for the given event.
51+
*
52+
* @param \Illuminate\Console\Scheduling\Event $event
53+
* @return void
54+
*/
55+
public function forget(Event $event)
56+
{
57+
$this->cache->forget($event->mutexName());
58+
}
59+
}

src/Illuminate/Console/Scheduling/CallbackEvent.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use LogicException;
66
use InvalidArgumentException;
77
use Illuminate\Contracts\Container\Container;
8-
use Illuminate\Contracts\Cache\Repository as Cache;
98

109
class CallbackEvent extends Event
1110
{
@@ -26,22 +25,22 @@ class CallbackEvent extends Event
2625
/**
2726
* Create a new event instance.
2827
*
29-
* @param \Illuminate\Contracts\Cache\Repository $cache
28+
* @param \Illuminate\Console\Scheduling\Mutex $mutex
3029
* @param string $callback
3130
* @param array $parameters
3231
* @return void
3332
*
3433
* @throws \InvalidArgumentException
3534
*/
36-
public function __construct(Cache $cache, $callback, array $parameters = [])
35+
public function __construct(Mutex $mutex, $callback, array $parameters = [])
3736
{
3837
if (! is_string($callback) && ! is_callable($callback)) {
3938
throw new InvalidArgumentException(
4039
'Invalid scheduled callback event. Must be a string or callable.'
4140
);
4241
}
4342

44-
$this->cache = $cache;
43+
$this->mutex = $mutex;
4544
$this->callback = $callback;
4645
$this->parameters = $parameters;
4746
}
@@ -57,7 +56,7 @@ public function __construct(Cache $cache, $callback, array $parameters = [])
5756
public function run(Container $container)
5857
{
5958
if ($this->description) {
60-
$this->cache->put($this->mutexName(), true, 1440);
59+
$this->mutex->create($this);
6160
}
6261

6362
try {
@@ -79,7 +78,7 @@ public function run(Container $container)
7978
protected function removeMutex()
8079
{
8180
if ($this->description) {
82-
$this->cache->forget($this->mutexName());
81+
$this->mutex->forget($this);
8382
}
8483
}
8584

@@ -99,7 +98,7 @@ public function withoutOverlapping()
9998
}
10099

101100
return $this->skip(function () {
102-
return $this->cache->has($this->mutexName());
101+
return $this->mutex->exists($this);
103102
});
104103
}
105104

src/Illuminate/Console/Scheduling/Event.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,11 @@
1010
use Symfony\Component\Process\Process;
1111
use Illuminate\Support\Traits\Macroable;
1212
use Illuminate\Contracts\Container\Container;
13-
use Illuminate\Contracts\Cache\Repository as Cache;
1413

1514
class Event
1615
{
1716
use Macroable, ManagesFrequencies;
1817

19-
/**
20-
* The cache store implementation.
21-
*
22-
* @var \Illuminate\Contracts\Cache\Repository
23-
*/
24-
protected $cache;
25-
2618
/**
2719
* The command string.
2820
*
@@ -128,16 +120,23 @@ class Event
128120
*/
129121
public $description;
130122

123+
/**
124+
* The mutex implementation.
125+
*
126+
* @var \Illuminate\Console\Scheduling\Mutex
127+
*/
128+
public $mutex;
129+
131130
/**
132131
* Create a new event instance.
133132
*
134-
* @param \Illuminate\Contracts\Cache\Repository $cache
133+
* @param \Illuminate\Console\Scheduling\Mutex $mutex
135134
* @param string $command
136135
* @return void
137136
*/
138-
public function __construct(Cache $cache, $command)
137+
public function __construct(Mutex $mutex, $command)
139138
{
140-
$this->cache = $cache;
139+
$this->mutex = $mutex;
141140
$this->command = $command;
142141
$this->output = $this->getDefaultOutput();
143142
}
@@ -161,7 +160,7 @@ public function getDefaultOutput()
161160
public function run(Container $container)
162161
{
163162
if ($this->withoutOverlapping &&
164-
! $this->cache->add($this->mutexName(), true, 1440)) {
163+
! $this->mutex->create($this)) {
165164
return;
166165
}
167166

@@ -517,9 +516,9 @@ public function withoutOverlapping()
517516
$this->withoutOverlapping = true;
518517

519518
return $this->then(function () {
520-
$this->cache->forget($this->mutexName());
519+
$this->mutex->forget($this);
521520
})->skip(function () {
522-
return $this->cache->has($this->mutexName());
521+
return $this->mutex->exists($this);
523522
});
524523
}
525524

@@ -633,4 +632,17 @@ public function getExpression()
633632
{
634633
return $this->expression;
635634
}
635+
636+
/**
637+
* Set the mutex implementation to be used.
638+
*
639+
* @param \Illuminate\Console\Scheduling\Mutex $mutex
640+
* @return $this
641+
*/
642+
public function preventOverlapsUsing(Mutex $mutex)
643+
{
644+
$this->mutex = $mutex;
645+
646+
return $this;
647+
}
636648
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Illuminate\Console\Scheduling;
4+
5+
interface Mutex
6+
{
7+
/**
8+
* Attempt to obtain a mutex for the given event.
9+
*
10+
* @param \Illuminate\Console\Scheduling\Event $event
11+
* @return bool
12+
*/
13+
public function create(Event $event);
14+
15+
/**
16+
* Determine if a mutex exists for the given event.
17+
*
18+
* @param \Illuminate\Console\Scheduling\Event $event
19+
* @return bool
20+
*/
21+
public function exists(Event $event);
22+
23+
/**
24+
* Clear the mutex for the given event.
25+
*
26+
* @param \Illuminate\Console\Scheduling\Event $event
27+
* @return void
28+
*/
29+
public function forget(Event $event);
30+
}

src/Illuminate/Console/Scheduling/Schedule.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,35 @@
55
use Illuminate\Console\Application;
66
use Illuminate\Container\Container;
77
use Symfony\Component\Process\ProcessUtils;
8-
use Illuminate\Contracts\Cache\Repository as Cache;
98

109
class Schedule
1110
{
1211
/**
13-
* The cache store implementation.
12+
* All of the events on the schedule.
1413
*
15-
* @var \Illuminate\Contracts\Cache\Repository
14+
* @var array
1615
*/
17-
protected $cache;
16+
protected $events = [];
1817

1918
/**
20-
* All of the events on the schedule.
19+
* The mutex implementation.
2120
*
22-
* @var array
21+
* @var \Illuminate\Console\Scheduling\Mutex
2322
*/
24-
protected $events = [];
23+
protected $mutex;
2524

2625
/**
2726
* Create a new event instance.
2827
*
29-
* @param \Illuminate\Contracts\Cache\Repository $cache
3028
* @return void
3129
*/
32-
public function __construct(Cache $cache)
30+
public function __construct()
3331
{
34-
$this->cache = $cache;
32+
$container = Container::getInstance();
33+
34+
$this->mutex = $container->bound(Mutex::class)
35+
? $container->make(Mutex::class)
36+
: $container->make(CacheMutex::class);
3537
}
3638

3739
/**
@@ -43,7 +45,9 @@ public function __construct(Cache $cache)
4345
*/
4446
public function call($callback, array $parameters = [])
4547
{
46-
$this->events[] = $event = new CallbackEvent($this->cache, $callback, $parameters);
48+
$this->events[] = $event = new CallbackEvent(
49+
$this->mutex, $callback, $parameters
50+
);
4751

4852
return $event;
4953
}
@@ -92,7 +96,7 @@ public function exec($command, array $parameters = [])
9296
$command .= ' '.$this->compileParameters($parameters);
9397
}
9498

95-
$this->events[] = $event = new Event($this->cache, $command);
99+
$this->events[] = $event = new Event($this->mutex, $command);
96100

97101
return $event;
98102
}

src/Illuminate/Contracts/Mail/MailQueue.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,19 @@ interface MailQueue
77
/**
88
* Queue a new e-mail message for sending.
99
*
10-
* @param string|array $view
11-
* @param array $data
12-
* @param \Closure|string $callback
10+
* @param string|array|MailableContract $view
1311
* @param string $queue
1412
* @return mixed
1513
*/
16-
public function queue($view, array $data, $callback, $queue = null);
14+
public function queue($view, $queue = null);
1715

1816
/**
1917
* Queue a new e-mail message for sending after (n) seconds.
2018
*
21-
* @param int $delay
22-
* @param string|array $view
23-
* @param array $data
24-
* @param \Closure|string $callback
19+
* @param \DateTime|int $delay
20+
* @param string|array|MailableContract $view
2521
* @param string $queue
2622
* @return mixed
2723
*/
28-
public function later($delay, $view, array $data, $callback, $queue = null);
24+
public function later($delay, $view, $queue = null);
2925
}

src/Illuminate/Contracts/Mail/Mailer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function raw($text, $callback);
1616
/**
1717
* Send a new message using a view.
1818
*
19-
* @param string|array $view
19+
* @param string|array|MailableContract $view
2020
* @param array $data
2121
* @param \Closure|string $callback
2222
* @return void

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,12 +959,13 @@ public function replicate(array $except = null)
959959
/**
960960
* Determine if two models have the same ID and belong to the same table.
961961
*
962-
* @param \Illuminate\Database\Eloquent\Model $model
962+
* @param \Illuminate\Database\Eloquent\Model|null $model
963963
* @return bool
964964
*/
965-
public function is(Model $model)
965+
public function is($model)
966966
{
967-
return $this->getKey() === $model->getKey() &&
967+
return ! is_null($model) &&
968+
$this->getKey() === $model->getKey() &&
968969
$this->getTable() === $model->getTable() &&
969970
$this->getConnectionName() === $model->getConnectionName();
970971
}

src/Illuminate/Database/Eloquent/Relations/BelongsTo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function update(array $attributes)
204204
/**
205205
* Associate the model instance to the given parent.
206206
*
207-
* @param \Illuminate\Database\Eloquent\Model|int $model
207+
* @param \Illuminate\Database\Eloquent\Model|int|string $model
208208
* @return \Illuminate\Database\Eloquent\Model
209209
*/
210210
public function associate($model)

0 commit comments

Comments
 (0)