Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes mistakes re: typcasting vs. null coalescing operator precedence #8039

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Actions/Admin/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2470,7 +2470,7 @@ protected function setGroupsContext(): void
];
}

Group::countPermissionsBatch(array_keys(Utils::$context['groups']), (int) $_REQUEST['pid'] ?? null);
Group::countPermissionsBatch(array_keys(Utils::$context['groups']), isset($_REQUEST['pid']) ? (int) $_REQUEST['pid'] : null);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Sources/Actions/Admin/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function general(): void

// Ensure all URLs are aligned with the new force_ssl setting
// Treat unset like 0
$this->alignURLsWithSSLSetting((int) $_POST['force_ssl'] ?? 0);
$this->alignURLsWithSSLSetting((int) ($_POST['force_ssl'] ?? 0));

ACP::saveSettings($config_vars);
$_SESSION['adm-save'] = true;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Actions/Unread.php
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,8 @@ protected function getTopicRequestWithoutTempTable(): void
list($num_topics, $min_message) = Db::$db->fetch_row($request);
Db::$db->free_result($request);

$this->num_topics = (int) $num_topics ?? 0;
$this->min_message = (int) $min_message ?? 0;
$this->num_topics = (int) ($num_topics ?? 0);
$this->min_message = (int) ($min_message ?? 0);

if ($this->num_topics == 0) {
$this->setNoTopics();
Expand Down
4 changes: 2 additions & 2 deletions Sources/Actions/UnreadReplies.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ protected function getTopicRequestWithoutTempTable(): void
list($num_topics, $min_message) = Db::$db->fetch_row($request);
Db::$db->free_result($request);

$this->num_topics = (int) $num_topics ?? 0;
$this->min_message = (int) $min_message ?? 0;
$this->num_topics = (int) ($num_topics ?? 0);
$this->min_message = (int) ($min_message ?? 0);

if ($this->num_topics == 0) {
$this->setNoTopics();
Expand Down
4 changes: 2 additions & 2 deletions Sources/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2800,8 +2800,8 @@ protected function setAvatarAttachment(string $filepath): ?string
}

// Check whether the image is too large.
$max_width = (int) Config::$modSettings['avatar_max_width_external'] ?? 0;
$max_height = (int) Config::$modSettings['avatar_max_height_external'] ?? 0;
$max_width = (int) (Config::$modSettings['avatar_max_width_external'] ?? 0);
$max_height = (int) (Config::$modSettings['avatar_max_height_external'] ?? 0);

if ($image->shouldResize($max_width, $max_height)) {
// Try to resize it, unless the admin disabled resizing.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Subs-Compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -3225,7 +3225,7 @@ function read_tgz_file(
): array|bool {
return PackageManager\SubsPackage::read_tgz_file(
$gzfilename,
(string) $destination ?? null,
isset($destination) ? (string) $destination : null,
$single_file,
$overwrite,
$files_to_extract,
Expand Down
2 changes: 1 addition & 1 deletion Sources/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ class User implements \ArrayAccess
public function __set(string $prop, mixed $value): void
{
if (in_array($this->prop_aliases[$prop] ?? $prop, ['additional_groups', 'buddies', 'ignoreusers', 'ignoreboards']) && is_string($value)) {
$prop = (string) $this->prop_aliases[$prop] ?? $prop;
$prop = (string) ($this->prop_aliases[$prop] ?? $prop);
$value = array_map('intval', array_filter(explode(',', $value), 'strlen'));
}

Expand Down
Loading