Basic Information
Two unrelated fatals, both one-liners, both found while testing #9517.
1. The board index fatals for a moderator as soon as a board has unapproved posts.
Themes/default/BoardIndex.template.php:191:
Lang::getTxt('unapproved_posts', $board, file: 'General')
$board there is an SMF\Board, and Lang::getTxt() types its second argument as array:
SMF\Lang::getTxt(): Argument #2 ($args) must be of type array, SMF\Board given,
called in /var/www/html/Themes/default/BoardIndex.template.php on line 191
The branch is guarded by $board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics']), so it only fires for someone who can approve, on a board that has something waiting — but for that person the board index is then unusable. A few lines below, moderators_list passes a real array, which is the shape this one wants too.
2. The installer cannot be run from the command line.
Sources/Maintenance/Tools/Install.php:612:
Maintenance::$context['detected_url'] = 'http' . (Sapi::httpsOn() ? 's' : '') . '://' . $this->defaultHost() . substr(Maintenance::getSelf(), 0, strrpos(Maintenance::getSelf(), '/'));
Maintenance::getSelf() returns $_SERVER['PHP_SELF'], which on the CLI is just install.php — no slash — so strrpos() returns false and substr() gets false where it wants ?int:
PHP Fatal error: Uncaught TypeError: substr(): Argument #3 ($length) must be of type ?int,
false given in /var/www/html/Sources/Maintenance/Tools/Install.php:612
defaultHost() warns on the way past as well, since neither HTTP_HOST nor SERVER_NAME exists on the CLI:
PHP Warning: Undefined array key "SERVER_NAME" in .../Install.php on line 1421
This matters because Maintenance::parseCliArguments() exists specifically so the installer can be driven from a shell, and --boardurl is already among the arguments it accepts — the detection this line is doing is not even needed when the caller supplied one.
Steps to reproduce
- As an administrator with
approve_posts, turn post moderation on, let a reply sit unapproved, and load the board index.
- From a shell in the forum directory:
php install.php --contbutt=1 --db_type=MySQL --db_server=… --boardurl=http://localhost:8080 …
Expected result
- The board index renders with the
! moderation link.
- The installer runs.
Actual result
- Fatal, logged to
smf_log_errors.
- Fatal before the first step finishes.
Version/Git revision
3.0 Alpha 4, release-3.0 at bfbca5b
Database Engine
All
Database Version
MySQL 8.4 and PostgreSQL 17
PHP Version
8.4.24
Logs
SMF\Lang::getTxt(): Argument #2 ($args) must be of type array, SMF\Board given,
called in /var/www/html/Themes/default/BoardIndex.template.php on line 191
PHP Warning: Undefined array key "SERVER_NAME" in /var/www/html/Sources/Maintenance/Tools/Install.php on line 1421
PHP Fatal error: Uncaught TypeError: substr(): Argument #3 ($length) must be of type ?int, false given in /var/www/html/Sources/Maintenance/Tools/Install.php:612
Stack trace:
#0 /var/www/html/Sources/Maintenance/Tools/Install.php(612): substr('install.php', 0, false)
#1 /var/www/html/Sources/Maintenance/Maintenance.php(298): SMF\Maintenance\Tools\Install->forumSettings()
#2 /var/www/html/install.php(31): SMF\Maintenance\Maintenance->execute(1)
Additional Information
Found while testing #9517; neither is related to that PR.
Basic Information
Two unrelated fatals, both one-liners, both found while testing #9517.
1. The board index fatals for a moderator as soon as a board has unapproved posts.
Themes/default/BoardIndex.template.php:191:$boardthere is anSMF\Board, andLang::getTxt()types its second argument asarray:The branch is guarded by
$board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics']), so it only fires for someone who can approve, on a board that has something waiting — but for that person the board index is then unusable. A few lines below,moderators_listpasses a real array, which is the shape this one wants too.2. The installer cannot be run from the command line.
Sources/Maintenance/Tools/Install.php:612:Maintenance::getSelf()returns$_SERVER['PHP_SELF'], which on the CLI is justinstall.php— no slash — sostrrpos()returnsfalseandsubstr()getsfalsewhere it wants?int:defaultHost()warns on the way past as well, since neitherHTTP_HOSTnorSERVER_NAMEexists on the CLI:This matters because
Maintenance::parseCliArguments()exists specifically so the installer can be driven from a shell, and--boardurlis already among the arguments it accepts — the detection this line is doing is not even needed when the caller supplied one.Steps to reproduce
approve_posts, turn post moderation on, let a reply sit unapproved, and load the board index.php install.php --contbutt=1 --db_type=MySQL --db_server=… --boardurl=http://localhost:8080 …Expected result
!moderation link.Actual result
smf_log_errors.Version/Git revision
3.0 Alpha 4,
release-3.0at bfbca5bDatabase Engine
All
Database Version
MySQL 8.4 and PostgreSQL 17
PHP Version
8.4.24
Logs
Additional Information
Found while testing #9517; neither is related to that PR.