Skip to content

Commit

Permalink
Merge pull request #22 from laravel/5.8
Browse files Browse the repository at this point in the history
sbgs
  • Loading branch information
imanghafoori1 authored Mar 2, 2019
2 parents 62e5748 + 0062459 commit 9c94dfa
Show file tree
Hide file tree
Showing 81 changed files with 886 additions and 583 deletions.
20 changes: 19 additions & 1 deletion CHANGELOG-5.7.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# Release Notes for 5.7.x

## [Unreleased](https://github.com/laravel/framework/compare/v5.7.26...5.7)
## [Unreleased](https://github.com/laravel/framework/compare/v5.7.28...5.7)


## [v5.7.28 (2019-02-26)](https://github.com/laravel/framework/compare/v5.7.27...v5.7.28)

### Added
- Add support for `Pheanstalk 4.x` ([#27622](https://github.com/laravel/framework/pull/27622))
- Allow configuration of token guard keys ([#27585](https://github.com/laravel/framework/pull/27585))

### Changed
- Update vue preset to exclude `@babel/preset-react` ([#27645](https://github.com/laravel/framework/pull/27645))
- Reflash the session for the broadcasting auth call ([#27647](https://github.com/laravel/framework/pull/27647))
- Improving readability in `AuthenticateWithBasicAuth` Middleware ([#27661](https://github.com/laravel/framework/pull/27661))
- Use safe container getter on `Pipeline` ([#27648](https://github.com/laravel/framework/pull/27648))

### Fixed
- Fixed Postgres grammar when using union queries ([#27589](https://github.com/laravel/framework/pull/27589))
- Fixed an issue when using Mail::queue to queue Mailables ([#27618](https://github.com/laravel/framework/pull/27618))
- Fixed error in `Foundation\Exceptions\Handler` ([#27632](https://github.com/laravel/framework/pull/27632))


## [v5.7.26 (2019-02-12)](https://github.com/laravel/framework/compare/v5.7.25...v5.7.26)
Expand Down
23 changes: 21 additions & 2 deletions CHANGELOG-5.8.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# Release Notes for 5.8.x

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

## [v5.8.0 (TODO)](https://github.com/laravel/framework/compare/5.7...v5.8.0)

## [v5.8.2 (2019-02-27)](https://github.com/laravel/framework/compare/v5.8.1...v5.8.2)

### Fixed
- Fixed quoted environment variable parsing ([#27691](https://github.com/laravel/framework/pull/27691))


## [v5.8.1 (2019-02-27)](https://github.com/laravel/framework/compare/v5.8.0...v5.8.1)

### Added
- Added `Illuminate\View\FileViewFinder::setPaths()` ([#27678](https://github.com/laravel/framework/pull/27678))

### Changed
- Return fake objects from facades ([#27680](https://github.com/laravel/framework/pull/27680))

### Reverted
- reverted changes related to the `Facade` ([63d87d7](https://github.com/laravel/framework/commit/63d87d78e08cc502947f07ebbfa4993955339c5a))


## [v5.8.0 (2019-02-26)](https://github.com/laravel/framework/compare/5.7...v5.8.0)

Check the upgrade guide in the [Official Laravel Documentation](https://laravel.com/docs/5.8/upgrade).
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^3.0).",
"symfony/css-selector": "Required to use some of the crawler integration testing tools (^4.2).",
"symfony/dom-crawler": "Required to use most of the crawler integration testing tools (^4.2).",
"symfony/psr-http-message-bridge": "Required to psr7 bridging features (^1.1)."
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^1.1).",
"wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)."
},
"config": {
"sort-packages": true
Expand Down
20 changes: 13 additions & 7 deletions src/Illuminate/Auth/Access/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,20 @@ class Gate implements GateContract
* @param array $policies
* @param array $beforeCallbacks
* @param array $afterCallbacks
* @param callable $guessPolicyNamesUsingCallback
* @return void
*/
public function __construct(Container $container, callable $userResolver, array $abilities = [],
array $policies = [], array $beforeCallbacks = [], array $afterCallbacks = [])
array $policies = [], array $beforeCallbacks = [], array $afterCallbacks = [],
callable $guessPolicyNamesUsingCallback = null)
{
$this->policies = $policies;
$this->container = $container;
$this->abilities = $abilities;
$this->userResolver = $userResolver;
$this->afterCallbacks = $afterCallbacks;
$this->beforeCallbacks = $beforeCallbacks;
$this->guessPolicyNamesUsingCallback = $guessPolicyNamesUsingCallback;
}

/**
Expand Down Expand Up @@ -538,8 +541,10 @@ public function getPolicyFor($class)
return $this->resolvePolicy($this->policies[$class]);
}

if (class_exists($guessedPolicy = $this->guessPolicyName($class))) {
return $this->resolvePolicy($guessedPolicy);
foreach ($this->guessPolicyName($class) as $guessedPolicy) {
if (class_exists($guessedPolicy)) {
return $this->resolvePolicy($guessedPolicy);
}
}

foreach ($this->policies as $expected => $policy) {
Expand All @@ -553,17 +558,17 @@ public function getPolicyFor($class)
* Guess the policy name for the given class.
*
* @param string $class
* @return string
* @return array
*/
protected function guessPolicyName($class)
{
if ($this->guessPolicyNamesUsingCallback) {
return call_user_func($this->guessPolicyNamesUsingCallback, $class);
return Arr::wrap(call_user_func($this->guessPolicyNamesUsingCallback, $class));
}

$classDirname = str_replace('/', '\\', dirname(str_replace('\\', '/', $class)));

return $classDirname.'\\Policies\\'.class_basename($class).'Policy';
return [$classDirname.'\\Policies\\'.class_basename($class).'Policy'];
}

/**
Expand Down Expand Up @@ -698,7 +703,8 @@ public function forUser($user)

return new static(
$this->container, $callback, $this->abilities,
$this->policies, $this->beforeCallbacks, $this->afterCallbacks
$this->policies, $this->beforeCallbacks, $this->afterCallbacks,
$this->guessPolicyNamesUsingCallback
);
}

Expand Down
6 changes: 5 additions & 1 deletion src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ public function __construct(AuthFactory $auth)
* @param string|null $guard
* @param string|null $field
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
*/
public function handle($request, Closure $next, $guard = null, $field = null)
{
return $this->auth->guard($guard)->basic($field ?: 'email') ?: $next($request);
$this->auth->guard($guard)->basic($field ?: 'email');

return $next($request);
}
}
4 changes: 0 additions & 4 deletions src/Illuminate/Auth/RequestGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ public function validate(array $credentials = [])
*/
public function setRequest(Request $request)
{
if ($this->request !== $request) {
$this->user = null;
}

$this->request = $request;

return $this;
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Broadcasting/BroadcastController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class BroadcastController extends Controller
*/
public function authenticate(Request $request)
{
if ($request->hasSession()) {
$request->session()->reflash();
}

return Broadcast::auth($request);
}
}
5 changes: 5 additions & 0 deletions src/Illuminate/Container/BoundMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class BoundMethod
* @param array $parameters
* @param string|null $defaultMethod
* @return mixed
*
* @throws \ReflectionException
* @throws \InvalidArgumentException
*/
public static function call($container, $callback, array $parameters = [], $defaultMethod = null)
{
Expand Down Expand Up @@ -107,6 +110,8 @@ protected static function normalizeMethod($callback)
* @param callable|string $callback
* @param array $parameters
* @return array
*
* @throws \ReflectionException
*/
protected static function getMethodDependencies($container, $callback, array $parameters = [])
{
Expand Down
4 changes: 0 additions & 4 deletions src/Illuminate/Database/DatabaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ protected function registerConnectionServices()
$this->app->bind('db.connection', function ($app) {
return $app['db']->connection();
});

$this->app->bind('db.schema', function ($app) {
return $app['db']->connection()->getSchemaBuilder();
});
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -792,12 +792,17 @@ protected function asDateTime($value)
return Date::instance(Carbon::createFromFormat('Y-m-d', $value)->startOfDay());
}

$format = $this->getDateFormat();

// https://bugs.php.net/bug.php?id=75577
if (version_compare(PHP_VERSION, '7.3.0-dev', '<')) {
$format = str_replace('.v', '.u', $format);
}

// Finally, we will just assume this date is in the format used by default on
// the database connection and use that format to create the Carbon object
// that is returned back out to the developers after we convert it here.
return Date::createFromFormat(
str_replace('.v', '.u', $this->getDateFormat()), $value
);
return Date::createFromFormat($format, $value);
}

/**
Expand Down
28 changes: 27 additions & 1 deletion src/Illuminate/Database/Eloquent/Concerns/HasEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Database\Eloquent\Concerns;

use Illuminate\Support\Arr;
use InvalidArgumentException;
use Illuminate\Contracts\Events\Dispatcher;

trait HasEvents
Expand Down Expand Up @@ -30,6 +31,8 @@ trait HasEvents
*
* @param object|array|string $classes
* @return void
*
* @throws \RuntimeException
*/
public static function observe($classes)
{
Expand All @@ -45,10 +48,12 @@ public static function observe($classes)
*
* @param object|string $class
* @return void
*
* @throws \RuntimeException
*/
protected function registerObserver($class)
{
$className = is_string($class) ? $class : get_class($class);
$className = $this->resolveObserverClassName($class);

// When registering a model observer, we will spin through the possible events
// and determine if this observer has that method. If it does, we will hook
Expand All @@ -60,6 +65,27 @@ protected function registerObserver($class)
}
}

/**
* Resolve the observer's class name from an object or string.
*
* @param object|string $class
* @return string
*
* @throws \InvalidArgumentException
*/
private function resolveObserverClassName($class)
{
if (is_object($class)) {
return get_class($class);
}

if (class_exists($class)) {
return $class;
}

throw new InvalidArgumentException('Unable to find observer: '.$class);
}

/**
* Get the observable event names.
*
Expand Down
27 changes: 18 additions & 9 deletions src/Illuminate/Database/Eloquent/Relations/Concerns/AsPivot.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public static function fromAttributes(Model $parent, $attributes, $table, $exist
{
$instance = new static;

$instance->timestamps = $instance->hasTimestampAttributes($attributes);

// The pivot model is a "dynamic" model since we will set the tables dynamically
// for the instance. This allows it work for any intermediate tables for the
// many to many relationship that are defined by this developer's classes.
Expand All @@ -57,8 +59,6 @@ public static function fromAttributes(Model $parent, $attributes, $table, $exist

$instance->exists = $exists;

$instance->timestamps = $instance->hasTimestampAttributes();

return $instance;
}

Expand All @@ -75,9 +75,9 @@ public static function fromRawAttributes(Model $parent, $attributes, $table, $ex
{
$instance = static::fromAttributes($parent, [], $table, $exists);

$instance->setRawAttributes($attributes, true);
$instance->timestamps = $instance->hasTimestampAttributes($attributes);

$instance->timestamps = $instance->hasTimestampAttributes();
$instance->setRawAttributes($attributes, true);

return $instance;
}
Expand Down Expand Up @@ -111,10 +111,18 @@ protected function setKeysForSaveQuery(Builder $query)
public function delete()
{
if (isset($this->attributes[$this->getKeyName()])) {
return parent::delete();
return (int) parent::delete();
}

return $this->getDeleteQuery()->delete();
if ($this->fireModelEvent('deleting') === false) {
return 0;
}

$this->touchOwners();

return tap($this->getDeleteQuery()->delete(), function () {
$this->fireModelEvent('deleted', false);
});
}

/**
Expand Down Expand Up @@ -193,13 +201,14 @@ public function setPivotKeys($foreignKey, $relatedKey)
}

/**
* Determine if the pivot model has timestamp attributes.
* Determine if the pivot model or given attributes has timestamp attributes.
*
* @param $attributes array|null
* @return bool
*/
public function hasTimestampAttributes()
public function hasTimestampAttributes($attributes = null)
{
return array_key_exists($this->getCreatedAtColumn(), $this->attributes);
return array_key_exists($this->getCreatedAtColumn(), $attributes ?? $this->attributes);
}

/**
Expand Down
Loading

0 comments on commit 9c94dfa

Please sign in to comment.