Skip to content
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/Smileys.php
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,7 @@ protected function import(string $smileyPath, bool $create = false): void
[
'code' => 'string-30', 'description' => 'string-80', 'smiley_row' => 'int', 'smiley_order' => 'int',
],
$new_smiley['info'],
[$new_smiley['info']],
['id_smiley'],
1,
);
Expand Down
12 changes: 10 additions & 2 deletions Sources/Actions/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,18 @@ protected function markRead(): void
Topic::$info->new_from == 0 ? 'ignore' : 'replace',
'{db_prefix}log_topics',
[
'id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'unwatched' => 'int',
'id_member' => 'int',
'id_topic' => 'int',
'id_msg' => 'int',
'unwatched' => 'int',
],
[
User::$me->id, Topic::$info->id, $mark_at_msg, Topic::$info->unwatched,
[
User::$me->id,
Topic::$info->id,
$mark_at_msg,
Topic::$info->unwatched,
],
],
['id_member', 'id_topic'],
);
Expand Down
11 changes: 8 additions & 3 deletions Sources/Actions/Moderation/ReportedContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -1208,10 +1208,15 @@ protected function saveModComment(int $report_id, array $data): void
'',
'{db_prefix}log_comments',
[
'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'recipient_name' => 'string',
'id_notice' => 'int', 'body' => 'string', 'log_time' => 'int',
'id_member' => 'int',
'member_name' => 'string',
'comment_type' => 'string',
'recipient_name' => 'string',
'id_notice' => 'int',
'body' => 'string',
'log_time' => 'int',
],
$data,
[$data],
['id_comment'],
1,
);
Expand Down
2 changes: 1 addition & 1 deletion Sources/Calendar/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ public function save(): void
'',
'{db_prefix}calendar',
$columns,
$params,
[$params],
['id_event'],
1,
);
Expand Down
69 changes: 58 additions & 11 deletions Sources/Calendar/RecurrenceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,11 @@ private function expand(\DateTime $current, ?string $break_after = null): \Gener

