Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/5.7' into 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
gabfr committed Nov 10, 2018
2 parents 2b36bfa + f546835 commit 1bf9d58
Show file tree
Hide file tree
Showing 56 changed files with 926 additions and 83 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG-5.7.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Release Notes for 5.7.x

## [v5.7.13 (2018-11-07)](https://github.com/laravel/framework/compare/v5.7.12...v5.7.13)

### Added
- Added ability to return an array of messages in a custom validation rule ([#26327](https://github.com/laravel/framework/pull/26327))
- Added `whenEmpty`/ `whenNotEmpty` / `unlessEmpty` / `unlessNotEmpty` methods to `Collection` ([#26345](https://github.com/laravel/framework/pull/26345))
- Added `Illuminate\Support\Collection::some` method ([#26376](https://github.com/laravel/framework/pull/26376), [8f7e647](https://github.com/laravel/framework/commit/8f7e647dcee5fe13d7fc33a1e0e1ce531ea9f49e))
- Added `Illuminate\Cache\Repository::missing` method ([#26351](https://github.com/laravel/framework/pull/26351))
- Added `Macroable` trait to `Illuminate\View\Factory` ([#26361](https://github.com/laravel/framework/pull/26361))
- Added support for UNION aggregate queries ([#26365](https://github.com/laravel/framework/pull/26365))

### Changed
- Updated `AbstractPaginator::appends` to handle null ([#26326](https://github.com/laravel/framework/pull/26326))
- Added "guzzlehttp/guzzle": "^6.3", to `composer.json` ([#26328](https://github.com/laravel/framework/pull/26328))
- Showed exception message on 403 error page when message is available ([#26356](https://github.com/laravel/framework/pull/26356))
- Don't run TransformsRequest twice on ?query= parameters ([#26366](https://github.com/laravel/framework/pull/26366))
- Added missing logging options to slack log driver ([#26360](https://github.com/laravel/framework/pull/26360))
- Use cascade when truncating table in PostgreSQL ([#26389](https://github.com/laravel/framework/pull/26389))
- Allowed pass absolute parameter in has valid signature request macro ([#26397](https://github.com/laravel/framework/pull/26397))

### Changed realization
- Used `Request::validate` macro in Auth traits ([#26314](https://github.com/laravel/framework/pull/26314))


## [v5.7.12 (2018-10-30)](https://github.com/laravel/framework/compare/v5.7.11...v5.7.12)

### Added
Expand Down
8 changes: 5 additions & 3 deletions src/Illuminate/Auth/Console/stubs/make/views/auth/login.stub
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@
{{ __('Login') }}
</button>

<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
</div>
</div>
</form>
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Cache/Console/ClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(CacheManager $cache, Filesystem $files)
*/
public function handle()
{
$this->laravel['events']->fire(
$this->laravel['events']->dispatch(
'cache:clearing', [$this->argument('store'), $this->tags()]
);

Expand All @@ -72,7 +72,7 @@ public function handle()
return $this->error('Failed to clear cache. Make sure you have the appropriate permissions.');
}

$this->laravel['events']->fire(
$this->laravel['events']->dispatch(
'cache:cleared', [$this->argument('store'), $this->tags()]
);

Expand Down
21 changes: 16 additions & 5 deletions src/Illuminate/Cache/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ public function has($key)
return ! is_null($this->get($key));
}

/**
* Determine if an item doesn't exist in the cache.
*
* @param string $key
* @return bool
*/
public function missing($key)
{
return ! $this->has($key);
}

/**
* Retrieve an item from the cache by key.
*
Expand Down Expand Up @@ -308,7 +319,7 @@ public function forever($key, $value)
}

/**
* Get an item from the cache, or store the default value.
* Get an item from the cache, or execute the given Closure and store the result.
*
* @param string $key
* @param \DateTimeInterface|\DateInterval|float|int $minutes
Expand All @@ -332,9 +343,9 @@ public function remember($key, $minutes, Closure $callback)
}

/**
* Get an item from the cache, or store the default value forever.
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param string $key
* @param \Closure $callback
* @return mixed
*/
Expand All @@ -344,9 +355,9 @@ public function sear($key, Closure $callback)
}

/**
* Get an item from the cache, or store the default value forever.
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param string $key
* @param \Closure $callback
* @return mixed
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ public function run(InputInterface $input = null, OutputInterface $output = null
$input = $input ?: new ArgvInput
);

$this->events->fire(
$this->events->dispatch(
new Events\CommandStarting(
$commandName, $input, $output = $output ?: new ConsoleOutput
)
);

$exitCode = parent::run($input, $output);

$this->events->fire(
$this->events->dispatch(
new Events\CommandFinished($commandName, $input, $output, $exitCode)
);

Expand Down
10 changes: 5 additions & 5 deletions src/Illuminate/Contracts/Cache/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function decrement($key, $value = 1);
public function forever($key, $value);

/**
* Get an item from the cache, or store the default value.
* Get an item from the cache, or execute the given Closure and store the result.
*
* @param string $key
* @param \DateTimeInterface|\DateInterval|float|int $minutes
Expand All @@ -91,18 +91,18 @@ public function forever($key, $value);
public function remember($key, $minutes, Closure $callback);

/**
* Get an item from the cache, or store the default value forever.
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param string $key
* @param \Closure $callback
* @return mixed
*/
public function sear($key, Closure $callback);

/**
* Get an item from the cache, or store the default value forever.
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param string $key
* @param \Closure $callback
* @return mixed
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Contracts/Validation/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function passes($attribute, $value);
/**
* Get the validation error message.
*
* @return string
* @return string|array
*/
public function message();
}
3 changes: 2 additions & 1 deletion src/Illuminate/Cookie/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace Illuminate\Cookie;

use Illuminate\Support\Arr;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Support\InteractsWithTime;
use Symfony\Component\HttpFoundation\Cookie;
use Illuminate\Contracts\Cookie\QueueingFactory as JarContract;

class CookieJar implements JarContract
{
use InteractsWithTime;
use InteractsWithTime, Macroable;

/**
* The default path (if specified).
Expand Down
22 changes: 18 additions & 4 deletions src/Illuminate/Database/Console/Migrations/TableGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

class TableGuesser
{
const CREATE_PATTERNS = [
'/^create_(\w+)_table$/',
'/^create_(\w+)$/',
];

const CHANGE_PATTERNS = [
'/_(to|from|in)_(\w+)_table$/',
'/_(to|from|in)_(\w+)$/',
];

/**
* Attempt to guess the table name and "creation" status of the given migration.
*
Expand All @@ -12,12 +22,16 @@ class TableGuesser
*/
public static function guess($migration)
{
if (preg_match('/^create_(\w+)_table$/', $migration, $matches)) {
return [$matches[1], $create = true];
foreach (self::CREATE_PATTERNS as $pattern) {
if (preg_match($pattern, $migration, $matches)) {
return [$matches[1], $create = true];
}
}

if (preg_match('/_(to|from|in)_(\w+)_table$/', $migration, $matches)) {
return [$matches[2], $create = false];
foreach (self::CHANGE_PATTERNS as $pattern) {
if (preg_match($pattern, $migration, $matches)) {
return [$matches[2], $create = false];
}
}
}
}
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ public function addEagerConstraints(array $models)
// our eagerly loading query so it returns the proper models from execution.
$key = $this->related->getTable().'.'.$this->ownerKey;

$this->query->whereIn($key, $this->getEagerModelKeys($models));
$whereIn = $this->whereInMethod($this->related, $this->ownerKey);

$this->query->{$whereIn}($key, $this->getEagerModelKeys($models));
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ protected function addWhereConstraints()
*/
public function addEagerConstraints(array $models)
{
$this->query->whereIn($this->getQualifiedForeignPivotKeyName(), $this->getKeys($models, $this->parentKey));
$whereIn = $this->whereInMethod($this->parent, $this->parentKey);

$this->query->{$whereIn}(
$this->getQualifiedForeignPivotKeyName(),
$this->getKeys($models, $this->parentKey)
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ public function throughParentSoftDeletes()
*/
public function addEagerConstraints(array $models)
{
$this->query->whereIn(
$whereIn = $this->whereInMethod($this->farParent, $this->localKey);

$this->query->{$whereIn}(
$this->getQualifiedFirstKeyName(), $this->getKeys($models, $this->localKey)
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public function addConstraints()
*/
public function addEagerConstraints(array $models)
{
$this->query->whereIn(
$whereIn = $this->whereInMethod($this->parent, $this->localKey);

$this->query->{$whereIn}(
$this->foreignKey, $this->getKeys($models, $this->localKey)
);
}
Expand Down
15 changes: 15 additions & 0 deletions src/Illuminate/Database/Eloquent/Relations/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,21 @@ public function relatedUpdatedAt()
return $this->related->getUpdatedAtColumn();
}

/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(Model $model, $key)
{
return $model->getKeyName() === last(explode('.', $key))
&& in_array($model->getKeyType(), ['int', 'integer'])
? 'whereInRaw'
: 'whereIn';
}

/**
* Set or get the morph map for polymorphic relations.
*
Expand Down
34 changes: 30 additions & 4 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,30 @@ protected function whereInExistingQuery($column, $query, $boolean, $not)
return $this;
}

/**
* Add a "where in raw" clause to the query.
*
* @param string $column
* @param array $values
* @param string $boolean
* @param bool $not
* @return $this
*/
public function whereInRaw($column, array $values, $boolean = 'and', $not = false)
{
$type = $not ? 'NotInRaw' : 'InRaw';

if ($values instanceof Arrayable) {
$values = $values->toArray();
}

$values = array_map('intval', $values);

$this->wheres[] = compact('type', 'column', 'values', 'boolean');

return $this;
}

/**
* Add a "where null" clause to the query.
*
Expand Down Expand Up @@ -2106,8 +2130,10 @@ public function getCountForPagination($columns = ['*'])
*/
protected function runPaginationCountQuery($columns = ['*'])
{
return $this->cloneWithout(['columns', 'orders', 'limit', 'offset'])
->cloneWithoutBindings(['select', 'order'])
$without = $this->unions ? ['orders', 'limit', 'offset'] : ['columns', 'orders', 'limit', 'offset'];

return $this->cloneWithout($without)
->cloneWithoutBindings($this->unions ? ['order'] : ['select', 'order'])
->setAggregate('count', $this->withoutSelectAliases($columns))
->get()->all();
}
Expand Down Expand Up @@ -2420,8 +2446,8 @@ public function average($column)
*/
public function aggregate($function, $columns = ['*'])
{
$results = $this->cloneWithout(['columns'])
->cloneWithoutBindings(['select'])
$results = $this->cloneWithout($this->unions ? [] : ['columns'])
->cloneWithoutBindings($this->unions ? [] : ['select'])
->setAggregate($function, $columns)
->get($columns);

Expand Down
Loading

0 comments on commit 1bf9d58

Please sign in to comment.