SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

[quote date=] with huge date causes PHP/500 errors (SMF 2.0 and 2.1)

Started by Dav999, February 11, 2023, 12:20:48 PM

Previous topic - Next topic


I saw some error messages coming from old posts on my SMF 2.0 forum:

getdate(): Argument #1 ($timestamp) must be of type ?int, float given
It turns out that in 2016, playful members would sometimes replace the quote timestamps by gigantic numbers, like the following:
[quote author=Author link=topic=1234.msg1234#msg1234 date=43221236679945679975421332243343546864502]

This probably had the effect of actually showing correct heat-death-of-the-universe dates with the SMF and PHP versions of the time. However, this has since been causing more errors: I remember seeing similar errors in my log years after the posts were made, but the entire topic would still load and the dates would be blank ("Quote from: author on "). With SMF 2.0.19 on PHP 8.0.25 however, the topic crashes entirely:

On 2.1.3, such a topic results in a complete 500 Internal Server Error.

It's also not possible to post or preview a message with these contents, as it will result in the same An Error Has Occurred message on 2.0, and a complete 500 error in 2.1.

This is the full error logged in SMF 2.1:

[11-Feb-2023 17:05:10 Europe/Berlin] PHP Fatal error:  Uncaught TypeError: smf_strftime(): Argument #2 ($timestamp) must be of type ?int, string given, called in /home/tolp/public_tolp_testforum/smf_2.1/Sources/Subs.php on line 756 and defined in /home/tolp/public_tolp_testforum/smf_2.1/Sources/Subs.php:903
Stack trace:
#0 /home/tolp/public_tolp_testforum/smf_2.1/Sources/Subs.php(756): smf_strftime('%b %d, %Y, %I:%...', '432212366799456...', 'Europe/Berlin')
#1 /home/tolp/public_tolp_testforum/smf_2.1/Sources/Subs.php(3441): timeformat('432212366799456...')
#2 /home/tolp/public_tolp_testforum/smf_2.1/Sources/Post.php(2063): parse_bbc('[quote author=A...', false)
#3 /home/tolp/public_tolp_testforum/smf_2.1/index.php(191): Post2()
#4 {main}
  thrown in /home/tolp/public_tolp_testforum/smf_2.1/Sources/Subs.php on line 903

I get that it's something that members are not supposed to be doing, but this allows members to spam error logs and waste admins' time, and old playful posts can render part or all of a topic, a member's posts page, etc inaccessible.


Sorry for bringing this topic up, but I've discovered a similar error related with that timestamp.
This issue occour too when using the [time] tag.
If the value has more than 18 digits like [time]9999999999999999999[/time] or [time]-9999999999999999999[/time], SMF will throw an error message, similar to that what the OP has posted, while in older posts the page looks cutted from the reply on where that code was once posted.

A possible solution would be a small function that trims all time values that are longer than 18 digits or cut it down to the current system's maximum supported amount of digits.


"Faith is what you have in things that don't exist."
--Homer Simpson

Es gibt hier im Forum ein deutsches Support-Board!
<Werbung>Meine Frau hat ihr erstes Buch veröffentlicht!</Werbung>