Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Fix to prevent recursive where clause addition for chunkById #16498

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,26 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
return $this;
}

/**
* Adds an id limit to assist with Eloquent chunkById.
*
* Subsequent calls override previous limit.
*
* @param string $column
* @param int $value
* @return $this
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing return annotation

protected function chunkIdWhere($column, $value)
{
$where = compact('column', 'value');
$where['type'] = 'Basic';
$where['operator'] = '>';
$where['boolean'] = 'and';
$this->wheres['chunkId'] = $where;

return $this;
}

/**
* Add an array of where clauses to the query.
*
Expand Down Expand Up @@ -1498,7 +1518,7 @@ public function forPageAfterId($perPage = 15, $lastId = 0, $column = 'id')
return $order['column'] === $column;
})->values()->all();

return $this->where($column, '>', $lastId)
return $this->chunkIdWhere($column, $lastId)
->orderBy($column, 'asc')
->take($perPage);
}
Expand Down