Skip to content

Commit 685b0f1

Browse files
authored
Merge branch 'laravel:9.x' into 9.x
2 parents a299816 + 44391ab commit 685b0f1

File tree

62 files changed

+1391
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1391
-241
lines changed

CHANGELOG.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,57 @@
11
# Release Notes for 9.x
22

3-
## [Unreleased](https://github.com/laravel/framework/compare/v9.37.0...9.x)
3+
## [Unreleased](https://github.com/laravel/framework/compare/v9.39.0...9.x)
4+
5+
6+
## [v9.39.0](https://github.com/laravel/framework/compare/v9.38.0...v9.39.0) - 2022-11-08
7+
8+
### Added
9+
- Added template fragments to Blade ([#44774](https://github.com/laravel/framework/pull/44774))
10+
- Added source file to Collection's dd method output ([#44793](https://github.com/laravel/framework/pull/44793), [d2e0e85](https://github.com/laravel/framework/commit/d2e0e859f00579aeb2600fce2fe9fc3cca933f41))
11+
- Added `Illuminate/Support/Testing/Fakes/PendingBatchFake::dispatchAfterResponse()` ([#44815](https://github.com/laravel/framework/pull/44815))
12+
- Added `Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase::assertDatabaseEmpty()` ([#44810](https://github.com/laravel/framework/pull/44810))
13+
14+
### Fixed
15+
- Fixed `InteractsWithContainer::withoutMix()` ([#44822](https://github.com/laravel/framework/pull/44822))
16+
17+
### Changed
18+
- Update `UpCommand::handle` that must return int ([#44807](https://github.com/laravel/framework/pull/44807))
19+
- Decouple database component from console component ([#44798](https://github.com/laravel/framework/pull/44798))
20+
- Improve input argument parsing for commands ([#44662](https://github.com/laravel/framework/pull/44662), [#44826](https://github.com/laravel/framework/pull/44826))
21+
- Added DatabaseBatchRepository to provides() in BusServiceProvider ([#44833](https://github.com/laravel/framework/pull/44833))
22+
- Move reusable onNotSuccessfulTest functionality to TestResponse ([#44827](https://github.com/laravel/framework/pull/44827))
23+
- Add CSP nonce to Vite reactRefresh inline script ([#44816](https://github.com/laravel/framework/pull/44816))
24+
- Allow route group method to be chained ([#44825](https://github.com/laravel/framework/pull/44825))
25+
- Remove __sleep() & __wakeup() from SerializesModels trait. ([#44847](https://github.com/laravel/framework/pull/44847))
26+
- Handle SQLite without ENABLE_DBSTAT_VTAB enabled in `Illuminate/Database/Console/DatabaseInspectionCommand::getSqliteTableSize()` ([#44867](https://github.com/laravel/framework/pull/44867))
27+
- Apply force flag when necessary in `Illuminate/Queue/Listener` ([#44862](https://github.com/laravel/framework/pull/44862))
28+
- De-couple Console component from framework ([#44864](https://github.com/laravel/framework/pull/44864))
29+
- Update Vite mock to return empty array for preloadedAssets ([#44858](https://github.com/laravel/framework/pull/44858))
30+
31+
32+
## [v9.38.0](https://github.com/laravel/framework/compare/v9.37.0...v9.38.0) - 2022-11-01
33+
34+
### Added
35+
- Added `Illuminate/Routing/Route::flushController()` ([#44393](https://github.com/laravel/framework/pull/44393))
36+
- Added `Illuminate/Session/Store::setHandler()` ([#44736](https://github.com/laravel/framework/pull/44736))
37+
- Added dictionary to slug helper ([#44730](https://github.com/laravel/framework/pull/44730))
38+
- Added ability to set middleware based on notifiable instance and channel ([#44767](https://github.com/laravel/framework/pull/44767))
39+
- Added touchQuietly convenience method to Model ([#44722](https://github.com/laravel/framework/pull/44722))
40+
- Added `Illuminate/Routing/Router::removeMiddlewareFromGroup()` ([#44780](https://github.com/laravel/framework/pull/44780))
41+
- Allow queueable notifications to set maxExceptions ([#44773](https://github.com/laravel/framework/pull/44773))
42+
- Make migrate command isolated ([#44743](https://github.com/laravel/framework/pull/44743), [ac3252a](https://github.com/laravel/framework/commit/ac3252a4c2a4c94724cd5aeaf6268427d21f9e97))
43+
44+
### Fixed
45+
- Fixed whenPivotLoaded(As) api resource methods when using Eloquent strict mode ([#44792](https://github.com/laravel/framework/pull/44792))
46+
- Fixed components view error when using $attributes in parent view ([#44778](https://github.com/laravel/framework/pull/44778))
47+
- Fixed problem with disregarding global scopes when using existOr and doesntExistOr methods on model query ([#44795](https://github.com/laravel/framework/pull/44795))
48+
49+
### Changed
50+
- Recompiles views when necessary ([#44737](https://github.com/laravel/framework/pull/44737))
51+
- Throw meaningful exception when broadcast connection not configured ([#44745](https://github.com/laravel/framework/pull/44745))
52+
- Prevents booting of providers when running env:encrypt ([#44758](https://github.com/laravel/framework/pull/44758))
53+
- Added nonce for preloaded assets ([#44747](https://github.com/laravel/framework/pull/44747))
54+
- Inherit crossorigin attributes while preloading view ([#44800](https://github.com/laravel/framework/pull/44800))
455

556

657
## [v9.37.0](https://github.com/laravel/framework/compare/v9.36.4...v9.37.0) - 2022-10-25

src/Illuminate/Bus/BusServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function provides()
6464
DispatcherContract::class,
6565
QueueingDispatcherContract::class,
6666
BatchRepository::class,
67+
DatabaseBatchRepository::class,
6768
];
6869
}
6970
}

src/Illuminate/Collections/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ public function mergeRecursive($items)
807807
* @template TCombineValue
808808
*
809809
* @param \Illuminate\Contracts\Support\Arrayable<array-key, TCombineValue>|iterable<array-key, TCombineValue> $values
810-
* @return static<TKey, TCombineValue>
810+
* @return static<TValue, TCombineValue>
811811
*/
812812
public function combine($values)
813813
{

src/Illuminate/Collections/Enumerable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ public function mergeRecursive($items);
719719
* @template TCombineValue
720720
*
721721
* @param \Illuminate\Contracts\Support\Arrayable<array-key, TCombineValue>|iterable<array-key, TCombineValue> $values
722-
* @return static<TKey, TCombineValue>
722+
* @return static<TValue, TCombineValue>
723723
*/
724724
public function combine($values);
725725

@@ -1168,7 +1168,7 @@ public function count(): int;
11681168
* @param (callable(TValue, TKey): mixed)|string|null $countBy
11691169
* @return static<array-key, int>
11701170
*/
1171-
public function countBy($callback = null);
1171+
public function countBy($countBy = null);
11721172

11731173
/**
11741174
* Zip the collection together with one or more arrays.

src/Illuminate/Collections/LazyCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ public function mergeRecursive($items)
798798
* @template TCombineValue
799799
*
800800
* @param \IteratorAggregate<array-key, TCombineValue>|array<array-key, TCombineValue>|(callable(): \Generator<array-key, TCombineValue>) $values
801-
* @return static<TKey, TCombineValue>
801+
* @return static<TValue, TCombineValue>
802802
*/
803803
public function combine($values)
804804
{

src/Illuminate/Console/Application.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Symfony\Component\Console\Application as SymfonyApplication;
1414
use Symfony\Component\Console\Command\Command as SymfonyCommand;
1515
use Symfony\Component\Console\Exception\CommandNotFoundException;
16+
use Symfony\Component\Console\Exception\ExceptionInterface;
1617
use Symfony\Component\Console\Input\ArgvInput;
1718
use Symfony\Component\Console\Input\ArrayInput;
1819
use Symfony\Component\Console\Input\InputDefinition;
@@ -93,6 +94,14 @@ public function run(InputInterface $input = null, OutputInterface $output = null
9394
$input = $input ?: new ArgvInput
9495
);
9596

97+
if (! is_null($commandName)) {
98+
try {
99+
$input->bind($this->find($commandName)->getDefinition());
100+
} catch (ExceptionInterface) {
101+
// ...
102+
}
103+
}
104+
96105
$this->events->dispatch(
97106
new CommandStarting(
98107
$commandName, $input, $output = $output ?: new BufferedConsoleOutput
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
3+
namespace Illuminate\Console;
4+
5+
use Carbon\CarbonInterval;
6+
use Illuminate\Contracts\Cache\Factory as Cache;
7+
8+
class CacheCommandMutex implements CommandMutex
9+
{
10+
/**
11+
* The cache factory implementation.
12+
*
13+
* @var \Illuminate\Contracts\Cache\Factory
14+
*/
15+
public $cache;
16+
17+
/**
18+
* The cache store that should be used.
19+
*
20+
* @var string|null
21+
*/
22+
public $store = null;
23+
24+
/**
25+
* Create a new command mutex.
26+
*
27+
* @param \Illuminate\Contracts\Cache\Factory $cache
28+
*/
29+
public function __construct(Cache $cache)
30+
{
31+
$this->cache = $cache;
32+
}
33+
34+
/**
35+
* Attempt to obtain a command mutex for the given command.
36+
*
37+
* @param \Illuminate\Console\Command $command
38+
* @return bool
39+
*/
40+
public function create($command)
41+
{
42+
return $this->cache->store($this->store)->add(
43+
$this->commandMutexName($command),
44+
true,
45+
method_exists($command, 'isolationLockExpiresAt')
46+
? $command->isolationLockExpiresAt()
47+
: CarbonInterval::hour(),
48+
);
49+
}
50+
51+
/**
52+
* Determine if a command mutex exists for the given command.
53+
*
54+
* @param \Illuminate\Console\Command $command
55+
* @return bool
56+
*/
57+
public function exists($command)
58+
{
59+
return $this->cache->store($this->store)->has(
60+
$this->commandMutexName($command)
61+
);
62+
}
63+
64+
/**
65+
* Release the mutex for the given command.
66+
*
67+
* @param \Illuminate\Console\Command $command
68+
* @return bool
69+
*/
70+
public function forget($command)
71+
{
72+
return $this->cache->store($this->store)->forget(
73+
$this->commandMutexName($command)
74+
);
75+
}
76+
77+
/**
78+
* @param \Illuminate\Console\Command $command
79+
* @return string
80+
*/
81+
protected function commandMutexName($command)
82+
{
83+
return 'framework'.DIRECTORY_SEPARATOR.'command-'.$command->getName();
84+
}
85+
86+
/**
87+
* Specify the cache store that should be used.
88+
*
89+
* @param string|null $store
90+
* @return $this
91+
*/
92+
public function useStore($store)
93+
{
94+
$this->store = $store;
95+
96+
return $this;
97+
}
98+
}

src/Illuminate/Console/Command.php

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace Illuminate\Console;
44

55
use Illuminate\Console\View\Components\Factory;
6+
use Illuminate\Contracts\Console\Isolatable;
67
use Illuminate\Support\Traits\Macroable;
78
use Symfony\Component\Console\Command\Command as SymfonyCommand;
89
use Symfony\Component\Console\Input\InputInterface;
10+
use Symfony\Component\Console\Input\InputOption;
911
use Symfony\Component\Console\Output\OutputInterface;
1012

1113
class Command extends SymfonyCommand
@@ -86,6 +88,10 @@ public function __construct()
8688
if (! isset($this->signature)) {
8789
$this->specifyParameters();
8890
}
91+
92+
if ($this instanceof Isolatable) {
93+
$this->configureIsolation();
94+
}
8995
}
9096

9197
/**
@@ -106,6 +112,22 @@ protected function configureUsingFluentDefinition()
106112
$this->getDefinition()->addOptions($options);
107113
}
108114

115+
/**
116+
* Configure the console command for isolation.
117+
*
118+
* @return void
119+
*/
120+
protected function configureIsolation()
121+
{
122+
$this->getDefinition()->addOption(new InputOption(
123+
'isolated',
124+
null,
125+
InputOption::VALUE_OPTIONAL,
126+
'Do not run the command if another instance of the command is already running',
127+
false
128+
));
129+
}
130+
109131
/**
110132
* Run the console command.
111133
*
@@ -139,9 +161,38 @@ public function run(InputInterface $input, OutputInterface $output): int
139161
*/
140162
protected function execute(InputInterface $input, OutputInterface $output)
141163
{
164+
if ($this instanceof Isolatable && $this->option('isolated') !== false &&
165+
! $this->commandIsolationMutex()->create($this)) {
166+
$this->comment(sprintf(
167+
'The [%s] command is already running.', $this->getName()
168+
));
169+
170+
return (int) (is_numeric($this->option('isolated'))
171+
? $this->option('isolated')
172+
: self::SUCCESS);
173+
}
174+
142175
$method = method_exists($this, 'handle') ? 'handle' : '__invoke';
143176

144-
return (int) $this->laravel->call([$this, $method]);
177+
try {
178+
return (int) $this->laravel->call([$this, $method]);
179+
} finally {
180+
if ($this instanceof Isolatable && $this->option('isolated') !== false) {
181+
$this->commandIsolationMutex()->forget($this);
182+
}
183+
}
184+
}
185+
186+
/**
187+
* Get a command isolation mutex instance for the command.
188+
*
189+
* @return \Illuminate\Console\CommandMutex
190+
*/
191+
protected function commandIsolationMutex()
192+
{
193+
return $this->laravel->bound(CommandMutex::class)
194+
? $this->laravel->make(CommandMutex::class)
195+
: $this->laravel->make(CacheCommandMutex::class);
145196
}
146197

147198
/**
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;
4+
5+
interface CommandMutex
6+
{
7+
/**
8+
* Attempt to obtain a command mutex for the given command.
9+
*
10+
* @param \Illuminate\Console\Command $command
11+
* @return bool
12+
*/
13+
public function create($command);
14+
15+
/**
16+
* Determine if a command mutex exists for the given command.
17+
*
18+
* @param \Illuminate\Console\Command $command
19+
* @return bool
20+
*/
21+
public function exists($command);
22+
23+
/**
24+
* Release the mutex for the given command.
25+
*
26+
* @param \Illuminate\Console\Command $command
27+
* @return bool
28+
*/
29+
public function forget($command);
30+
}

src/Illuminate/Console/View/Components/Component.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,14 @@ protected function compile($view, $data)
8181
protected function mutate($data, $mutators)
8282
{
8383
foreach ($mutators as $mutator) {
84+
$mutator = new $mutator;
85+
8486
if (is_iterable($data)) {
8587
foreach ($data as $key => $value) {
86-
$data[$key] = app($mutator)->__invoke($value);
88+
$data[$key] = $mutator($value);
8789
}
8890
} else {
89-
$data = app($mutator)->__invoke($data);
91+
$data = $mutator($data);
9092
}
9193
}
9294

0 commit comments

Comments
 (0)