Skip to content

Commit

Permalink
Merge pull request #18 from laravel/5.7
Browse files Browse the repository at this point in the history
5.7
  • Loading branch information
imanghafoori1 authored Feb 8, 2019
2 parents 35df766 + e2fd979 commit 13e80c4
Show file tree
Hide file tree
Showing 19 changed files with 351 additions and 29 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ language: php

env:
global:
- setup=stable
- SETUP=stable

matrix:
fast_finish: true
include:
- php: 7.1
- php: 7.1
env: setup=lowest
env: SETUP=lowest
- php: 7.2
- php: 7.2
env: setup=lowest
env: SETUP=lowest
- php: 7.3
- php: 7.3
env: setup=lowest
env: SETUP=lowest

cache:
directories:
Expand All @@ -35,7 +35,7 @@ before_install:
- mysql -e 'CREATE DATABASE forge;'

install:
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-stable --no-suggest; fi
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable --no-suggest; fi
- if [[ $SETUP = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-stable --no-suggest; fi
- if [[ $SETUP = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable --no-suggest; fi

script: vendor/bin/phpunit
17 changes: 16 additions & 1 deletion CHANGELOG-5.7.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Release Notes for 5.7.x

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


## [v5.7.25 (2019-02-05)](https://github.com/laravel/framework/compare/v5.7.24...v5.7.25)

### Added
- Allowed specifying custom translation for date relative messages ([#27341](https://github.com/laravel/framework/pull/27341))
- Add computed support to SQL Server schema grammar ([#27346](https://github.com/laravel/framework/pull/27346), [1c74d7f](https://github.com/laravel/framework/commit/1c74d7fe595df223279de55dffc7ae6fc8ac9ca6))
- Allowed `ENV` to control paths of `cache files` for `services`, `packages` and `routes` ([#27389](https://github.com/laravel/framework/pull/27389))

### Fixed
- Fixed `BelongsToMany` pivot relationship child with loaded relations wakeup ([#27358](https://github.com/laravel/framework/pull/27358))
- Fixed wrong class being used when eager loading nullable `MorphTo` with `withDefault()` ([#27411](https://github.com/laravel/framework/pull/27411))

### Changed
- Removed `php_network_getaddresses: getaddrinfo failed: Name or service not known` in `DetectsLostConnections` trait ([#27418](https://github.com/laravel/framework/pull/27418))


## [v5.7.24 (2019-01-30)](https://github.com/laravel/framework/compare/v5.7.23...v5.7.24)
Expand Down
10 changes: 10 additions & 0 deletions src/Illuminate/Cache/TaggedCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,14 @@ protected function event($event)
{
parent::event($event->setTags($this->tags->getNames()));
}

/**
* Get the tag set instance.
*
* @return \Illuminate\Cache\TagSet
*/
public function getTags()
{
return $this->tags;
}
}
1 change: 0 additions & 1 deletion src/Illuminate/Database/DetectsLostConnections.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ protected function causedByLostConnection(Throwable $e)
'reset by peer',
'Physical connection is not usable',
'TCP Provider: Error code 0x68',
'php_network_getaddresses: getaddrinfo failed: Name or service not known',
'ORA-03114',
'Packets out of order. Expected',
'Adaptive Server connection failed',
Expand Down
21 changes: 21 additions & 0 deletions src/Illuminate/Database/Eloquent/Concerns/HasEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,25 @@ public static function unsetEventDispatcher()
{
static::$dispatcher = null;
}

/**
* Execute a callback without firing any model events for any model type.
*
* @param callable $callback
* @return mixed
*/
public static function withoutEvents(callable $callback)
{
$dispatcher = static::getEventDispatcher();

static::unsetEventDispatcher();

try {
return $callback();
} finally {
if ($dispatcher) {
static::setEventDispatcher($dispatcher);
}
}
}
}
10 changes: 0 additions & 10 deletions src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,16 +415,6 @@ public function prepareBindingsForUpdate(array $bindings, array $values)
);
}

/**
* Determine if the grammar supports savepoints.
*
* @return bool
*/
public function supportsSavepoints()
{
return true;
}

/**
* Compile the SQL statement to define a savepoint.
*
Expand Down
18 changes: 9 additions & 9 deletions src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*
* @var string
*/
const VERSION = '5.7.24';
const VERSION = '5.7.25';

/**
* The base path for the Laravel installation.
Expand All @@ -55,14 +55,14 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
/**
* The array of booting callbacks.
*
* @var array
* @var callable[]
*/
protected $bootingCallbacks = [];

/**
* The array of booted callbacks.
*
* @var array
* @var callable[]
*/
protected $bootedCallbacks = [];

Expand Down Expand Up @@ -823,7 +823,7 @@ protected function bootProvider(ServiceProvider $provider)
/**
* Register a new boot listener.
*
* @param mixed $callback
* @param callable $callback
* @return void
*/
public function booting($callback)
Expand All @@ -834,7 +834,7 @@ public function booting($callback)
/**
* Register a new "booted" listener.
*
* @param mixed $callback
* @param callable $callback
* @return void
*/
public function booted($callback)
Expand All @@ -849,7 +849,7 @@ public function booted($callback)
/**
* Call the booting callbacks for the application.
*
* @param array $callbacks
* @param callable[] $callbacks
* @return void
*/
protected function fireAppCallbacks(array $callbacks)
Expand Down Expand Up @@ -885,7 +885,7 @@ public function shouldSkipMiddleware()
*/
public function getCachedServicesPath()
{
return $this->bootstrapPath().'/cache/services.php';
return $_ENV['APP_SERVICES_CACHE'] ?? $this->bootstrapPath().'/cache/services.php';
}

/**
Expand All @@ -895,7 +895,7 @@ public function getCachedServicesPath()
*/
public function getCachedPackagesPath()
{
return $this->bootstrapPath().'/cache/packages.php';
return $_ENV['APP_PACKAGES_CACHE'] ?? $this->bootstrapPath().'/cache/packages.php';
}

/**
Expand Down Expand Up @@ -935,7 +935,7 @@ public function routesAreCached()
*/
public function getCachedRoutesPath()
{
return $this->bootstrapPath().'/cache/routes.php';
return $_ENV['APP_ROUTES_CACHE'] ?? $this->bootstrapPath().'/cache/routes.php';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Http/Resources/MergeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MergeValue
/**
* Create new merge value instance.
*
* @param \Illuminate\Support\Collection|array $data
* @param \Illuminate\Support\Collection|\JsonSerializable|array $data
* @return void
*/
public function __construct($data)
Expand Down
12 changes: 12 additions & 0 deletions src/Illuminate/Pipeline/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ public function then(Closure $destination)
return $pipeline($this->passable);
}

/**
* Run the pipeline and return the result.
*
* @return mixed
*/
public function thenReturn()
{
return $this->then(function ($passable) {
return $passable;
});
}

/**
* Get the final piece of the Closure onion.
*
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ public function crossJoin(...$lists)
/**
* Dump the collection and end the script.
*
* @param mixed ...$args
* @return void
*/
public function dd(...$args)
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Testing/Fakes/EventFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function dispatch($event, $payload = [], $halt = false)
if ($this->shouldFakeEvent($name, $payload)) {
$this->events[$name][] = func_get_args();
} else {
$this->dispatcher->dispatch($event, $payload, $halt);
return $this->dispatcher->dispatch($event, $payload, $halt);
}
}

Expand Down
37 changes: 37 additions & 0 deletions tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,37 @@ public function testModelObserversCanBeAttachedToModelsThroughCallingObserveMeth
EloquentModelStub::flushEventListeners();
}

public function testWithoutEventDispatcher()
{
EloquentModelSaveStub::setEventDispatcher($events = m::mock(Dispatcher::class));
$events->shouldReceive('listen')->once()->with('eloquent.creating: Illuminate\Tests\Database\EloquentModelSaveStub', EloquentTestObserverStub::class.'@creating');
$events->shouldReceive('listen')->once()->with('eloquent.saved: Illuminate\Tests\Database\EloquentModelSaveStub', EloquentTestObserverStub::class.'@saved');
$events->shouldNotReceive('until');
$events->shouldNotReceive('dispatch');
$events->shouldReceive('forget');
EloquentModelSaveStub::observe(EloquentTestObserverStub::class);

$model = EloquentModelSaveStub::withoutEvents(function () {
$model = new EloquentModelSaveStub;
$model->save();

return $model;
});

$model->withoutEvents(function () use ($model) {
$model->first_name = 'Taylor';
$model->save();
});

$events->shouldReceive('until')->once()->with('eloquent.saving: Illuminate\Tests\Database\EloquentModelSaveStub', $model);
$events->shouldReceive('dispatch')->once()->with('eloquent.saved: Illuminate\Tests\Database\EloquentModelSaveStub', $model);

$model->last_name = 'Otwell';
$model->save();

EloquentModelSaveStub::flushEventListeners();
}

public function testSetObservableEvents()
{
$class = new EloquentModelStub;
Expand Down Expand Up @@ -1976,7 +2007,13 @@ class EloquentModelSaveStub extends Model

public function save(array $options = [])
{
if ($this->fireModelEvent('saving') === false) {
return false;
}

$_SERVER['__eloquent.saved'] = true;

$this->fireModelEvent('saved', false);
}

public function setIncrementing($value)
Expand Down
26 changes: 26 additions & 0 deletions tests/Foundation/FoundationApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,32 @@ public function testBeforeBootstrappingAddsClosure()
$this->assertArrayHasKey(0, $app['events']->getListeners('bootstrapping: Illuminate\Foundation\Bootstrap\RegisterFacades'));
}

public function testTerminationTests()
{
$app = new Application;

$result = [];
$callback1 = function () use (&$result) {
$result[] = 1;
};

$callback2 = function () use (&$result) {
$result[] = 2;
};

$callback3 = function () use (&$result) {
$result[] = 3;
};

$app->terminating($callback1);
$app->terminating($callback2);
$app->terminating($callback3);

$app->terminate();

$this->assertEquals([1, 2, 3], $result);
}

public function testAfterBootstrappingAddsClosure()
{
$app = new Application;
Expand Down
Loading

0 comments on commit 13e80c4

Please sign in to comment.