fix: address code review feedback on billing admin fixes

- menu.php: remove unnecessary @ suppression from mysqli_thread_id()
  (instanceof check already guarantees a mysqli object)
- adminserverlist.php: split ternary flash message into separate if/else
  for readability; replace dynamic SQL fragment with explicit if/else
  query branches

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/988997ed-7568-48bf-96ef-889fb5d91fec

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-02 13:41:13 +00:00 committed by GitHub
parent bb77620796
commit f4f222953f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View file

@ -83,7 +83,11 @@ if (isset($_POST['update_remote_servers'])) {
$db->query("UPDATE {$table_prefix}remote_servers SET enabled={$e} WHERE remote_server_id={$id}");
}
}
$flash[] = $rsHasEnabled ? "Server locations updated." : "Server locations updated (note: 'enabled' column missing from remote_servers — run add_remote_server_enabled_column.sql migration).";
if ($rsHasEnabled) {
$flash[] = "Server locations updated.";
} else {
$flash[] = "Server locations updated (note: 'enabled' column missing from remote_servers — run add_remote_server_enabled_column.sql migration).";
}
}
/* helper: update one service row from posted array */
@ -153,9 +157,13 @@ if (isset($_POST['remove_service'], $_POST['service_id_remove'])) {
}
/* fetch data for UI */
$rsEnabledExpr = $rsHasEnabled ? ', enabled' : ', 1 AS enabled';
$remoteServers = fetch_all_assoc($db, "SELECT remote_server_id, remote_server_name{$rsEnabledExpr} FROM {$table_prefix}remote_servers ORDER BY remote_server_name");
$services = fetch_all_assoc($db, "SELECT service_id, service_name, `{$locationCol}` AS locs, slot_min_qty, slot_max_qty, price_daily, price_monthly, price_year, img_url, enabled FROM {$table_prefix}billing_services ORDER BY service_name");
// Build remote-servers query — include `enabled` only when the column exists (older installs may be missing it).
if ($rsHasEnabled) {
$remoteServers = fetch_all_assoc($db, "SELECT remote_server_id, remote_server_name, enabled FROM {$table_prefix}remote_servers ORDER BY remote_server_name");
} else {
$remoteServers = fetch_all_assoc($db, "SELECT remote_server_id, remote_server_name, 1 AS enabled FROM {$table_prefix}remote_servers ORDER BY remote_server_name");
}
$services = fetch_all_assoc($db, "SELECT service_id, service_name, `{$locationCol}` AS locs, slot_min_qty, slot_max_qty, price_daily, price_monthly, price_year, img_url, enabled FROM {$table_prefix}billing_services ORDER BY service_name");
?>
<?php if ($flash): ?>

View file

@ -56,8 +56,9 @@ if ($is_logged_in) {
$menu_db = null;
$menu_db_opened = false;
// Only reuse $db if it is still an open (non-closed) connection.
// mysqli_thread_id() returns 0 on a closed handle, so guard against that.
if (isset($db) && $db instanceof mysqli && @mysqli_thread_id($db)) {
// mysqli_thread_id() returns 0 on a closed handle; no @ needed since instanceof
// already guarantees $db is a mysqli object.
if (isset($db) && $db instanceof mysqli && mysqli_thread_id($db)) {
$menu_db = $db;
} else {
$menu_db_port = isset($db_port) ? (int)$db_port : null;