fix: UTF-8 BOM in update SQL files causing MariaDB syntax error
PowerShell 5.1 Out-File -Encoding UTF8 adds BOM (EF BB BF) which breaks SQL execution on production. Also fix manifest JSON serializing full PS objects instead of plain strings. - build-update.ps1: use UTF8Encoding($false) for all file writes - build-update.ps1: force .ToString() on Get-Content results - UpdateRepository.php: strip BOM and normalize line endings in executeSql - Rebuild ver_0.304 package files (clean SQL + manifest) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,7 @@ param(
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Utf8NoBom = New-Object System.Text.UTF8Encoding $false
|
||||
|
||||
# --- Helpers ---
|
||||
|
||||
@@ -214,7 +215,7 @@ $sqlQueries = @()
|
||||
$migrationFile = "migrations/$versionNumber.sql"
|
||||
|
||||
if (Test-Path $migrationFile) {
|
||||
$sqlQueries = Get-Content $migrationFile | Where-Object { $_.Trim() -ne '' }
|
||||
$sqlQueries = @(Get-Content $migrationFile | Where-Object { $_.Trim() -ne '' } | ForEach-Object { $_.ToString() })
|
||||
Write-Step "Znaleziono migracje SQL: $migrationFile ($($sqlQueries.Count) zapytan)"
|
||||
} else {
|
||||
Write-Step "Brak migracji SQL ($migrationFile nie istnieje)"
|
||||
@@ -322,7 +323,7 @@ $manifest = @{
|
||||
|
||||
$manifestJson = $manifest | ConvertTo-Json -Depth 4
|
||||
$manifestPath = "$updatesDir/ver_${versionNumber}_manifest.json"
|
||||
$manifestJson | Out-File $manifestPath -Encoding UTF8
|
||||
[System.IO.File]::WriteAllText($manifestPath, $manifestJson, $Utf8NoBom)
|
||||
|
||||
Write-Ok "Utworzono manifest: $manifestPath"
|
||||
|
||||
@@ -330,7 +331,7 @@ Write-Ok "Utworzono manifest: $manifestPath"
|
||||
|
||||
if ($sqlQueries.Count -gt 0) {
|
||||
$sqlPath = "$updatesDir/ver_${versionNumber}_sql.txt"
|
||||
($sqlQueries -join "`n") | Out-File $sqlPath -Encoding UTF8 -NoNewline
|
||||
[System.IO.File]::WriteAllText($sqlPath, ($sqlQueries -join "`n"), $Utf8NoBom)
|
||||
Write-Ok "Utworzono legacy SQL: $sqlPath"
|
||||
}
|
||||
|
||||
@@ -340,7 +341,7 @@ if ($deletedFilesOnly.Count -gt 0 -or $deletedDirs.Count -gt 0) {
|
||||
foreach ($d in $deletedDirs) { $filesContent += "D: ../$d" }
|
||||
|
||||
$filesPath = "$updatesDir/ver_${versionNumber}_files.txt"
|
||||
($filesContent -join "`n") | Out-File $filesPath -Encoding UTF8 -NoNewline
|
||||
[System.IO.File]::WriteAllText($filesPath, ($filesContent -join "`n"), $Utf8NoBom)
|
||||
Write-Ok "Utworzono legacy files: $filesPath"
|
||||
}
|
||||
|
||||
@@ -350,7 +351,7 @@ $versionsFile = "updates/versions.php"
|
||||
if (Test-Path $versionsFile) {
|
||||
$content = Get-Content $versionsFile -Raw
|
||||
$content = $content -replace '\$current_ver\s*=\s*\d+;', "`$current_ver = $versionInt;"
|
||||
$content | Out-File $versionsFile -Encoding UTF8 -NoNewline
|
||||
[System.IO.File]::WriteAllText($versionsFile, $content, $Utf8NoBom)
|
||||
Write-Ok "Zaktualizowano versions.php: `$current_ver = $versionInt"
|
||||
}
|
||||
|
||||
@@ -363,7 +364,7 @@ if (Test-Path $changelogFile) {
|
||||
|
||||
$changelogContent = Get-Content $changelogFile -Raw
|
||||
$changelogContent = $newEntry + $changelogContent
|
||||
$changelogContent | Out-File $changelogFile -Encoding UTF8 -NoNewline
|
||||
[System.IO.File]::WriteAllText($changelogFile, $changelogContent, $Utf8NoBom)
|
||||
Write-Ok "Zaktualizowano changelog.php"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user