Skip to content

Commit ab89974

Browse files
Merge pull request SimpleMachines#8407 from Sesquipedalian/3.0/misc_fixes
2 parents 66c9221 + fefcf87 commit ab89974

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

Sources/Actions/Recent.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ protected function getBoards(): void
344344
'current_board' => Board::$info->id,
345345
],
346346
);
347-
list($this->total_posts, $redirect) = Db::$db->fetch_row($request);
347+
list($total_posts, $redirect) = Db::$db->fetch_row($request);
348+
$this->total_posts = (int) $total_posts;
348349
Db::$db->free_result($request);
349350

350351
// If this is a redirection board, don't bother counting topics here...

Sources/Actions/TopicMerge.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,7 @@ public function merge(): void
972972
$searchAPI = SearchApi::load();
973973

974974
if (is_callable([$searchAPI, 'topicMerge'])) {
975-
// todo: undefined method
976-
$searchAPI->topicMerge($id_topic, $this->topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : [Utils::$context['response_prefix'], $target_subject]);
975+
$searchAPI->topicMerge($id_topic, $this->topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : Utils::$context['response_prefix'] . $target_subject);
977976
}
978977

979978
// Merging is the sort of thing an external CMS might want to know about

Sources/Actions/TopicRestore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public function execute(): void
238238
);
239239

240240
while ($member = Db::$db->fetch_assoc($request2)) {
241-
User::updateMemberData($member['id_member'], ['posts' => 'posts + ' . $member['post_count']]);
241+
User::updateMemberData((int) $member['id_member'], ['posts' => 'posts + ' . $member['post_count']]);
242242
}
243243
Db::$db->free_result($request2);
244244
}

Sources/Actions/Unread.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ protected function getEarliestMsg(): void
647647
'current_member' => User::$me->id,
648648
],
649649
);
650-
list($this->earliest_msg) = Db::$db->fetch_row($request);
650+
list($earliest_msg) = Db::$db->fetch_row($request);
651+
$this->earliest_msg = (int) $earliest_msg;
651652
Db::$db->free_result($request);
652653
} else {
653654
$request = Db::$db->query(
@@ -660,7 +661,8 @@ protected function getEarliestMsg(): void
660661
'current_member' => User::$me->id,
661662
],
662663
);
663-
list($this->earliest_msg) = Db::$db->fetch_row($request);
664+
list($earliest_msg) = Db::$db->fetch_row($request);
665+
$this->earliest_msg = (int) $earliest_msg;
664666
Db::$db->free_result($request);
665667
}
666668

@@ -670,7 +672,7 @@ protected function getEarliestMsg(): void
670672
} else {
671673
// Using caching, when possible, to ignore the below slow query.
672674
if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) {
673-
$earliest_msg2 = $_SESSION['cached_log_time'][1];
675+
$earliest_msg2 = (int) $_SESSION['cached_log_time'][1];
674676
} else {
675677
// This query is pretty slow, but it's needed to ensure nothing crucial is ignored.
676678
$request = Db::$db->query(
@@ -683,6 +685,7 @@ protected function getEarliestMsg(): void
683685
],
684686
);
685687
list($earliest_msg2) = Db::$db->fetch_row($request);
688+
$earliest_msg2 = (int) $earliest_msg2;
686689
Db::$db->free_result($request);
687690

688691
// In theory this could be zero, if the first ever post is unread, so fudge it ;)

Sources/Autolinker.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -986,15 +986,15 @@ protected function setUrlRegex(): void
986986
foreach (['path', 'query', 'fragment'] as $part) {
987987
switch ($part) {
988988
case 'path':
989-
$part_excluded_trailing_chars = '[^\P{Po}?/#&]';
989+
$part_excluded_trailing_chars = '[^\P{Po}?/#&"]';
990990
break;
991991

992992
case 'query':
993-
$part_excluded_trailing_chars = '[^\P{Po}#&]';
993+
$part_excluded_trailing_chars = '[^\P{Po}#&"]';
994994
break;
995995

996996
default:
997-
$part_excluded_trailing_chars = '[^\P{Po}&]';
997+
$part_excluded_trailing_chars = '[^\P{Po}&"]';
998998
break;
999999
}
10001000

Sources/Board.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2415,7 +2415,7 @@ protected function loadBoardInfo(): void
24152415

24162416
if (!empty($temp)) {
24172417
foreach ($temp as $key => $value) {
2418-
if ($key === 'cat') {
2418+
if ($key === 'cat' && !($value instanceof Category)) {
24192419
$this->{$key} = Category::init($value['id'], $value);
24202420
} else {
24212421
$this->{$key} = $value;

Sources/PersonalMessage/PM.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,7 @@ public static function getLatest(): int
19531953
{
19541954
$latest = self::getRecent('pm.id_pm', true, 1);
19551955

1956-
return reset($latest);
1956+
return (int) reset($latest);
19571957
}
19581958

19591959
/**

Sources/QueryString.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ public static function ob_sessrewrite(string $buffer): string
440440
|| @get_cfg_var('cgi.fix_pathinfo') == 1
441441
)
442442
&& (
443-
Sapi::isOS([Sapi::SERVER_APACHE, Sapi::SERVER_LIGHTTPD, Sapi::SERVER_LITESPEED])
443+
Sapi::isSoftware([Sapi::SERVER_APACHE, Sapi::SERVER_LIGHTTPD, Sapi::SERVER_LITESPEED])
444444
)
445445
) {
446446
// Let's do something special for session ids!

Sources/Sapi.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,11 @@ class Sapi
7272
*/
7373
public static function isSoftware(string|array $server): bool
7474
{
75-
$servers = (array) $server;
76-
77-
foreach ($servers as $server) {
78-
if (
79-
isset($_SERVER['SERVER_SOFTWARE'])
80-
&& strpos($_SERVER['SERVER_SOFTWARE'], self::$server_software[$server] ?? $server) !== false
81-
) {
82-
return true;
75+
if (isset($_SERVER['SERVER_SOFTWARE'])) {
76+
foreach ((array) $server as $serv) {
77+
if (preg_match('~' . (self::$server_software[$serv] ?? $serv) . '~i', $_SERVER['SERVER_SOFTWARE'])) {
78+
return true;
79+
}
8380
}
8481
}
8582

Themes/default/Recent.template.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function template_recent()
4545
<div class="page_number floatright"> #', $post['counter'], '</div>
4646
<div class="topic_details">
4747
<h5>', $post['board']['link'], ' / ', $post['link'], '</h5>
48-
<span class="smalltext">', Lang::getTxt('last_post_member_date', ['member' => $post['poster']['link'], '' => str_contains($post['time'], Lang::$txt['today']) ? 'today' : (str_contains($post['time'], Lang::$txt['yesterday']) ? 'yesterday' : 'other'), 'date' => $post['time']]), '</span>
48+
<span class="smalltext">', Lang::getTxt('last_post_member_date', ['member' => $post['poster']['link'], 'relative' => str_contains($post['time'], Lang::$txt['today']) ? 'today' : (str_contains($post['time'], Lang::$txt['yesterday']) ? 'yesterday' : 'other'), 'date' => $post['time']]), '</span>
4949
</div>
5050
<div class="list_posts">', $post['body'], '</div>';
5151

0 commit comments

Comments
 (0)