This commit is contained in:
Sampanna Rimal
2024-09-04 12:22:04 +05:45
parent 53c0140f58
commit 82fab174dc
203 changed files with 4255 additions and 1343 deletions

View File

@ -1,6 +1,17 @@
# Release Notes for 10.x
## [Unreleased](https://github.com/laravel/framework/compare/v10.48.7...10.x)
## [Unreleased](https://github.com/laravel/framework/compare/v10.48.9...10.x)
## [v10.48.9](https://github.com/laravel/framework/compare/v10.48.8...v10.48.9) - 2024-04-23
* [10.x] Binding order is incorrect when using cursor paginate with multiple unions with a where by [@thijsvdanker](https://github.com/thijsvdanker) in https://github.com/laravel/framework/pull/50884
* [10.x] Fix cursor paginate with union and column alias by [@thijsvdanker](https://github.com/thijsvdanker) in https://github.com/laravel/framework/pull/50882
* [10.x] Address Null Parameter Deprecations in UrlGenerator by [@aldobarr](https://github.com/aldobarr) in https://github.com/laravel/framework/pull/51148
## [v10.48.8](https://github.com/laravel/framework/compare/v10.48.7...v10.48.8) - 2024-04-17
* [10.x] Fix error when using `orderByRaw()` in query before using `cursorPaginate()` by @axlon in https://github.com/laravel/framework/pull/51023
* [10.x] Database layer fixes by @saadsidqui in https://github.com/laravel/framework/pull/49787
## [v10.48.7](https://github.com/laravel/framework/compare/v10.48.6...v10.48.7) - 2024-04-10

View File

@ -379,11 +379,14 @@ trait BuildsQueries
$orders = $this->ensureOrderForCursorPagination(! is_null($cursor) && $cursor->pointsToPreviousItems());
if (! is_null($cursor)) {
$addCursorConditions = function (self $builder, $previousColumn, $i) use (&$addCursorConditions, $cursor, $orders) {
$unionBuilders = isset($builder->unions) ? collect($builder->unions)->pluck('query') : collect();
// Reset the union bindings so we can add the cursor where in the correct position...
$this->setBindings([], 'union');
$addCursorConditions = function (self $builder, $previousColumn, $originalColumn, $i) use (&$addCursorConditions, $cursor, $orders) {
$unionBuilders = $builder->getUnionBuilders();
if (! is_null($previousColumn)) {
$originalColumn = $this->getOriginalColumnNameForCursorPagination($this, $previousColumn);
$originalColumn ??= $this->getOriginalColumnNameForCursorPagination($this, $previousColumn);
$builder->where(
Str::contains($originalColumn, ['(', ')']) ? new Expression($originalColumn) : $originalColumn,
@ -393,7 +396,7 @@ trait BuildsQueries
$unionBuilders->each(function ($unionBuilder) use ($previousColumn, $cursor) {
$unionBuilder->where(
$this->getOriginalColumnNameForCursorPagination($this, $previousColumn),
$this->getOriginalColumnNameForCursorPagination($unionBuilder, $previousColumn),
'=',
$cursor->parameter($previousColumn)
);
@ -402,44 +405,48 @@ trait BuildsQueries
});
}
$builder->where(function (self $builder) use ($addCursorConditions, $cursor, $orders, $i, $unionBuilders) {
$builder->where(function (self $secondBuilder) use ($addCursorConditions, $cursor, $orders, $i, $unionBuilders) {
['column' => $column, 'direction' => $direction] = $orders[$i];
$originalColumn = $this->getOriginalColumnNameForCursorPagination($this, $column);
$builder->where(
$secondBuilder->where(
Str::contains($originalColumn, ['(', ')']) ? new Expression($originalColumn) : $originalColumn,
$direction === 'asc' ? '>' : '<',
$cursor->parameter($column)
);
if ($i < $orders->count() - 1) {
$builder->orWhere(function (self $builder) use ($addCursorConditions, $column, $i) {
$addCursorConditions($builder, $column, $i + 1);
$secondBuilder->orWhere(function (self $thirdBuilder) use ($addCursorConditions, $column, $originalColumn, $i) {
$addCursorConditions($thirdBuilder, $column, $originalColumn, $i + 1);
});
}
$unionBuilders->each(function ($unionBuilder) use ($column, $direction, $cursor, $i, $orders, $addCursorConditions) {
$unionBuilder->where(function ($unionBuilder) use ($column, $direction, $cursor, $i, $orders, $addCursorConditions) {
$unionWheres = $unionBuilder->getRawBindings()['where'];
$originalColumn = $this->getOriginalColumnNameForCursorPagination($unionBuilder, $column);
$unionBuilder->where(function ($unionBuilder) use ($column, $direction, $cursor, $i, $orders, $addCursorConditions, $originalColumn, $unionWheres) {
$unionBuilder->where(
$this->getOriginalColumnNameForCursorPagination($this, $column),
$originalColumn,
$direction === 'asc' ? '>' : '<',
$cursor->parameter($column)
);
if ($i < $orders->count() - 1) {
$unionBuilder->orWhere(function (self $builder) use ($addCursorConditions, $column, $i) {
$addCursorConditions($builder, $column, $i + 1);
$unionBuilder->orWhere(function (self $fourthBuilder) use ($addCursorConditions, $column, $originalColumn, $i) {
$addCursorConditions($fourthBuilder, $column, $originalColumn, $i + 1);
});
}
$this->addBinding($unionWheres, 'union');
$this->addBinding($unionBuilder->getRawBindings()['where'], 'union');
});
});
});
};
$addCursorConditions($this, null, 0);
$addCursorConditions($this, null, null, 0);
}
$this->limit($perPage + 1);

View File

@ -19,6 +19,7 @@ trait DetectsLostConnections
return Str::contains($message, [
'server has gone away',
'Server has gone away',
'no connection to the server',
'Lost connection',
'is dead or not enabled',

View File

@ -108,6 +108,7 @@ class Builder implements BuilderContract
'getbindings',
'getconnection',
'getgrammar',
'getrawbindings',
'implode',
'insert',
'insertgetid',
@ -1727,6 +1728,18 @@ class Builder implements BuilderContract
: $scope();
}
/**
* Get the Eloquent builder instances that are used in the union of the query.
*
* @return \Illuminate\Support\Collection
*/
protected function getUnionBuilders()
{
return isset($this->query->unions)
? collect($this->query->unions)->pluck('query')
: collect();
}
/**
* Get the underlying query builder instance.
*

View File

@ -3815,6 +3815,18 @@ class Builder implements BuilderContract
return $this->connection->raw($value);
}
/**
* Get the query builder instances that are used in the union of the query.
*
* @return \Illuminate\Support\Collection
*/
protected function getUnionBuilders()
{
return isset($this->unions)
? collect($this->unions)->pluck('query')
: collect();
}
/**
* Get the current query value bindings in a flattened array.
*

View File

@ -40,7 +40,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
*
* @var string
*/
const VERSION = '10.48.8';
const VERSION = '10.48.10';
/**
* The base path for the Laravel installation.
@ -535,6 +535,10 @@ class Application extends Container implements ApplicationContract, CachesConfig
return $this->joinPaths($this->storagePath ?: $_ENV['LARAVEL_STORAGE_PATH'], $path);
}
if (isset($_SERVER['LARAVEL_STORAGE_PATH'])) {
return $this->joinPaths($this->storagePath ?: $_SERVER['LARAVEL_STORAGE_PATH'], $path);
}
return $this->joinPaths($this->storagePath ?: $this->basePath('storage'), $path);
}

View File

@ -310,7 +310,7 @@ class TestResponse implements ArrayAccess
public function assertLocation($uri)
{
PHPUnit::assertEquals(
app('url')->to($uri), app('url')->to($this->headers->get('Location'))
app('url')->to($uri), app('url')->to($this->headers->get('Location', ''))
);
return $this;
@ -324,7 +324,7 @@ class TestResponse implements ArrayAccess
*/
public function assertDownload($filename = null)
{
$contentDisposition = explode(';', $this->headers->get('content-disposition'));
$contentDisposition = explode(';', $this->headers->get('content-disposition', ''));
if (trim($contentDisposition[0]) !== 'attachment') {
PHPUnit::fail(