Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 23, 2017
2 parents 26475a4 + da7b006 commit bb826ca
Show file tree
Hide file tree
Showing 19 changed files with 536 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
before_install:
- if [[ $TRAVIS_PHP_VERSION != 7.1 ]] ; then phpenv config-rm xdebug.ini; fi
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- pecl install -f redis
- travis_retry composer self-update

install:
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG-5.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Unreleased]

### Added
- Added `getManager()` and `setManager()` to queue worker ([#18452](https://github.com/laravel/framework/pull/18452))

## v5.4.16 (2017-03-21)

### Added
- Added PHPDBG detection to `runningInConsole()` ([#18198](https://github.com/laravel/framework/pull/18198))
- Added `Arr:wrap()` method ([#18216](https://github.com/laravel/framework/pull/18216))
Expand All @@ -14,9 +19,11 @@
- Added `Container::makeWith()` method ([#18271](https://github.com/laravel/framework/pull/18271), [#18320](https://github.com/laravel/framework/pull/18320))
- 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))
- 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))
- Added `-q` shorthand for `make:listener --queued` ([#18362](https://github.com/laravel/framework/pull/18362))
- Added `Model::setKeyType()` ([#18354](https://github.com/laravel/framework/pull/18354))
- 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))
- Added `pipeline()`, `transaction()`, and `executeRaw()` to `PhpRedisConnection` ([#18421](https://github.com/laravel/framework/pull/18421))
- Added `@isset()` directive ([#18425](https://github.com/laravel/framework/pull/18425))
- Added `tinyIncrements()` database schema method ([#18424](https://github.com/laravel/framework/pull/18424))

### Changed
- 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))
Expand All @@ -33,6 +40,9 @@
- Use `getAuthIdentifier()` method in broadcasters ([#18351](https://github.com/laravel/framework/pull/18351))
- Use atomic cache operation when checking for event overlaps ([8ebb5b8](https://github.com/laravel/framework/commit/8ebb5b859ae8f2382a1836a83a47542de234d63a))
- Return pretty JSON response from `HasInDatabase::failureDescription()` ([#18377](https://github.com/laravel/framework/pull/18377))
- Allow Validator extension to use array-style callable ([#18399](https://github.com/laravel/framework/pull/18399))
- Pass the condition value to query builder's `when()` method ([#18419](https://github.com/laravel/framework/pull/18419))
- Don't require returning the query from `when()` method ([#18422](https://github.com/laravel/framework/pull/18422))

### Fixed
- Fixed an issue with slots when passed content equals `null` ([#18246](https://github.com/laravel/framework/pull/18246))
Expand All @@ -43,6 +53,9 @@
- Allow `ImplicitRouteBinding` to match camelcase method parameter names ([#18307](https://github.com/laravel/framework/pull/18307), [4ae31a1](https://github.com/laravel/framework/commit/4ae31a154f81c2d76c7397dbdebfcac0e74e4ccd))
- Fixing weird behaviour of `Connection::getConfig()` when `null` was passed ([#18356](https://github.com/laravel/framework/pull/18356))
- Attempt to solve an issue with using `required_*` rules while the `ConvertEmptyStringToNull` middleware is applied ([#18376](https://github.com/laravel/framework/pull/18376))
- Fixed faking of model events ([d6cb75c](https://github.com/laravel/framework/commit/d6cb75c057009c6316d4efd865dccb3c4a5c7b36))
- Prevent model event result from firing observable events ([#18401](https://github.com/laravel/framework/pull/18401), [0607db0](https://github.com/laravel/framework/commit/0607db02ba9eeab0a22abe1dabb19536f4aa1ff2))
- Fix issue in `authorizeResource()` with compound names ([#18435](https://github.com/laravel/framework/pull/18435))


## v5.4.15 (2017-03-02)
Expand Down
92 changes: 92 additions & 0 deletions src/Illuminate/Database/Concerns/BuildsQueries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

namespace Illuminate\Database\Concerns;

trait BuildsQueries
{
/**
* Chunk the results of the query.
*
* @param int $count
* @param callable $callback
* @return bool
*/
public function chunk($count, callable $callback)
{
$this->enforceOrderBy();

$page = 1;

do {
// We'll execute the query for the given page and get the results. If there are
// no results we can just break and return from here. When there are results
// we will call the callback with the current chunk of these results here.
$results = $this->forPage($page, $count)->get();

$countResults = $results->count();

if ($countResults == 0) {
break;
}

// On each chunk result set, we will pass them to the callback and then let the
// developer take care of everything within the callback, which allows us to
// keep the memory low for spinning through large result sets for working.
if ($callback($results) === false) {
return false;
}

$page++;
} while ($countResults == $count);

return true;
}

/**
* Execute a callback over each item while chunking.
*
* @param callable $callback
* @param int $count
* @return bool
*/
public function each(callable $callback, $count = 1000)
{
return $this->chunk($count, function ($results) use ($callback) {
foreach ($results as $key => $value) {
if ($callback($value, $key) === false) {
return false;
}
}
});
}

/**
* Execute the query and get the first result.
*
* @param array $columns
* @return mixed
*/
public function first($columns = ['*'])
{
return $this->take(1)->get($columns)->first();
}

/**
* Apply the callback's query changes if the given "value" is true.
*
* @param mixed $value
* @param \Closure $callback
* @param \Closure $default
* @return mixed
*/
public function when($value, $callback, $default = null)
{
if ($value) {
return $callback($this, $value) ?: $this;
} elseif ($default) {
return $default($this, $value) ?: $this;
}

return $this;
}
}
91 changes: 2 additions & 89 deletions src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Str;
use Illuminate\Pagination\Paginator;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Database\Concerns\BuildsQueries;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Query\Builder as QueryBuilder;
Expand All @@ -17,7 +18,7 @@
*/
class Builder
{
use Concerns\QueriesRelationships;
use BuildsQueries, Concerns\QueriesRelationships;

/**
* The base query builder instance.
Expand Down Expand Up @@ -162,27 +163,6 @@ public function removedScopes()
return $this->removedScopes;
}

/**
* Apply the callback's query changes if the given "value" is true.
*
* @param bool $value
* @param \Closure $callback
* @param \Closure $default
* @return $this
*/
public function when($value, $callback, $default = null)
{
$builder = $this;

if ($value) {
$builder = $callback($builder);
} elseif ($default) {
$builder = $default($builder);
}

return $builder;
}

/**
* Add a where clause on the primary key to the query.
*
Expand Down Expand Up @@ -398,17 +378,6 @@ public function updateOrCreate(array $attributes, array $values = [])
});
}

/**
* Execute the query and get the first result.
*
* @param array $columns
* @return \Illuminate\Database\Eloquent\Model|static|null
*/
public function first($columns = ['*'])
{
return $this->take(1)->get($columns)->first();
}

/**
* Execute the query and get the first result or throw an exception.
*
Expand Down Expand Up @@ -620,44 +589,6 @@ public function cursor()
}
}

/**
* Chunk the results of the query.
*
* @param int $count
* @param callable $callback
* @return bool
*/
public function chunk($count, callable $callback)
{
$this->enforceOrderBy();

$page = 1;

do {
// We'll execute the query for the given page and get the results. If there are
// no results we can just break and return from here. When there are results
// we will call the callback with the current chunk of these results here.
$results = $this->forPage($page, $count)->get();

$countResults = $results->count();

if ($countResults == 0) {
break;
}

// On each chunk result set, we will pass them to the callback and then let the
// developer take care of everything within the callback, which allows us to
// keep the memory low for spinning through large result sets for working.
if ($callback($results) === false) {
return false;
}

$page++;
} while ($countResults == $count);

return true;
}

/**
* Chunk the results of a query by comparing numeric IDs.
*
Expand Down Expand Up @@ -714,24 +645,6 @@ protected function enforceOrderBy()
}
}

/**
* Execute a callback over each item while chunking.
*
* @param callable $callback
* @param int $count
* @return bool
*/
public function each(callable $callback, $count = 1000)
{
return $this->chunk($count, function ($results) use ($callback) {
foreach ($results as $key => $value) {
if ($callback($value, $key) === false) {
return false;
}
}
});
}

/**
* Get an array with the values of a given column.
*
Expand Down
Loading

0 comments on commit bb826ca

Please sign in to comment.