foreach ($this->rrule->{$prop} as $value) {
if ($value != $current_value) {
$temp = \DateTime::createFromFormat('Y z H:i:s e', $temp->format('Y ') . ($value > 0 ? $value - 1 : $value + ((bool) $temp->format('L') && $value >= -306 ? 366 : 365)) . $temp->format(' H:i:s e'));
try {
$temp = \DateTime::createFromFormat('Y z H:i:s e', $temp->format('Y ') . ($value > 0 ? $value - 1 : $value + ((bool) $temp->format('L') && $value >= -306 ? 366 : 365)) . $temp->format(' H:i:s e'));
} catch (\Throwable $e) {
$temp = \DateTime::createFromFormat('Y z H:i:s P', $temp->format('Y ') . ($value > 0 ? $value - 1 : $value + ((bool) $temp->format('L') && $value >= -306 ? 366 : 365)) . $temp->format(' H:i:s P'));
}

yield $temp;

Expand Down Expand Up @@ -1312,13 +1316,22 @@ private function expand(\DateTime $current, ?string $break_after = null): \Gener

// Move temp to start of week.
$temp->modify('+ 1 day');
$temp->modify('previous ' . self::WEEKDAY_NAMES[$this->rrule->wkst] . ' ' . $temp->format('H:i:s e'));

try {
$temp->modify('previous ' . self::WEEKDAY_NAMES[$this->rrule->wkst] . ' ' . $temp->format('H:i:s e'));
} catch (\Throwable $e) {
$temp->modify('previous ' . self::WEEKDAY_NAMES[$this->rrule->wkst] . ' ' . $temp->format('H:i:s P'));
}

$temp_value = strtoupper(substr($temp->format('D'), 0, 2));

foreach ($this->sortWeekdays($this->rrule->byday) as $value) {
if ($value != $temp_value) {
$temp->modify('next ' . self::WEEKDAY_NAMES[$value] . ' ' . $temp->format('H:i:s e'));
try {
$temp->modify('next ' . self::WEEKDAY_NAMES[$value] . ' ' . $temp->format('H:i:s e'));
} catch (\Throwable $e) {
$temp->modify('next ' . self::WEEKDAY_NAMES[$value] . ' ' . $temp->format('H:i:s P'));
}
}

if (self::calculateWeekNum($temp, $this->rrule->wkst) === $weeknum) {
Expand All @@ -1334,7 +1347,11 @@ private function expand(\DateTime $current, ?string $break_after = null): \Gener
else {
foreach ($this->rrule->byday as $value) {
if ($value != $current_value) {
$temp->modify('next ' . self::WEEKDAY_NAMES[$value] . ' ' . $temp->format('H:i:s e'));
try {
$temp->modify('next ' . self::WEEKDAY_NAMES[$value] . ' ' . $temp->format('H:i:s e'));
} catch (\Throwable $e) {
$temp->modify('next ' . self::WEEKDAY_NAMES[$value] . ' ' . $temp->format('H:i:s P'));
}

yield $temp;

Expand Down Expand Up @@ -1409,11 +1426,21 @@ private function expandMonthByDay(\DateTime $current, array $expansion_values, s
if ($this->frequency_interval->m === 1) {
$upperlimit->add($this->frequency_interval);
} elseif (!empty($this->rrule->bymonth) && in_array((($upperlimit->format('m') + 1) % 12), $this->rrule->bymonth)) {
$upperlimit->modify('last day of ' . $upperlimit->format('F H:i:s e'));
try {
$upperlimit->modify('last day of ' . $upperlimit->format('F H:i:s e'));
} catch (\Throwable $e) {
$upperlimit->modify('last day of ' . $upperlimit->format('F H:i:s P'));
}

$upperlimit->modify('+ 1 day');
} else {
$upperlimit->setDate((int) $upperlimit->format('Y'), (int) $upperlimit->format('m'), 1);
$upperlimit->modify('last day of ' . $upperlimit->format('F H:i:s e'));

try {
$upperlimit->modify('last day of ' . $upperlimit->format('F H:i:s e'));
} catch (\Throwable $e) {
$upperlimit->modify('last day of ' . $upperlimit->format('F H:i:s P'));
}
}

$expansion_values = $this->sortWeekdays($expansion_values);
Expand Down Expand Up @@ -1443,7 +1470,11 @@ private function expandMonthByDay(\DateTime $current, array $expansion_values, s
$temp->modify('- 1 day');

// Go to first occurrence of the weekday in the month.
$temp->modify('next ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s e'));
try {
$temp->modify('next ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s e'));
} catch (\Throwable $e) {
$temp->modify('next ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s P'));
}

// Move forward to the requested occurrence.
if ($expansion_values[$key]['modifier'] > 1) {
Expand Down Expand Up @@ -1472,7 +1503,11 @@ private function expandMonthByDay(\DateTime $current, array $expansion_values, s
$temp->setDate((int) $temp->format('Y'), (int) $temp->format('m') + 1, 1);

// Go to last occurrence of the weekday in the month.
$temp->modify('previous ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s e'));
try {
$temp->modify('previous ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s e'));
} catch (\Throwable $e) {
$temp->modify('previous ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s P'));
}

// Move backward to the requested occurrence.
if ($expansion_values[$key]['modifier'] < -1) {
Expand Down Expand Up @@ -1562,7 +1597,11 @@ private function expandYearByDay(\DateTime $current, array $expansion_values, st
$temp->modify('- 1 day');

// Go to first occurrence of the weekday in the year.
$temp->modify('next ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s e'));
try {
$temp->modify('next ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s e'));
} catch (\Throwable $e) {
$temp->modify('next ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s P'));
}

// Move forward to the requested occurrence.
if ($expansion_values[$key]['modifier'] > 1) {
Expand All @@ -1588,7 +1627,11 @@ private function expandYearByDay(\DateTime $current, array $expansion_values, st
$temp->modify('+ 1 day');

// Go to last occurrence of the weekday in the year.
$temp->modify('previous ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s e'));
try {
$temp->modify('previous ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s e'));
} catch (\Throwable $e) {
$temp->modify('previous ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s P'));
}

// Move backward to the requested occurrence.
if ($expansion_values[$key]['modifier'] < -1) {
Expand All @@ -1608,7 +1651,11 @@ private function expandYearByDay(\DateTime $current, array $expansion_values, st
// No modifier means every matching weekday.
// E.g.: 'TH' means every Thursday.
else {
$temp->modify('next ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s e'));
try {
$temp->modify('next ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s e'));
} catch (\Throwable $e) {
$temp->modify('next ' . self::WEEKDAY_NAMES[$expansion_values[$key]['weekday']] . ' ' . $temp->format('H:i:s P'));
}

if ($temp <= $upperlimit) {
yield $temp;
Expand Down
19 changes: 16 additions & 3 deletions Sources/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -895,18 +895,31 @@ public static function load(): void
*/
public static function set(array $settings): void
{
self::getSettingsDefs();

foreach ($settings as $var => $val) {
if (property_exists(__CLASS__, $var)) {
// Try to ensure the type is correct.
if (
isset(self::$settings_defs[$var])
&& !in_array(gettype($val), (array) self::$settings_defs[$var]['type'])
) {
foreach (['boolean', 'integer', 'double', 'string', 'array', 'NULL'] as $to_type) {
if (in_array($to_type, (array) self::$settings_defs[$var]['type'])) {
settype($val, $to_type);
break;
}
}
}

self::${$var} = $val;
} else {
self::$custom[$var] = $val;
}
}

// Anything missing?
$class_vars = get_class_vars(__CLASS__);

foreach ($class_vars['settings_defs'] as $var => $def) {
foreach (self::$settings_defs as $var => $def) {
if (is_string($var) && property_exists(__CLASS__, $var) && !isset(self::${$var})) {
if (!empty($def['raw_default'])) {
$default = strtr($def['default'], [
Expand Down
2 changes: 1 addition & 1 deletion Sources/Tasks/ExportProfileData.php
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ public function execute(): bool
'insert',
'{db_prefix}background_tasks',
['task_file' => 'string-255', 'task_class' => 'string-255', 'task_data' => 'string', 'claimed_time' => 'int'],
$this->next_task,
[$this->next_task],
[],
);
}
Expand Down
46 changes: 24 additions & 22 deletions other/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1729,28 +1729,30 @@ function AdminAccount()
'ignore_boards' => 'string',
],
[
$_POST['username'],
$_POST['username'],
$_POST['password1'],
$_POST['email'],
1,
0,
time(),
$incontext['member_salt'],
'',
'',
'',
$ip,
$ip,
'',
'',
'',
'',
'',
'',
'',
'',
'',
[
$_POST['username'],
$_POST['username'],
$_POST['password1'],
$_POST['email'],
1,
0,
time(),
$incontext['member_salt'],
'',
'',
'',
$ip,
$ip,
'',
'',
'',
'',
'',
'',
'',
'',
'',
],
],
['id_member'],
1,
Expand Down
27 changes: 18 additions & 9 deletions other/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,9 @@ function UpgradeOptions()
'replace',
Config::$db_prefix . 'settings',
['variable' => 'string', 'value' => 'string'],
['enable_sm_stats', 1],
[
['enable_sm_stats', 1],
],
['variable'],
);
}
Expand Down Expand Up @@ -1889,7 +1891,9 @@ function DatabaseChanges()
'replace',
Config::$db_prefix . 'settings',
['variable' => 'string', 'value' => 'string'],
['smfVersion', $file[2]],
[
['smfVersion', $file[2]],
],
['variable'],
);

Expand Down Expand Up @@ -2387,7 +2391,7 @@ function ($errno, $errstr, $errfile, $errline) use ($support_js) {
// Count the total number of steps within this file - for progress.
$file_steps = substr_count(implode('', $lines), '---#');
$upcontext['total_items'] = substr_count(implode('', $lines), '--- ');
$upcontext['debug_items'] = $file_substrsteps;
$upcontext['debug_items'] = $file_steps;
$upcontext['current_item_num'] = 0;
$upcontext['current_item_name'] = '';
$upcontext['current_debug_item_num'] = 0;
Expand Down Expand Up @@ -3187,7 +3191,9 @@ function ConvertUtf8()
'replace',
'{db_prefix}settings',
['variable' => 'string', 'value' => 'string'],
[['global_character_set', 'UTF-8']],
[
['global_character_set', 'UTF-8'],
],
['variable'],
);

Expand Down Expand Up @@ -3683,7 +3689,10 @@ function ConvertUtf8()
'replace',
'{db_prefix}settings',
['variable' => 'string', 'value' => 'string'],
[['global_character_set', 'UTF-8'], ['previousCharacterSet', $prev_charset]],
[
['global_character_set', 'UTF-8'],
['previousCharacterSet', $prev_charset],
],
['variable'],
);

Expand Down Expand Up @@ -4056,7 +4065,7 @@ function serialize_to_json()

function Cleanup()
{
global $command_line, $upcontext, $support_js, $txt;
global $command_line, $upcontext, $support_js;

$upcontext['sub_template'] = isset($_GET['xml']) ? 'cleanup_xml' : 'cleanup';
$upcontext['page_title'] = Lang::$txt['upgrade_step_cleanup'];
Expand All @@ -4074,7 +4083,7 @@ function Cleanup()
$upcontext['steps_count'] = count($cleanupSteps);
$upcontext['cur_substep_num'] = ((int) $_GET['substep']) ?? 0;
$upcontext['cur_substep'] = $cleanupSteps[$upcontext['cur_substep_num']] ?? $cleanupSteps[0];
$upcontext['cur_substep_name'] = $txt['upgrade_step_cleanup_' . $upcontext['cur_substep']] ?? $txt['upgrade_step_cleanup'];
$upcontext['cur_substep_name'] = Lang::$txt['upgrade_step_cleanup_' . $upcontext['cur_substep']] ?? Lang::$txt['upgrade_step_cleanup'];
$upcontext['step_progress'] = (int) (($upcontext['cur_substep_num'] / $upcontext['steps_count']) * 100);

foreach ($cleanupSteps as $id => $substep) {
Expand All @@ -4090,7 +4099,7 @@ function Cleanup()
// Dubstep.
for ($substep = $upcontext['cur_substep_num']; $substep < $upcontext['steps_count']; $substep++) {
$upcontext['step_progress'] = (int) (($substep / $upcontext['steps_count']) * 100);
$upcontext['cur_substep_name'] = $txt['upgrade_step_cleanup_' . $cleanupSteps[$substep]] ?? $txt['upgrade_step_cleanup'];
$upcontext['cur_substep_name'] = Lang::$txt['upgrade_step_cleanup_' . $cleanupSteps[$substep]] ?? Lang::$txt['upgrade_step_cleanup'];
$upcontext['cur_substep_num'] = $substep + 1;

if ($command_line) {
Expand Down Expand Up @@ -4181,7 +4190,7 @@ function CleanupAgreements()
}

// Skip anything not agreements.
if (str_starts_with($entry, 'agreements.') || !str_ends_with($entry, '.txt')) {
if (!str_starts_with($entry, 'agreements.') || !str_ends_with($entry, '.txt')) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions other/upgrade_1-0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,8 @@ if (!isset(Config::$modSettings['censor_vulgar']) || !isset(Config::$modSettings
INSERT IGNORE INTO {$db_prefix}settings
(variable, value)
VALUES
('censor_vulgar', 'Config::$modSettings[censor_vulgar]'),
('censor_proper', 'Config::$modSettings[censor_proper]')");
('censor_vulgar', '" . Config::$modSettings['censor_vulgar'] . "'),
('censor_proper', '" . Config::$modSettings['censor_proper'] . "')");

upgrade_query("
DROP TABLE IF EXISTS {$db_prefix}censor");
Expand Down
Loading