Skip to content

Commit ffab5fc

Browse files
committed
Merge branch '10.x' of github.com:laravel/framework into 10.x
2 parents 6758bc0 + e1e7cd1 commit ffab5fc

File tree

15 files changed

+135
-73
lines changed

15 files changed

+135
-73
lines changed

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
# Release Notes for 10.x
22

3-
## [Unreleased](https://github.com/laravel/framework/compare/v10.48.15...10.x)
3+
## [Unreleased](https://github.com/laravel/framework/compare/v10.48.18...10.x)
4+
5+
## [v10.48.18](https://github.com/laravel/framework/compare/v10.48.17...v10.48.18) - 2024-07-30
6+
7+
* [10.x] backport #52188 by [@calebdw](https://github.com/calebdw) in https://github.com/laravel/framework/pull/52293
8+
* [10.x] Fix runPaginationCountQuery not working properly for union queries by [@chinleung](https://github.com/chinleung) in https://github.com/laravel/framework/pull/52314
9+
10+
## [v10.48.17](https://github.com/laravel/framework/compare/v10.48.16...v10.48.17) - 2024-07-23
11+
12+
* [10.x] Fix PHP_CLI_SERVER_WORKERS warning by suppressing it by [@pelomedusa](https://github.com/pelomedusa) in https://github.com/laravel/framework/pull/52094
13+
* [10.x] Backport #51615 by [@GrahamCampbell](https://github.com/GrahamCampbell) in https://github.com/laravel/framework/pull/52215
14+
15+
## [v10.48.16](https://github.com/laravel/framework/compare/v10.48.15...v10.48.16) - 2024-07-09
16+
17+
* [10.x] Fix Http::retry so that throw is respected for call signature Http::retry([1,2], throw: false) by [@paulyoungnb](https://github.com/paulyoungnb) in https://github.com/laravel/framework/pull/52002
18+
* [10.x] Set application_name and character set as PostgreSQL DSN string by [@sunaoka](https://github.com/sunaoka) in https://github.com/laravel/framework/pull/51985
419

520
## [v10.48.15](https://github.com/laravel/framework/compare/v10.48.14...v10.48.15) - 2024-07-02
621

src/Illuminate/Database/Connectors/PostgresConnector.php

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,13 @@ public function connect(array $config)
3838

3939
$this->configureIsolationLevel($connection, $config);
4040

41-
$this->configureEncoding($connection, $config);
42-
4341
// Next, we will check to see if a timezone has been specified in this config
4442
// and if it has we will issue a statement to modify the timezone with the
4543
// database. Setting this DB timezone is an optional configuration item.
4644
$this->configureTimezone($connection, $config);
4745

4846
$this->configureSearchPath($connection, $config);
4947

50-
// Postgres allows an application_name to be set by the user and this name is
51-
// used to when monitoring the application with pg_stat_activity. So we'll
52-
// determine if the option has been specified and run a statement if so.
53-
$this->configureApplicationName($connection, $config);
54-
5548
$this->configureSynchronousCommit($connection, $config);
5649

5750
return $connection;
@@ -71,22 +64,6 @@ protected function configureIsolationLevel($connection, array $config)
7164
}
7265
}
7366

74-
/**
75-
* Set the connection character set and collation.
76-
*
77-
* @param \PDO $connection
78-
* @param array $config
79-
* @return void
80-
*/
81-
protected function configureEncoding($connection, $config)
82-
{
83-
if (! isset($config['charset'])) {
84-
return;
85-
}
86-
87-
$connection->prepare("set names '{$config['charset']}'")->execute();
88-
}
89-
9067
/**
9168
* Set the timezone on the connection.
9269
*
@@ -132,22 +109,6 @@ protected function quoteSearchPath($searchPath)
132109
return count($searchPath) === 1 ? '"'.$searchPath[0].'"' : '"'.implode('", "', $searchPath).'"';
133110
}
134111

135-
/**
136-
* Set the application name on the connection.
137-
*
138-
* @param \PDO $connection
139-
* @param array $config
140-
* @return void
141-
*/
142-
protected function configureApplicationName($connection, $config)
143-
{
144-
if (isset($config['application_name'])) {
145-
$applicationName = $config['application_name'];
146-
147-
$connection->prepare("set application_name to '$applicationName'")->execute();
148-
}
149-
}
150-
151112
/**
152113
* Create a DSN string from a configuration.
153114
*
@@ -178,6 +139,17 @@ protected function getDsn(array $config)
178139
$dsn .= ";port={$port}";
179140
}
180141

142+
if (isset($charset)) {
143+
$dsn .= ";client_encoding='{$charset}'";
144+
}
145+
146+
// Postgres allows an application_name to be set by the user and this name is
147+
// used to when monitoring the application with pg_stat_activity. So we'll
148+
// determine if the option has been specified and run a statement if so.
149+
if (isset($application_name)) {
150+
$dsn .= ";application_name='".str_replace("'", "\'", $application_name)."'";
151+
}
152+
181153
return $this->addSslOptions($dsn, $config);
182154
}
183155

src/Illuminate/Database/Eloquent/Factories/Factory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ public function afterMaking(Closure $callback)
676676
/**
677677
* Add a new "after creating" callback to the model definition.
678678
*
679-
* @param \Closure(\Illuminate\Database\Eloquent\Model|TModel): mixed $callback
679+
* @param \Closure(\Illuminate\Database\Eloquent\Model|TModel, \Illuminate\Database\Eloquent\Model|null): mixed $callback
680680
* @return static
681681
*/
682682
public function afterCreating(Closure $callback)

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Illuminate\Support\Collection as BaseCollection;
2121
use Illuminate\Support\Str;
2222
use Illuminate\Support\Traits\ForwardsCalls;
23+
use JsonException;
2324
use JsonSerializable;
2425
use LogicException;
2526

@@ -1646,10 +1647,10 @@ public function toArray()
16461647
*/
16471648
public function toJson($options = 0)
16481649
{
1649-
$json = json_encode($this->jsonSerialize(), $options);
1650-
1651-
if (json_last_error() !== JSON_ERROR_NONE) {
1652-
throw JsonEncodingException::forModel($this, json_last_error_msg());
1650+
try {
1651+
$json = json_encode($this->jsonSerialize(), $options | JSON_THROW_ON_ERROR);
1652+
} catch (JsonException $e) {
1653+
throw JsonEncodingException::forModel($this, $e->getMessage());
16531654
}
16541655

16551656
return $json;
@@ -2122,7 +2123,7 @@ protected function childRouteBindingRelationshipName($childType)
21222123
/**
21232124
* Retrieve the model for a bound value.
21242125
*
2125-
* @param \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\Relation $query
2126+
* @param \Illuminate\Database\Eloquent\Model|\Illuminate\Contracts\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Relations\Relation $query
21262127
* @param mixed $value
21272128
* @param string|null $field
21282129
* @return \Illuminate\Database\Eloquent\Relations\Relation

src/Illuminate/Database/Query/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,10 +3016,10 @@ protected function runPaginationCountQuery($columns = ['*'])
30163016
->get()->all();
30173017
}
30183018

3019-
$without = $this->unions ? ['orders', 'limit', 'offset'] : ['columns', 'orders', 'limit', 'offset'];
3019+
$without = $this->unions ? ['unionOrders', 'unionLimit', 'unionOffset'] : ['columns', 'orders', 'limit', 'offset'];
30203020

30213021
return $this->cloneWithout($without)
3022-
->cloneWithoutBindings($this->unions ? ['order'] : ['select', 'order'])
3022+
->cloneWithoutBindings($this->unions ? ['unionOrder'] : ['select', 'order'])
30233023
->setAggregate('count', $this->withoutSelectAliases($columns))
30243024
->get()->all();
30253025
}

src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function compileColumns($table)
123123
return sprintf(
124124
'select name, type, not "notnull" as "nullable", dflt_value as "default", pk as "primary" '
125125
.'from pragma_table_info(%s) order by cid asc',
126-
$this->wrap(str_replace('.', '__', $table))
126+
$this->quoteString(str_replace('.', '__', $table))
127127
);
128128
}
129129

@@ -136,12 +136,12 @@ public function compileColumns($table)
136136
public function compileIndexes($table)
137137
{
138138
return sprintf(
139-
'select "primary" as name, group_concat(col) as columns, 1 as "unique", 1 as "primary" '
139+
'select \'primary\' as name, group_concat(col) as columns, 1 as "unique", 1 as "primary" '
140140
.'from (select name as col from pragma_table_info(%s) where pk > 0 order by pk, cid) group by name '
141-
.'union select name, group_concat(col) as columns, "unique", origin = "pk" as "primary" '
141+
.'union select name, group_concat(col) as columns, "unique", origin = \'pk\' as "primary" '
142142
.'from (select il.*, ii.name as col from pragma_index_list(%s) il, pragma_index_info(il.name) ii order by il.seq, ii.seqno) '
143143
.'group by name, "unique", "primary"',
144-
$table = $this->wrap(str_replace('.', '__', $table)),
144+
$table = $this->quoteString(str_replace('.', '__', $table)),
145145
$table
146146
);
147147
}
@@ -159,7 +159,7 @@ public function compileForeignKeys($table)
159159
.'group_concat("to") as foreign_columns, on_update, on_delete '
160160
.'from (select * from pragma_foreign_key_list(%s) order by id desc, seq) '
161161
.'group by id, "table", on_update, on_delete',
162-
$this->wrap(str_replace('.', '__', $table))
162+
$this->quoteString(str_replace('.', '__', $table))
163163
);
164164
}
165165

src/Illuminate/Foundation/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
4040
*
4141
* @var string
4242
*/
43-
const VERSION = '10.48.15';
43+
const VERSION = '10.48.18';
4444

4545
/**
4646
* The base path for the Laravel installation.

src/Illuminate/Foundation/Console/ServeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ protected function handleProcessOutput()
295295

296296
$this->output->write(' '.str_repeat('<fg=gray>.</>', $dots));
297297
$this->output->writeln(" <fg=gray>~ {$runTime}s</>");
298-
} elseif (str($line)->contains(['Closed without sending a request'])) {
298+
} elseif (str($line)->contains(['Closed without sending a request', 'Failed to poll event'])) {
299299
// ...
300300
} elseif (! empty($line)) {
301301
$position = strpos($line, '] ');

src/Illuminate/Http/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ public function get(string $key, mixed $default = null): mixed
404404
public function json($key = null, $default = null)
405405
{
406406
if (! isset($this->json)) {
407-
$this->json = new InputBag((array) json_decode($this->getContent(), true));
407+
$this->json = new InputBag((array) json_decode($this->getContent() ?: '[]', true));
408408
}
409409

410410
if (is_null($key)) {

src/Illuminate/Http/Resources/Json/JsonResource.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Illuminate\Http\Request;
1313
use Illuminate\Http\Resources\ConditionallyLoadsAttributes;
1414
use Illuminate\Http\Resources\DelegatesToResource;
15+
use JsonException;
1516
use JsonSerializable;
1617

1718
class JsonResource implements ArrayAccess, JsonSerializable, Responsable, UrlRoutable
@@ -144,10 +145,10 @@ public function toArray(Request $request)
144145
*/
145146
public function toJson($options = 0)
146147
{
147-
$json = json_encode($this->jsonSerialize(), $options);
148-
149-
if (json_last_error() !== JSON_ERROR_NONE) {
150-
throw JsonEncodingException::forResource($this, json_last_error_msg());
148+
try {
149+
$json = json_encode($this->jsonSerialize(), $options | JSON_THROW_ON_ERROR);
150+
} catch (JsonException $e) {
151+
throw JsonEncodingException::forResource($this, $e->getMessage());
151152
}
152153

153154
return $json;

0 commit comments

Comments
 (0)