Skip to content

Commit 4b4c484

Browse files
authored
Merge branch '5.4' into feature/schedule-overlapping-strategy
2 parents ac3e486 + 5621260 commit 4b4c484

Some content is hidden

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

55 files changed

+951
-266
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
before_install:
3131
- if [[ $TRAVIS_PHP_VERSION != 7.1 ]] ; then phpenv config-rm xdebug.ini; fi
3232
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
33-
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
33+
- pecl install -f redis
3434
- travis_retry composer self-update
3535

3636
install:

CHANGELOG-5.4.md

+27
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,41 @@
88
- Allow scheduling of queued jobs ([#18235](https://github.com/laravel/framework/pull/18235), [7bb67e2](https://github.com/laravel/framework/commit/7bb67e225646fb578c039cc0af130f7aa6858120))
99
- Allow skipping mail sending if a listener to `MessageSending` returns `false` ([#18245](https://github.com/laravel/framework/pull/18245))
1010
- Added `BcryptHasher::cost()` method ([#18266](https://github.com/laravel/framework/pull/18266))
11+
- Added `Command::alert()` method ([#18272](https://github.com/laravel/framework/pull/18272))
12+
- Added `tap()` method to query builder ([#18284](https://github.com/laravel/framework/pull/18284))
13+
- Added `orderByDesc()` methods to query builder ([#18292](https://github.com/laravel/framework/pull/18292))
14+
- Added `Container::makeWith()` method ([#18271](https://github.com/laravel/framework/pull/18271), [#18320](https://github.com/laravel/framework/pull/18320))
15+
- Added `InteractsWithDatabase::assertSoftDeleted()` ([#18328](https://github.com/laravel/framework/pull/18328), [2d4e1f0](https://github.com/laravel/framework/commit/2d4e1f0fe0bae3c7e3304317a69d619e71e476cc), [f89f917](https://github.com/laravel/framework/commit/f89f917b256ad79df786c688b11247ce1e48299a))
16+
- Added ability to set queue parameters inside queued listeners ([#18375](https://github.com/laravel/framework/pull/18375), [cf461e2](https://github.com/laravel/framework/commit/cf461e23b6123ba6ed084d2fb8e8306482973b88))
17+
- Added `-q` shorthand for `make:listener --queued` ([#18362](https://github.com/laravel/framework/pull/18362))
18+
- Added `Model::setKeyType()` ([#18354](https://github.com/laravel/framework/pull/18354))
19+
- Output migration name before starting a migration or rollback ([#18379](https://github.com/laravel/framework/pull/18379), [e47e8b1](https://github.com/laravel/framework/commit/e47e8b16c1e65d752943faaa65db14ca323f5feb))
1120

1221
### Changed
1322
- Throw exception when `bootstrap/cache` directory is not writable ([#18188](https://github.com/laravel/framework/pull/18188), [b4f0005](https://github.com/laravel/framework/commit/b4f000516166b0694e842d64f5b2fde1167d4690))
1423
- Use `resource_path()` helper in `MakeAuthCommand` ([#18215](https://github.com/laravel/framework/pull/18215))
1524
- Added `file_exists()` check to `Event::emailOutput()` ([c8eafa8](https://github.com/laravel/framework/commit/c8eafa8e6741dc5add4c5030aa7362744dcdab29))
25+
- Allow wildcards in MIME type validations ([#18243](https://github.com/laravel/framework/pull/18243))
26+
- Only push existing jobs back into the queue using `queue:retry` ([#18279](https://github.com/laravel/framework/pull/18279), [e874a56](https://github.com/laravel/framework/commit/e874a56e5b75663861aab13ff8e13b82050de54e))
27+
- Support file uploads in nested array ([#18276](https://github.com/laravel/framework/pull/18276))
28+
- Don't use `config()` helper in Mail component ([#18290](https://github.com/laravel/framework/pull/18290))
29+
- Return the insert ID from `DatabaseJob::release()` ([#18288](https://github.com/laravel/framework/pull/18288), [#18291](https://github.com/laravel/framework/pull/18291))
30+
- Changed `id` in failed jobs migration stub to `bigIncrements()` ([#18300](https://github.com/laravel/framework/pull/18300))
31+
- Prevent `make:auth` from overwriting existing views ([#18319](https://github.com/laravel/framework/pull/18319), [bef8f35](https://github.com/laravel/framework/commit/bef8f35694b7c22516a27929dbfc4c49032f78c6))
32+
- Ensure Mailable view data is not overridden by order of operations ([#18322](https://github.com/laravel/framework/pull/18322))
33+
- Use `getAuthIdentifier()` method in broadcasters ([#18351](https://github.com/laravel/framework/pull/18351))
34+
- Use atomic cache operation when checking for event overlaps ([8ebb5b8](https://github.com/laravel/framework/commit/8ebb5b859ae8f2382a1836a83a47542de234d63a))
35+
- Return pretty JSON response from `HasInDatabase::failureDescription()` ([#18377](https://github.com/laravel/framework/pull/18377))
1636

1737
### Fixed
1838
- Fixed an issue with slots when passed content equals `null` ([#18246](https://github.com/laravel/framework/pull/18246))
39+
- Do require `Closure` in `orWhereHas()` ([#18277](https://github.com/laravel/framework/pull/18277))
40+
- Let PHP parse `@includeWhen` directive ([#18285](https://github.com/laravel/framework/pull/18285))
41+
- Only include `.php` files when loading database factories ([#18336](https://github.com/laravel/framework/pull/18336))
42+
- Fixed PHP 5.6 issue in `FileFactory::generateImage()` ([#18345](https://github.com/laravel/framework/pull/18345))
43+
- Allow `ImplicitRouteBinding` to match camelcase method parameter names ([#18307](https://github.com/laravel/framework/pull/18307), [4ae31a1](https://github.com/laravel/framework/commit/4ae31a154f81c2d76c7397dbdebfcac0e74e4ccd))
44+
- Fixing weird behaviour of `Connection::getConfig()` when `null` was passed ([#18356](https://github.com/laravel/framework/pull/18356))
45+
- Attempt to solve an issue with using `required_*` rules while the `ConvertEmptyStringToNull` middleware is applied ([#18376](https://github.com/laravel/framework/pull/18376))
1946

2047

2148
## v5.4.15 (2017-03-02)

src/Illuminate/Auth/Console/MakeAuthCommand.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class MakeAuthCommand extends Command
1414
*
1515
* @var string
1616
*/
17-
protected $signature = 'make:auth {--views : Only scaffold the authentication views}';
17+
protected $signature = 'make:auth
18+
{--views : Only scaffold the authentication views}
19+
{--force : Overwrite existing views by default}';
1820

1921
/**
2022
* The console command description.
@@ -88,6 +90,12 @@ protected function createDirectories()
8890
protected function exportViews()
8991
{
9092
foreach ($this->views as $key => $value) {
93+
if (file_exists(resource_path('views/'.$value)) && ! $this->option('force')) {
94+
if (! $this->confirm("The [{$value}] view already exists. Do you want to replace it?")) {
95+
continue;
96+
}
97+
}
98+
9199
copy(
92100
__DIR__.'/stubs/make/views/'.$key,
93101
resource_path('views/'.$value)

src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function validAuthenticationResponse($request, $result)
6666
} else {
6767
return $this->decodePusherResponse(
6868
$this->pusher->presence_auth(
69-
$request->channel_name, $request->socket_id, $request->user()->getKey(), $result)
69+
$request->channel_name, $request->socket_id, $request->user()->getAuthIdentifier(), $result)
7070
);
7171
}
7272
}

src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function validAuthenticationResponse($request, $result)
7272
}
7373

7474
return json_encode(['channel_data' => [
75-
'user_id' => $request->user()->getKey(),
75+
'user_id' => $request->user()->getAuthIdentifier(),
7676
'user_info' => $result,
7777
]]);
7878
}

src/Illuminate/Console/Command.php

+15
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,21 @@ public function warn($string, $verbosity = null)
475475
$this->line($string, 'warning', $verbosity);
476476
}
477477

478+
/**
479+
* Write a string in an alert box.
480+
*
481+
* @param string $string
482+
* @return void
483+
*/
484+
public function alert($string)
485+
{
486+
$this->comment(str_repeat('*', strlen($string) + 12));
487+
$this->comment('* '.$string.' *');
488+
$this->comment(str_repeat('*', strlen($string) + 12));
489+
490+
$this->output->writeln('');
491+
}
492+
478493
/**
479494
* Set the verbosity level.
480495
*

src/Illuminate/Console/ConfirmableTrait.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ public function confirmToProceed($warning = 'Application In Production!', $callb
2626
return true;
2727
}
2828

29-
$this->comment(str_repeat('*', strlen($warning) + 12));
30-
$this->comment('* '.$warning.' *');
31-
$this->comment(str_repeat('*', strlen($warning) + 12));
32-
$this->output->writeln('');
29+
$this->alert($warning);
3330

3431
$confirmed = $this->confirm('Do you really wish to run this command?');
3532

src/Illuminate/Container/Container.php

+71-2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ class Container implements ArrayAccess, ContainerContract
8282
*/
8383
protected $buildStack = [];
8484

85+
/**
86+
* The parameter override stack.
87+
*
88+
* @var array
89+
*/
90+
protected $with = [];
91+
8592
/**
8693
* The contextual binding map.
8794
*
@@ -537,6 +544,18 @@ public function factory($abstract)
537544
};
538545
}
539546

547+
/**
548+
* Resolve the given type with the given parameter overrides.
549+
*
550+
* @param string $abstract
551+
* @param array $parameters
552+
* @return mixed
553+
*/
554+
public function makeWith($abstract, array $parameters)
555+
{
556+
return $this->resolve($abstract, $parameters);
557+
}
558+
540559
/**
541560
* Resolve the given type from the container.
542561
*
@@ -545,7 +564,21 @@ public function factory($abstract)
545564
*/
546565
public function make($abstract)
547566
{
548-
$needsContextualBuild = ! is_null(
567+
return $this->resolve($abstract);
568+
}
569+
570+
/**
571+
* Resolve the given type from the container.
572+
*
573+
* @param string $abstract
574+
* @param array $parameters
575+
* @return mixed
576+
*/
577+
protected function resolve($abstract, $parameters = [])
578+
{
579+
$this->with[] = $parameters;
580+
581+
$needsContextualBuild = ! empty($parameters) || ! is_null(
549582
$this->getContextualConcrete($abstract = $this->getAlias($abstract))
550583
);
551584

@@ -583,8 +616,13 @@ public function make($abstract)
583616

584617
$this->fireResolvingCallbacks($abstract, $object);
585618

619+
// Before returning, we will also set the resolved flag to "true" and pop off
620+
// the parameter overrides for this build. After those two things are done
621+
// we will be ready to return back the fully constructed class instance.
586622
$this->resolved[$abstract] = true;
587623

624+
array_pop($this->with);
625+
588626
return $object;
589627
}
590628

@@ -675,7 +713,7 @@ public function build($concrete)
675713
// hand back the results of the functions, which allows functions to be
676714
// used as resolvers for more fine-tuned resolution of these objects.
677715
if ($concrete instanceof Closure) {
678-
return $concrete($this);
716+
return $concrete($this, end($this->with));
679717
}
680718

681719
$reflector = new ReflectionClass($concrete);
@@ -725,6 +763,15 @@ protected function resolveDependencies(array $dependencies)
725763
$results = [];
726764

727765
foreach ($dependencies as $dependency) {
766+
// If this dependency has a override for this particular build we will use
767+
// that instead as the value. Otherwise, we will continue with this run
768+
// of resolutions and let reflection attempt to determine the result.
769+
if ($this->hasParameterOverride($dependency)) {
770+
$results[] = $this->getParameterOverride($dependency);
771+
772+
continue;
773+
}
774+
728775
// If the class is null, it means the dependency is a string or some other
729776
// primitive type which we can not resolve since it is not a class and
730777
// we will just bomb out with an error since we have no-where to go.
@@ -736,6 +783,28 @@ protected function resolveDependencies(array $dependencies)
736783
return $results;
737784
}
738785

786+
/**
787+
* Determine if the given dependency has a parameter override from makeWith.
788+
*
789+
* @param \ReflectionParameter $dependency
790+
* @return bool
791+
*/
792+
protected function hasParameterOverride($dependency)
793+
{
794+
return array_key_exists($dependency->name, end($this->with));
795+
}
796+
797+
/**
798+
* Get a parameter override for a dependency.
799+
*
800+
* @param \ReflectionParameter $dependency
801+
* @return mixed
802+
*/
803+
protected function getParameterOverride($dependency)
804+
{
805+
return end($this->with)[$dependency->name];
806+
}
807+
739808
/**
740809
* Resolve a non-class hinted primitive dependency.
741810
*

src/Illuminate/Contracts/Queue/Job.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function fire();
1515
* Release the job back into the queue.
1616
*
1717
* @param int $delay
18-
* @return void
18+
* @return mixed
1919
*/
2020
public function release($delay = 0);
2121

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
namespace Illuminate\Database\Concerns;
4+
5+
trait BuildsQueries
6+
{
7+
/**
8+
* Chunk the results of the query.
9+
*
10+
* @param int $count
11+
* @param callable $callback
12+
* @return bool
13+
*/
14+
public function chunk($count, callable $callback)
15+
{
16+
$this->enforceOrderBy();
17+
18+
$page = 1;
19+
20+
do {
21+
// We'll execute the query for the given page and get the results. If there are
22+
// no results we can just break and return from here. When there are results
23+
// we will call the callback with the current chunk of these results here.
24+
$results = $this->forPage($page, $count)->get();
25+
26+
$countResults = $results->count();
27+
28+
if ($countResults == 0) {
29+
break;
30+
}
31+
32+
// On each chunk result set, we will pass them to the callback and then let the
33+
// developer take care of everything within the callback, which allows us to
34+
// keep the memory low for spinning through large result sets for working.
35+
if ($callback($results) === false) {
36+
return false;
37+
}
38+
39+
$page++;
40+
} while ($countResults == $count);
41+
42+
return true;
43+
}
44+
45+
/**
46+
* Execute a callback over each item while chunking.
47+
*
48+
* @param callable $callback
49+
* @param int $count
50+
* @return bool
51+
*/
52+
public function each(callable $callback, $count = 1000)
53+
{
54+
return $this->chunk($count, function ($results) use ($callback) {
55+
foreach ($results as $key => $value) {
56+
if ($callback($value, $key) === false) {
57+
return false;
58+
}
59+
}
60+
});
61+
}
62+
63+
/**
64+
* Execute the query and get the first result.
65+
*
66+
* @param array $columns
67+
* @return mixed
68+
*/
69+
public function first($columns = ['*'])
70+
{
71+
return $this->take(1)->get($columns)->first();
72+
}
73+
74+
/**
75+
* Apply the callback's query changes if the given "value" is true.
76+
*
77+
* @param mixed $value
78+
* @param \Closure $callback
79+
* @param \Closure $default
80+
* @return mixed
81+
*/
82+
public function when($value, $callback, $default = null)
83+
{
84+
if ($value) {
85+
return $callback($this, $value) ?: $this;
86+
} elseif ($default) {
87+
return $default($this, $value) ?: $this;
88+
}
89+
90+
return $this;
91+
}
92+
}

src/Illuminate/Database/Connection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -957,10 +957,10 @@ public function getName()
957957
/**
958958
* Get an option from the configuration options.
959959
*
960-
* @param string $option
960+
* @param string|null $option
961961
* @return mixed
962962
*/
963-
public function getConfig($option)
963+
public function getConfig($option = null)
964964
{
965965
return Arr::get($this->config, $option);
966966
}

0 commit comments

Comments
 (0)