Stunts Forum

ZakStunts - the Competition => Competition and Website => Topic started by: dreadnaut on August 26, 2025, 12:57:40 PM

Title: Server upgrade 2025 (stuff did break)
Post by: dreadnaut on August 26, 2025, 12:57:40 PM
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.
Title: Re: Server upgrade 2025 (stuff did break)
Post by: HerrNove on August 26, 2025, 02:01:50 PM
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 !
Title: Re: Server upgrade 2025 (stuff did break)
Post by: MiDiaN on August 26, 2025, 02:48:33 PM
Thanks for keeping the site up to date! I'm looking forward for future updates.
Title: Re: Server upgrade 2025 (stuff did break)
Post by: dreadnaut on August 26, 2025, 03:15:53 PM
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!
Title: Re: Server upgrade 2025 (stuff did break)
Post by: HerrNove on August 27, 2025, 12:15:04 AM
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.

Screenshot from 2025-08-27 00-09-59.png

Screenshot from 2025-08-27 00-13-44.png
Title: Re: Server upgrade 2025 (stuff did break)
Post by: Alain il professore on August 27, 2025, 11:01:15 AM
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.

Screenshot from 2025-08-27 00-09-59.png

Screenshot from 2025-08-27 00-13-44.png

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.
Title: Re: Server upgrade 2025 (stuff did break)
Post by: HerrNove on August 27, 2025, 11:17:01 AM
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.
Title: Re: Server upgrade 2025 (stuff did break)
Post by: MiDiaN on August 27, 2025, 12:37:29 PM
LOL Alain must be trolling at this point :D
Title: Re: Server upgrade 2025 (stuff did break)
Post by: dreadnaut on August 27, 2025, 08:42:50 PM
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
Title: Re: Server upgrade 2025 (stuff did break)
Post by: dreadnaut on September 02, 2025, 07:23:52 PM
Quote from: dreadnaut on August 26, 2025, 03:15:53 PMWiki 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!

Fixed! Had to change the configuration from
$wgLogos = [ '1x' => "https://wiki.stunts.hu/images/4/4b/Wikilogo.png" ];
to
$wgLogos = [ 'icon' => "https://wiki.stunts.hu/images/4/4b/Wikilogo.png" ];
to support all skins.