Some important fixes

This commit is contained in:
novgorodschi catalin
2026-09-04 07:36:42 +03:00
parent 1bab6640d0
commit bbc5ae0252
4 changed files with 33 additions and 7 deletions
@@ -244,8 +244,17 @@ trait DatabaseAllianceQueries {
list($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8) = $this->escape_input($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8);
$q = "INSERT into " . TB_PREFIX . "ali_permission values(0,'$uid','$aid','$rank','$opt1','$opt2','$opt3','$opt4','$opt5','$opt6','$opt7','$opt8')";
mysqli_query($this->dblink,$q);
$q = "INSERT IGNORE into " . TB_PREFIX . "ali_permission values(0,'$uid','$aid','$rank','$opt1','$opt2','$opt3','$opt4','$opt5','$opt6','$opt7','$opt8')";
// BUG FIXED (fatal, log 3 sep): acceptInvite() in Alliance.php checks
// $session->alliance == 0 before calling this, but a double-submitted request
// (double-click / two near-simultaneous requests) can pass that check twice
// before either commits - ali_permission has a UNIQUE KEY on (uid, alliance),
// so the second INSERT threw an uncaught "Duplicate entry" mysqli_sql_exception,
// killing the whole request. INSERT IGNORE makes the (rare) duplicate a silent
// no-op instead: the first request's row already has correct, freshly-created
// permissions, so there's nothing meaningful to overwrite. Routed through
// $this->query() too, for the deadlock/connection-loss retry already there.
$this->query($q);
// update cache
$insertID = mysqli_insert_id($this->dblink);
@@ -294,7 +303,12 @@ trait DatabaseAllianceQueries {
self::$alliancePermissionsCache[ $uid . $aid ]['opt5'] = $opt5;
self::$alliancePermissionsCache[ $uid . $aid ]['opt6'] = $opt6;
self::$alliancePermissionsCache[ $uid . $aid ]['opt7'] = $opt7;
self::$alliancePermissionsCache[ $uid . $aid ]['opt8'] = $opt8;
// BUG FIXED: this function has no $opt8 parameter (only opt1..opt7 - see
// signature above and the UPDATE below, which also never touches the opt8
// column) - "self::...['opt8'] = $opt8" referenced an undefined variable on
// every call. Line removed entirely rather than inventing an opt8 param none
// of the 4 call sites pass: the DB column is untouched by this function, so
// leaving the cached opt8 value alone is what actually matches the DB.
}
$q = "UPDATE " . TB_PREFIX . "ali_permission SET `rank` = '$rank',opt1 = '$opt1', opt2 = '$opt2', opt3 = '$opt3', opt4 = '$opt4', opt5 = '$opt5', opt6 = '$opt6', opt7 = '$opt7' WHERE uid = $uid AND alliance = $aid LIMIT 1";
$result = mysqli_query($this->dblink, $q);
@@ -198,7 +198,12 @@ trait DatabaseStatisticsQueries {
}
$q = "SELECT count(id) FROM " . TB_PREFIX . "users where id > 5";
$result = mysqli_query($this->dblink,$q);
// BUG FIXED (fatal, log 2 sep): raw mysqli_query() bypassed $this->query() (the
// only place with reconnect/retry). This is called on every automation tick via
// procNewClimbers() -> Ranking::procRankArray() -> countUser() - when the
// connection dropped between cron ticks, "MySQL server has gone away" (2006)
// killed the whole tick. Same fix already applied to getOasisEnforce().
$result = $this->query($q);
$row = mysqli_fetch_row($result);
self::$usersCountCache[0] = $row[0];
+9 -2
View File
@@ -137,8 +137,15 @@ for ($i = (1 + $s); $i <= (10 + $s); $i++) {
if (
!$support_messages ||
($support_messages && $message->inbox1[$i - 1]['target'] != 1) ||
($multihunter_messages && $message->inbox1[$i - 1]['target'] != 5)
// BUG FIXED (warning only): $message->inbox1[$i - 1] intentionally kept as-is
// (see "IMPORTANT: păstrăm bug original inbox1" above) - inbox1 is a different,
// differently-sized array than sent1, so these indices commonly don't exist.
// Null-coalescing gives the exact same result as before (undefined key/null
// offset both evaluated to NULL, and NULL != 1 / NULL != 5 are both true) -
// just without the "Undefined array key" + "array offset on null" warning
// pair firing on every one of the up to 10 rows on this page.
($support_messages && ($message->inbox1[$i - 1]['target'] ?? null) != 1) ||
($multihunter_messages && ($message->inbox1[$i - 1]['target'] ?? null) != 5)
) {
$sent_as_text =
"<input class=\"check\" type=\"checkbox\" name=\"n" . $name . "\" value=\"" . $msg['id'] . "\" />";
+1 -1
View File
@@ -35,7 +35,7 @@ if(isset($_GET['newdid'])){
if(isset($_GET['t'])){
header("Location: ".$_SERVER['PHP_SELF']."?t=".$_GET['t']);
exit();
}else if($_GET['id'] != 0){
}else if(isset($_GET['id']) && $_GET['id'] != 0){
header("Location: ".$_SERVER['PHP_SELF']."?id=".$_GET['id']);
exit();
}else{