Skip to content

Commit 43f2d53

Browse files
committed
Merge branch 'release-3.0' of github.com:SimpleMachines/SMF into reactions
2 parents f2feb5f + af86a96 commit 43f2d53

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

Sources/Db/APIs/PostgreSQL.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,21 +411,13 @@ public function insert(string $method, string $table, array $columns, array $dat
411411

412412
// PostgreSQL doesn't support replace: we implement a MySQL-compatible behavior instead
413413
if ($method == 'replace' || $method == 'ignore') {
414-
$key_str = '';
414+
$key_str = implode(',', $keys);
415415
$col_str = '';
416-
417416
$count = 0;
418-
$count_pk = 0;
419417

418+
// Make a list of the non-pk fields.
420419
foreach ($columns as $columnName => $type) {
421-
// Check pk field.
422-
if (\in_array($columnName, $keys)) {
423-
$key_str .= ($count_pk > 0 ? ',' : '');
424-
$key_str .= $columnName;
425-
$count_pk++;
426-
}
427-
// Normal field.
428-
elseif ($method == 'replace') {
420+
if (!\in_array($columnName, $keys) && ($method == 'replace')) {
429421
$col_str .= ($count > 0 ? ',' : '');
430422
$col_str .= $columnName . ' = EXCLUDED.' . $columnName;
431423
$count++;

Sources/Db/Schema/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public function populate(bool $replace = false): int
547547
table: '{db_prefix}' . $this->name,
548548
columns: Db::$db->getTypeIndicators('{db_prefix}' . $this->name, reset($this->initial_data)),
549549
data: array_map(fn($row) => array_values($row), $this->initial_data),
550-
keys: isset($auto_col) ? [$auto_col] : [],
550+
keys: isset($auto_col) ? [$auto_col] : array_column($this->indexes['primary']->columns, 'name'),
551551
returnmode: $returnmode,
552552
);
553553

Sources/Utils.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,11 +1979,13 @@ public static function emitFile(\ArrayAccess|array $file, bool $show_thumb = fal
19791979
// Provide a plain ASCII name for the sake of old browsers.
19801980
if (preg_match('/[\x{80}-\x{10FFFF}]/u', $file['filename'])) {
19811981
$file['asciiname'] = Localization\AsciiTransliterator::toAscii($file['filename'], '?');
1982-
}
19831982

1984-
// Replace ASCII names like ??????.jpg with something more unique.
1985-
if (strspn($file['asciiname'], '?') === strpos($file['asciiname'], '.')) {
1986-
$file['asciiname'] = md5($file['filename']) . substr($file['asciiname'], strpos($file['asciiname'], '.'));
1983+
// Replace ASCII names like ??????.jpg with something more unique.
1984+
if (strspn($file['asciiname'], '?') === strpos($file['asciiname'], '.')) {
1985+
$file['asciiname'] = md5($file['filename']) . substr($file['asciiname'], strpos($file['asciiname'], '.'));
1986+
}
1987+
} else {
1988+
$file['asciiname'] = $file['filename'];
19871989
}
19881990

19891991
// Clear any output that was made before now.

0 commit comments

Comments
 (0)