Skip to content

Commit

Permalink
Merge branch 'master' into improve-from-subqueries-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
reinink authored Aug 17, 2019
2 parents 6c1e014 + 0b8b18b commit f75dad1
Show file tree
Hide file tree
Showing 47 changed files with 5,442 additions and 1,928 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
before_install:
- phpenv config-rm xdebug.ini || true
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- printf "\n" | pecl install -f redis-4.3.0
- printf "\n" | pecl install -f redis
- travis_retry composer self-update
- mysql -e 'CREATE DATABASE forge;'

Expand Down
12 changes: 9 additions & 3 deletions CHANGELOG-5.8.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Release Notes for 5.8.x

## [Unreleased](https://github.com/laravel/framework/compare/v5.8.31...5.8)
## [Unreleased](https://github.com/laravel/framework/compare/v5.8.32...5.8)

### TODO:
- Resolve columns with schema references ([#29448](https://github.com/laravel/framework/pull/29448))

## [v5.8.32 (2019-08-13)](https://github.com/laravel/framework/compare/v5.8.31...v5.8.32)

### Fixed
- Fixed top level wildcard validation for `distinct` validator ([#29499](https://github.com/laravel/framework/pull/29499))
- Fixed resolving of columns with schema references in Postgres ([#29448](https://github.com/laravel/framework/pull/29448))
- Only remove the event mutex if it was created ([#29526](https://github.com/laravel/framework/pull/29526))
- Fixed restoring serialized collection with deleted models ([#29533](https://github.com/laravel/framework/pull/29533), [74b62bb](https://github.com/laravel/framework/commit/74b62bbbb32674dfa167e2812231bf302454e67f))


## [v5.8.31 (2019-08-06)](https://github.com/laravel/framework/compare/v5.8.30...v5.8.31)
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/Notifications/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function toMail($notifiable)
->subject(Lang::get('Reset Password Notification'))
->line(Lang::get('You are receiving this email because we received a password reset request for your account.'))
->action(Lang::get('Reset Password'), url(config('app.url').route('password.reset', ['token' => $this->token, 'email' => $notifiable->getEmailForPasswordReset()], false)))
->line(Lang::get('This password reset link will expire in :count minutes.', ['count' => config('auth.passwords.users.expire')]))
->line(Lang::get('This password reset link will expire in :count minutes.', ['count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')]))
->line(Lang::get('If you did not request a password reset, no further action is required.'));
}

Expand Down
7 changes: 0 additions & 7 deletions src/Illuminate/Cache/NullStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ class NullStore extends TaggableStore
{
use RetrievesMultipleKeys;

/**
* The array of stored values.
*
* @var array
*/
protected $storage = [];

/**
* Retrieve an item from the cache by key.
*
Expand Down
4 changes: 1 addition & 3 deletions src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -768,9 +768,7 @@ protected function getContextualConcrete($abstract)
*/
protected function findInContextualBindings($abstract)
{
if (isset($this->contextual[end($this->buildStack)][$abstract])) {
return $this->contextual[end($this->buildStack)][$abstract];
}
return $this->contextual[end($this->buildStack)][$abstract] ?? null;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Database/Connectors/SqlServerConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ protected function buildConnectString($driver, array $arguments)
*/
protected function buildHostString(array $config, $separator)
{
if (isset($config['port']) && ! empty($config['port'])) {
return $config['host'].$separator.$config['port'];
} else {
if (empty($config['port'])) {
return $config['host'];
}

return $config['host'].$separator.$config['port'];
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,7 @@ public function getAttributeValue($key)
*/
protected function getAttributeFromArray($key)
{
if (isset($this->attributes[$key])) {
return $this->attributes[$key];
}
return $this->attributes[$key] ?? null;
}

/**
Expand Down
46 changes: 42 additions & 4 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,21 @@ public function __construct(ConnectionInterface $connection,
*/
public function select($columns = ['*'])
{
$this->columns = is_array($columns) ? $columns : func_get_args();
$this->columns = [];

$columns = is_array($columns) ? $columns : func_get_args();

foreach ($columns as $as => $column) {
if (is_string($as) && (
$column instanceof self ||
$column instanceof EloquentBuilder ||
$column instanceof Closure
)) {
$this->selectSub($column, $as);
} else {
$this->columns[] = $column;
}
}

return $this;
}
Expand Down Expand Up @@ -339,9 +353,23 @@ protected function parseSub($query)
*/
public function addSelect($column)
{
$column = is_array($column) ? $column : func_get_args();
$columns = is_array($column) ? $column : func_get_args();

foreach ($columns as $as => $column) {
if (is_string($as) && (
$column instanceof self ||
$column instanceof EloquentBuilder ||
$column instanceof Closure
)) {
if (is_null($this->columns)) {
$this->select($this->from.'.*');
}

$this->columns = array_merge((array) $this->columns, $column);
$this->selectSub($column, $as);
} else {
$this->columns[] = $column;
}
}

return $this;
}
Expand Down Expand Up @@ -1768,14 +1796,24 @@ public function orHavingRaw($sql, array $bindings = [])
/**
* Add an "order by" clause to the query.
*
* @param string $column
* @param \Closure|\Illuminate\Database\Query\Builder|string $column
* @param string $direction
* @return $this
*
* @throws \InvalidArgumentException
*/
public function orderBy($column, $direction = 'asc')
{
if ($column instanceof self ||
$column instanceof EloquentBuilder ||
$column instanceof Closure) {
[$query, $bindings] = $this->createSub($column);

$column = new Expression('('.$query.')');

$this->addBinding($bindings, 'order');
}

$direction = strtolower($direction);

if (! in_array($direction, ['asc', 'desc'], true)) {
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Database/Seeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ public function call($class, $silent = false)
$classes = Arr::wrap($class);

foreach ($classes as $class) {
$seeder = $this->resolve($class);

if ($silent === false && isset($this->command)) {
$this->command->getOutput()->writeln("<info>Seeding:</info> $class");
$this->command->getOutput()->writeln('<info>Seeding:</info> '.get_class($seeder));
}

$this->resolve($class)->__invoke();
$seeder->__invoke();
}

return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Filesystem/FilesystemManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected function formatS3Config(array $config)
{
$config += ['version' => 'latest'];

if ($config['key'] && $config['secret']) {
if (! empty($config['key']) && ! empty($config['secret'])) {
$config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
}

Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Foundation/Events/DiscoverEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ protected static function getListenerEvents($listeners, $basePath)
static::classFromFile($listener, $basePath)
);

if (! $listener->isInstantiable()) {
continue;
}

foreach ($listener->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
if (! Str::is('handle*', $method->name) ||
! isset($method->getParameters()[0])) {
Expand Down
8 changes: 7 additions & 1 deletion src/Illuminate/Foundation/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ViewErrorBag;
use Whoops\Handler\HandlerInterface;
use Illuminate\Http\RedirectResponse;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Contracts\Container\Container;
Expand All @@ -24,6 +25,7 @@
use Symfony\Component\Debug\Exception\FlattenException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Contracts\Container\BindingResolutionException;
use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
Expand Down Expand Up @@ -350,7 +352,11 @@ protected function renderExceptionWithWhoops(Exception $e)
*/
protected function whoopsHandler()
{
return (new WhoopsHandler)->forDebug();
try {
return app(HandlerInterface::class);
} catch (BindingResolutionException $e) {
return (new WhoopsHandler)->forDebug();
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/ProviderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ protected function freshManifest(array $providers)
*/
public function writeManifest($manifest)
{
if (! is_writable(dirname($this->manifestPath))) {
throw new Exception('The bootstrap/cache directory must be present and writable.');
if (! is_writable($dirname = dirname($this->manifestPath))) {
throw new Exception("The {$dirname} directory must be present and writable.");
}

$this->files->replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ protected function registerQueueListenCommand()
*/
protected function registerQueueRestartCommand()
{
$this->app->singleton('command.queue.restart', function () {
return new QueueRestartCommand;
$this->app->singleton('command.queue.restart', function ($app) {
return new QueueRestartCommand($app['cache.store']);
});
}

Expand All @@ -660,7 +660,7 @@ protected function registerQueueRetryCommand()
protected function registerQueueWorkCommand()
{
$this->app->singleton('command.queue.work', function ($app) {
return new QueueWorkCommand($app['queue.worker']);
return new QueueWorkCommand($app['queue.worker'], $app['cache.store']);
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/Illuminate/Foundation/Testing/PendingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ protected function mockConsoleOutput()

foreach ($this->test->expectedQuestions as $i => $question) {
$mock->shouldReceive('askQuestion')
->once()
->ordered()
->with(Mockery::on(function ($argument) use ($question) {
return $argument->getQuestion() == $question[0];
Expand Down Expand Up @@ -194,6 +195,7 @@ private function createABufferedOutputMock()

foreach ($this->test->expectedOutput as $i => $output) {
$mock->shouldReceive('doWrite')
->once()
->ordered()
->with($output, Mockery::any())
->andReturnUsing(function () use ($i) {
Expand Down
10 changes: 9 additions & 1 deletion src/Illuminate/Foundation/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
use Throwable;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Facade;
use Illuminate\Database\Eloquent\Model;
use Mockery\Exception\InvalidCountException;
use Illuminate\Console\Application as Artisan;
use PHPUnit\Framework\TestCase as BaseTestCase;

Expand Down Expand Up @@ -166,7 +168,13 @@ protected function tearDown(): void
$this->addToAssertionCount($container->mockery_getExpectationCount());
}

Mockery::close();
try {
Mockery::close();
} catch (InvalidCountException $e) {
if (! Str::contains($e->getMethodName(), ['doWrite', 'askQuestion'])) {
throw $e;
}
}
}

if (class_exists(Carbon::class)) {
Expand Down
6 changes: 1 addition & 5 deletions src/Illuminate/Log/ParsesLogConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ protected function level(array $config)
*/
protected function parseChannel(array $config)
{
if (! isset($config['name'])) {
return $this->getFallbackChannelName();
}

return $config['name'];
return $config['name'] ?? $this->getFallbackChannelName();
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Notifications/NotificationSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function __construct($manager, $bus, $events, $locale = null)
{
$this->bus = $bus;
$this->events = $events;
$this->manager = $manager;
$this->locale = $locale;
$this->manager = $manager;
}

/**
Expand Down
9 changes: 4 additions & 5 deletions src/Illuminate/Pagination/LengthAwarePaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use JsonSerializable;
use IteratorAggregate;
use Illuminate\Support\Collection;
use Illuminate\Support\HtmlString;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Pagination\LengthAwarePaginator as LengthAwarePaginatorContract;
Expand Down Expand Up @@ -73,7 +72,7 @@ protected function setCurrentPage($currentPage, $pageName)
*
* @param string|null $view
* @param array $data
* @return \Illuminate\Support\HtmlString
* @return \Illuminate\Contracts\Support\Htmlable
*/
public function links($view = null, $data = [])
{
Expand All @@ -85,14 +84,14 @@ public function links($view = null, $data = [])
*
* @param string|null $view
* @param array $data
* @return \Illuminate\Support\HtmlString
* @return \Illuminate\Contracts\Support\Htmlable
*/
public function render($view = null, $data = [])
{
return new HtmlString(static::viewFactory()->make($view ?: static::$defaultView, array_merge($data, [
return static::viewFactory()->make($view ?: static::$defaultView, array_merge($data, [
'paginator' => $this,
'elements' => $this->elements(),
]))->render());
]));
}

/**
Expand Down
11 changes: 4 additions & 7 deletions src/Illuminate/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use JsonSerializable;
use IteratorAggregate;
use Illuminate\Support\Collection;
use Illuminate\Support\HtmlString;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Pagination\Paginator as PaginatorContract;
Expand Down Expand Up @@ -102,15 +101,13 @@ public function links($view = null, $data = [])
*
* @param string|null $view
* @param array $data
* @return string
* @return \Illuminate\Contracts\Support\Htmlable
*/
public function render($view = null, $data = [])
{
return new HtmlString(
static::viewFactory()->make($view ?: static::$defaultSimpleView, array_merge($data, [
'paginator' => $this,
]))->render()
);
return static::viewFactory()->make($view ?: static::$defaultSimpleView, array_merge($data, [
'paginator' => $this,
]));
}

/**
Expand Down
Loading

0 comments on commit f75dad1

Please sign in to comment.