Skip to content

Commit 9b2601b

Browse files
authored
Merge pull request #9216 from sbulen/30_log_online_fix
[3.0] Don't log guests if disallowed
2 parents 07eda62 + d70e823 commit 9b2601b

4 files changed

Lines changed: 27 additions & 32 deletions

File tree

Languages/en_US/Who.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
$txt['who_no_online_spiders'] = 'There are currently no robots online.';
1919
$txt['who_no_online_guests'] = 'There are currently no guests online.';
2020
$txt['who_no_online_members'] = 'There are currently no members online.';
21-
$txt['who_guest_login'] = 'User has been taken to the login page.';
2221

2322
$txt['whospider_login'] = 'Viewing the login page.';
2423
$txt['whospider_register'] = 'Viewing the registration page.';

Sources/Actions/Who.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public static function determineActions(mixed $urls, string|bool $preferred_pref
526526

527527
if (isset($actions['error'])) {
528528
$error_message = Lang::getTxt(
529-
$actions['error'] == 'guest_login' ? 'who_guest_login' : $actions['error'],
529+
$actions['error'],
530530
(array) ($actions['error_params'] ?? []),
531531
file: 'Who+Errors',
532532
);

Sources/Forum.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -629,32 +629,6 @@ protected function preflight(): void
629629
ErrorHandler::fatalLang('not_a_topic', false);
630630
}
631631

632-
// Don't log if this is an attachment, avatar, toggle of editor buttons,
633-
// theme option, XML feed, popup, etc.
634-
if (
635-
self::$current_action?->canBeLogged() === true
636-
|| (
637-
self::$current_action === null
638-
&& !QueryString::isFilteredRequest(self::$unlogged_actions, 'action')
639-
)
640-
) {
641-
// Log this user as online.
642-
User::$me->logOnline();
643-
644-
// Track forum statistics and hits...?
645-
if (!empty(Config::$modSettings['hitStats'])) {
646-
Logging::trackStats(['hits' => '+']);
647-
}
648-
649-
// Login cookies should only expire after a period of inactivity.
650-
// Since doing something worthy of logging means this member is
651-
// actively engaged with the forum right now, refresh their login
652-
// cookie in order to reset the countdown to its expiry date.
653-
if (!User::$me->is_guest) {
654-
Cookie::updateLoginCookieExpiry();
655-
}
656-
}
657-
658632
// Make sure that our scheduled tasks have been running as intended.
659633
Config::checkCron();
660634

@@ -682,6 +656,32 @@ protected function preflight(): void
682656
) {
683657
User::$me->kickIfGuest(null, false);
684658
}
659+
660+
// Don't log if this is an attachment, avatar, toggle of editor buttons,
661+
// theme option, XML feed, popup, etc.
662+
if (
663+
self::$current_action?->canBeLogged() === true
664+
|| (
665+
self::$current_action === null
666+
&& !QueryString::isFilteredRequest(self::$unlogged_actions, 'action')
667+
)
668+
) {
669+
// Log this user as online.
670+
User::$me->logOnline();
671+
672+
// Track forum statistics and hits...?
673+
if (!empty(Config::$modSettings['hitStats'])) {
674+
Logging::trackStats(['hits' => '+']);
675+
}
676+
677+
// Login cookies should only expire after a period of inactivity.
678+
// Since doing something worthy of logging means this member is
679+
// actively engaged with the forum right now, refresh their login
680+
// cookie in order to reset the countdown to its expiry date.
681+
if (!User::$me->is_guest) {
682+
Cookie::updateLoginCookieExpiry();
683+
}
684+
}
685685
}
686686

687687
/**

Sources/User.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,10 +1547,6 @@ public function kickIfGuest(?string $message = null, bool $log = true): void
15471547

15481548
// Log what they were trying to do that didn't work.
15491549
if ($log) {
1550-
if (!empty(Config::$modSettings['who_enabled'])) {
1551-
$_GET['error'] = 'guest_login';
1552-
}
1553-
15541550
$this->logOnline(true);
15551551
}
15561552

0 commit comments

Comments
 (0)