fix(admin): align UTM notes and block obsolete chb publication
deploy-preland / deploy zoomstage.online (push) Successful in 54s

This commit is contained in:
Panfilov Konstantin committed 2026-10-25 23:16:35 +03:00
1 parent f2097d4800
commit 84f70b1c71
14 files changed
+93 -29

No files matched your search

+17
View File
@@ -42,5 +42,22 @@ try{
exec(PHP_BINARY.' '.escapeshellarg($script).' '.escapeshellarg($file).' 2>/dev/null',$out,$code);
if($code!==2||file_get_contents($file)!==$conflict)throw new RuntimeException('api#327: конфликт aliases должен блокировать patch без записи');
}
// preland#24: публикация старого chb запрещена даже при enum migration.
foreach([
'{"utm":{"theme":{"weights":{"dark":1},"default":"dark"},"chb":{"default":"1"}}}',
'{"utm":{"theme":{"weights":{"1":1},"default":"1"},"chb":null}}',
'{"utm":{"c\u0068b":null}}',
'{"utm":{"chb":{},"chb":null}}',
'{"utm":{"chb":null},"utm":{"theme":{"weights":{"dark":1},"default":"dark"}}}',
] as $obsolete){
file_put_contents($file,$obsolete);$stderr=$file.'.stderr';
exec(PHP_BINARY.' '.escapeshellarg($script).' '.escapeshellarg($file).' 2>'.escapeshellarg($stderr),$out,$code);
$message=file_get_contents($stderr);unlink($stderr);
if($code!==2||file_get_contents($file)!==$obsolete||!str_contains($message,'utm.chb'))throw new RuntimeException('preland#24: chb должен явно блокировать публикацию без изменения байтов');
}
$nested='{ "chb":null,"utm":{"custom":{"chb":null},"theme":{"weights":{"dark":1.0},"default":"dark"}} }';
file_put_contents($file,$nested);exec(PHP_BINARY.' '.escapeshellarg($script).' '.escapeshellarg($file),$out,$code);
$expectedNested=str_replace(['"dark":','"default":"dark"'],['"1":','"default":"1"'],$nested);
if($code!==10||file_get_contents($file)!==$expectedNested||property_exists(json_decode(file_get_contents($file))->utm,'cons'))throw new RuntimeException('preland#24: соседние chb/unknown сохраняются, отсутствующий cons не добавляется');
echo "OK: numeric config migration preserves weights/default/foreign JSON types\n";
}finally{unlink($file);}