Skip to content

Commit b68d362

Browse files
committed
misc
1 parent 6d2b87a commit b68d362

7 files changed

Lines changed: 33 additions & 12 deletions

File tree

packages/database/src/Driver/Pdo/PdoMysqlConnection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public static function prepareDbOptions(DriverOptions $options): DriverOptions
3232
}
3333
} else {
3434
if (strtolower($params['charset']) === 'utf8mb4') {
35-
$options->driverOptions[\PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES utf8mb4';
35+
$options->driverOptions[Mysql::ATTR_INIT_COMMAND] = 'SET NAMES utf8mb4';
3636
} elseif (strtolower($params['charset']) === 'utf8') {
37-
$options->driverOptions[\PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES utf8';
37+
$options->driverOptions[Mysql::ATTR_INIT_COMMAND] = 'SET NAMES utf8';
3838
}
3939
}
4040

@@ -45,7 +45,7 @@ public function disableBufferedQuery(bool $buffered = true): static
4545
{
4646
$pdo = $this->get();
4747

48-
$pdo?->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, !$buffered);
48+
$pdo?->setAttribute(Mysql::ATTR_USE_BUFFERED_QUERY, !$buffered);
4949

5050
return $this;
5151
}

packages/database/src/Manager/WriterManager.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,16 @@ public function upsert(
220220
string $table,
221221
array|object $data,
222222
array|string $keys,
223+
array $options = [],
223224
): StatementInterface {
224225
$keys = (array) $keys;
225226

226227
$platformName = $this->db->getPlatform()->getName();
228+
$updateNulls = $options['updateNulls'] ?? false;
229+
230+
if (!$updateNulls) {
231+
$data = array_filter($data, fn($v) => $v !== null);
232+
}
227233

228234
$query = $this->db->createQuery();
229235

packages/filter/src/Rule/IPV6.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function getRegex(): string
2525
public function test(mixed $value, bool $strict = false): bool
2626
{
2727
return filter_var(
28+
$value,
2829
FILTER_VALIDATE_IP,
2930
FILTER_FLAG_IPV6
3031
);

packages/orm/src/EntityMapper.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ function () use ($initData, $data, $item, $options, $condFields, $conditions) {
996996

997997
public function upsert(
998998
array|object $item,
999-
?array $condFields = null,
999+
array|string|null $condFields = null,
10001000
ORMOptions $options = new ORMOptions()
10011001
): ?StatementInterface {
10021002
if ($item === []) {
@@ -1005,12 +1005,11 @@ public function upsert(
10051005

10061006
$metadata = $this->getMetadata();
10071007

1008-
$updateNulls = true;
1008+
$updateNulls = $options->updateNulls;
10091009

1010-
// $updateNulls = $options->updateNulls;
1011-
// if ($this->metadata::isEntity($item)) {
1012-
// $updateNulls = true;
1013-
// }
1010+
if ($this->metadata::isEntity($item)) {
1011+
$updateNulls = true;
1012+
}
10141013

10151014
if (!$condFields) {
10161015
$condFields = $this->getKeys();
@@ -1044,6 +1043,9 @@ public function upsert(
10441043
$metadata->getTableName(),
10451044
$data,
10461045
$condFields,
1046+
[
1047+
'updateNulls' => $updateNulls,
1048+
]
10471049
);
10481050
}
10491051

@@ -1740,7 +1742,12 @@ public function toEntity(array|object $data): object
17401742
}
17411743

17421744
if (is_object($data)) {
1743-
$data = ReflectAccessor::getPropertiesValues($data);
1745+
if (EntityMetadata::isEntity($data)) {
1746+
// Keep B/C that we must extract protected props from old entities.
1747+
$data = ReflectAccessor::getPropertiesValues($data);
1748+
} else {
1749+
$data = TypeCast::toArray($data);
1750+
}
17441751
}
17451752

17461753
// Only ORM has Hydrator, we must call ORM to do this.

packages/orm/src/ORM.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ORM implements EventAwareInterface
7575
*
7676
* @param DatabaseAdapter $db
7777
*/
78-
public function __construct(protected DatabaseAdapter $db)
78+
public function __construct(public protected(set) DatabaseAdapter $db)
7979
{
8080
$this->entityMetadataCollection = new EntityMetadataCollection($this);
8181

packages/orm/src/ORMProxyTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public function updateOneOrCreate(
384384
public function upsert(
385385
string $entityClass,
386386
array|object $item,
387-
?array $condFields = null,
387+
array|string|null $condFields = null,
388388
ORMOptions $options = new ORMOptions()
389389
): ?StatementInterface {
390390
return $this->mapper($entityClass)->upsert($item, $condFields, $options);

packages/session/src/Bridge/PhpBridge.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ public function writeClose(bool $unset = true): bool
230230
return $r;
231231
}
232232

233+
public function write(): bool
234+
{
235+
$data = $this->encodeData($this->storage);
236+
237+
return $this->handler->write($this->getId(), $data);
238+
}
239+
233240
/**
234241
* Close without write, only for Session::fork().
235242
*

0 commit comments

Comments
 (0)