News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

Server upgrade 2025 (stuff did break)

Started by dreadnaut, August 26, 2025, 12:57:40 PM

Previous topic - Next topic

dreadnaut

Hello folks! As you have probably noticed, all bits of stunts.hu are back online.

We had requested a PHP upgrade, but instead of receiving the usual reply "sure, we can do it on this day, is that OK?" the email said "sure, we've just done it!"

Website, forum and wiki were actually ready, but something else went wrong on the hosting side, and they could only fix it this morning.

All back to normal at this point ✅

Glad it happened at the start of a race, and not at the end! Given the downtime was less than a day, there are no changes to the race schedule.

Now, on to enjoy PHP 8.4 features, clean up some more code, and possibly getting a new version of phpStunts out — it's about time.

HerrNove

Quote from: dreadnaut on August 26, 2025, 12:57:40 PMHello folks! As you have probably noticed, all bits of stunts.hu are back online.

We had requested a PHP upgrade, but instead of receiving the usual reply "sure, we can do it on this day, is that OK?" the email said "sure, we've just done it!"

Website, forum and wiki were actually ready, but something else went wrong on the hosting side, and they could only fix it this morning.

All back to normal at this point ✅

Glad it happened at the start of a race, and not at the end! Given the downtime was less than a day, there are no changes to the race schedule.

Now, on to enjoy PHP 8.4 features, clean up some more code, and possibly getting a new version of phpStunts out — it's about time.

Thanks for your work, @dreadnaut !

MiDiaN

Thanks for keeping the site up to date! I'm looking forward for future updates.

dreadnaut

No problem, it's good fun!

Wiki updated to MediaWiki 1.43.3. All seems fine, except... the logo does not appear 🤔 Should all be in place, but there's not even an <img> tag. I'll investigate later!

HerrNove

Hi dreadnaut, I am a little confused by the "Submit time" screen after the update. It seems that the "Corrected time" row does not display the centiseconds of the raw time correctly (it shows 1:13:00 instead of 1:13:95).

Curiously, the confirmation screen after submitting the time shows the centiseconds correctly.

You cannot view this attachment.

You cannot view this attachment.

Alain il professore

Quote from: HerrNove on August 27, 2025, 12:15:04 AMHi dreadnaut, I am a little confused by the "Submit time" screen after the update. It seems that the "Corrected time" row does not display the centiseconds of the raw time correctly (it shows 1:13:00 instead of 1:13:95).

Curiously, the confirmation screen after submitting the time shows the centiseconds correctly.

You cannot view this attachment.

You cannot view this attachment.

Because it shows for some reason one of the SQL rounded cell time format, not the real one.

Here's what's happening — and how to fix it.

What's the bug?

On the Submit time page, the "Corrected time" line prints the raw time with a formatter that drops centiseconds, while the corrected time on the right uses a centisecond-aware formatter.
Result: you see 1:13:00 – 10% = 1:06.55 even though the raw time is 1:13.95.
The confirmation screen uses the centisecond formatter consistently, so it looks correct there.

Why it happens

Somewhere in the template/back-end that builds the string

{raw} - {bonus}% = {corrected}


the left token uses a "mm:ss" formatter (seconds precision), while the right token uses "mm:ss.cc" (centiseconds). The math is fine; it's a display mismatch.

The fix

Use one centisecond formatter for every time you display (raw and corrected), on both pages.

Example (PHP)
function format_time_cs(int $centis): string {
    $min  = intdiv($centis, 6000);
    $sec  = intdiv($centis % 6000, 100);
    $csec = $centis % 100;
    return sprintf('%d:%02d.%02d', $min, $sec, $csec);
}

// Build the "Corrected time" row
$raw_cs       = $time_centiseconds;              // e.g., 4395 for 1:13.95
$bonus_pct    = 10;
$corrected_cs = intdiv($raw_cs * (100 - $bonus_pct), 100); // truncate, don't round

$line = sprintf(
    '%s - %d%% = %s',
    format_time_cs($raw_cs),
    $bonus_pct,
    format_time_cs($corrected_cs)
);

Example (JS, if the page formats client-side)
function formatTimeCs(totalCs){
  const m = Math.floor(totalCs / 6000);
  const s = Math.floor((totalCs % 6000) / 100);
  const c = totalCs % 100;
  return `${m}:${String(s).padStart(2,'0')}.${String(c).padStart(2,'0')}`;
}

// corrected = truncate to centiseconds
const correctedCs = Math.floor(rawCs * (100 - bonusPct) / 100);

const line = `${formatTimeCs(rawCs)} - ${bonusPct}% = ${formatTimeCs(correctedCs)}`;

Also worth standardizing

Use mm:ss.cc (dot before centiseconds) everywhere for clarity.

Add a quick unit test for edge cases (e.g., 0:59.99 with 10%, 1:00.00, etc.) to ensure truncation, not rounding.

Once the submit page calls the same format_time_cs for both sides, the display will read:

1:13.95 – 10% = 1:06.55


which will match the confirmation screen.
It is reasonable to expect that genetic influences on traits like IQ should become less important as one gains experiences with age. Surprisingly, the opposite occurs.

HerrNove

#6
Alain, thanks but I don't think ChatGPT's allucinations are useful here. It is a trivial error to fix for both dreadnaut and me: the only thing required is access to the source code, and the only curiosity is whether the PHP update affected that or if it was present from before and nobody noticed.

MiDiaN

LOL Alain must be trolling at this point :D

dreadnaut

Quote from: HerrNove on August 27, 2025, 12:15:04 AMIt seems that the "Corrected time" row does not display the centiseconds of the raw time correctly (it shows 1:13:00 instead of 1:13:95).

Thanks for spotting that. That's me I think, mis-placed brackets around an integer cast. I'll fix it

Quote from: HerrNove on August 27, 2025, 12:15:04 AMCuriously, the confirmation screen after submitting the time shows the centiseconds correctly.

Unfortunately there are still two codepaths here, for basically the same view