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(

Binary file not shown.

View File

@ -23,13 +23,13 @@
"ext-xml": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.52.1",
"illuminate/view": "^10.48.4",
"larastan/larastan": "^2.9.2",
"friendsofphp/php-cs-fixer": "^3.54.0",
"illuminate/view": "^10.48.8",
"larastan/larastan": "^2.9.5",
"laravel-zero/framework": "^10.3.0",
"mockery/mockery": "^1.6.11",
"nunomaduro/termwind": "^1.15.1",
"pestphp/pest": "^2.34.5"
"pestphp/pest": "^2.34.7"
},
"autoload": {
"psr-4": {

View File

@ -1,6 +1,7 @@
{
"name": "laravel/prompts",
"type": "library",
"description": "Add beautiful and user-friendly forms to your command-line applications.",
"license": "MIT",
"autoload": {
"psr-4": {

View File

@ -6,8 +6,12 @@ class Key
{
const UP = "\e[A";
const SHIFT_UP = "\e[1;2A";
const DOWN = "\e[B";
const SHIFT_DOWN = "\e[1;2B";
const RIGHT = "\e[C";
const LEFT = "\e[D";
@ -20,6 +24,8 @@ class Key
const LEFT_ARROW = "\eOD";
const ESCAPE = "\e";
const DELETE = "\e[3~";
const BACKSPACE = "\177";

View File

@ -113,7 +113,7 @@ class TextareaPrompt extends Prompt
$lines = collect($this->lines());
// Line length + 1 for the newline character
$lineLengths = $lines->map(fn ($line, $index) => mb_strwidth($line) + ($index === $lines->count() - 1 ? 0 : 1));
$lineLengths = $lines->map(fn ($line, $index) => mb_strlen($line) + ($index === $lines->count() - 1 ? 0 : 1));
$currentLineIndex = $this->currentLineIndex();
@ -145,13 +145,13 @@ class TextareaPrompt extends Prompt
$lines = collect($this->lines());
// Line length + 1 for the newline character
$lineLengths = $lines->map(fn ($line, $index) => mb_strwidth($line) + ($index === $lines->count() - 1 ? 0 : 1));
$lineLengths = $lines->map(fn ($line, $index) => mb_strlen($line) + ($index === $lines->count() - 1 ? 0 : 1));
$currentLineIndex = $this->currentLineIndex();
if ($currentLineIndex === $lines->count() - 1) {
// They're already at the last line, jump them to the last position
$this->cursorPosition = mb_strwidth($lines->implode(PHP_EOL));
$this->cursorPosition = mb_strlen($lines->implode(PHP_EOL));
return;
}
@ -205,7 +205,7 @@ class TextareaPrompt extends Prompt
$totalLineLength = 0;
return (int) collect($this->lines())->search(function ($line) use (&$totalLineLength) {
$totalLineLength += mb_strwidth($line) + 1;
$totalLineLength += mb_strlen($line) + 1;
return $totalLineLength > $this->cursorPosition;
}) ?: 0;

View File

@ -6,6 +6,8 @@ use Laravel\Prompts\Prompt;
trait DrawsBoxes
{
use InteractsWithStrings;
protected int $minWidth = 60;
/**
@ -55,44 +57,4 @@ trait DrawsBoxes
return $this;
}
/**
* Get the length of the longest line.
*
* @param array<string> $lines
*/
protected function longest(array $lines, int $padding = 0): int
{
return max(
$this->minWidth,
collect($lines)
->map(fn ($line) => mb_strwidth($this->stripEscapeSequences($line)) + $padding)
->max()
);
}
/**
* Pad text ignoring ANSI escape sequences.
*/
protected function pad(string $text, int $length): string
{
$rightPadding = str_repeat(' ', max(0, $length - mb_strwidth($this->stripEscapeSequences($text))));
return "{$text}{$rightPadding}";
}
/**
* Strip ANSI escape sequences from the given text.
*/
protected function stripEscapeSequences(string $text): string
{
// Strip ANSI escape sequences.
$text = preg_replace("/\e[^m]*m/", '', $text);
// Strip Symfony named style tags.
$text = preg_replace("/<(info|comment|question|error)>(.*?)<\/\\1>/", '$2', $text);
// Strip Symfony inline style tags.
return preg_replace("/<(?:(?:[fb]g|options)=[a-z,;]+)+>(.*?)<\/>/i", '$1', $text);
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace Laravel\Prompts\Themes\Default\Concerns;
trait InteractsWithStrings
{
/**
* Get the length of the longest line.
*
* @param array<string> $lines
*/
protected function longest(array $lines, int $padding = 0): int
{
return max(
$this->minWidth,
collect($lines)
->map(fn ($line) => mb_strwidth($this->stripEscapeSequences($line)) + $padding)
->max()
);
}
/**
* Pad text ignoring ANSI escape sequences.
*/
protected function pad(string $text, int $length, string $char = ' '): string
{
$rightPadding = str_repeat($char, max(0, $length - mb_strwidth($this->stripEscapeSequences($text))));
return "{$text}{$rightPadding}";
}
/**
* Strip ANSI escape sequences from the given text.
*/
protected function stripEscapeSequences(string $text): string
{
// Strip ANSI escape sequences.
$text = preg_replace("/\e[^m]*m/", '', $text);
// Strip Symfony named style tags.
$text = preg_replace("/<(info|comment|question|error)>(.*?)<\/\\1>/", '$2', $text);
// Strip Symfony inline style tags.
return preg_replace("/<(?:(?:[fb]g|options)=[a-z,;]+)+>(.*?)<\/>/i", '$1', $text);
}
}