Send Discord snowflake IDs as strings to prevent JS precision loss
channel_id and role_id are 64-bit integers that exceed Number.MAX_SAFE_INTEGER, causing silent rounding in the browser. Cast to string in the GET response; PHP stores them back as integers on save (64-bit PHP handles them correctly). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
df11e32e70
commit
dfca6df629
1 changed files with 7 additions and 0 deletions
|
|
@ -39,6 +39,13 @@ if ($method === 'GET') {
|
||||||
$safe = $config;
|
$safe = $config;
|
||||||
if (isset($safe['linkedin']['access_token'])) $safe['linkedin']['access_token'] = $safe['linkedin']['access_token'] ? '***' : null;
|
if (isset($safe['linkedin']['access_token'])) $safe['linkedin']['access_token'] = $safe['linkedin']['access_token'] ? '***' : null;
|
||||||
if (isset($safe['linkedin']['refresh_token'])) $safe['linkedin']['refresh_token'] = $safe['linkedin']['refresh_token'] ? '***' : null;
|
if (isset($safe['linkedin']['refresh_token'])) $safe['linkedin']['refresh_token'] = $safe['linkedin']['refresh_token'] ? '***' : null;
|
||||||
|
// Discord snowflake IDs exceed JS Number.MAX_SAFE_INTEGER — send as strings
|
||||||
|
foreach (['twitch', 'rss'] as $section) {
|
||||||
|
foreach ($safe[$section] ?? [] as $key => $item) {
|
||||||
|
if (isset($item['channel_id'])) $safe[$section][$key]['channel_id'] = (string)$item['channel_id'];
|
||||||
|
if (isset($item['role_id']) && $item['role_id'] !== null) $safe[$section][$key]['role_id'] = (string)$item['role_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
echo json_encode(['config' => $safe]);
|
echo json_encode(['config' => $safe]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue