Skip to content

Commit

Permalink
Forgot PHP CS
Browse files Browse the repository at this point in the history
  • Loading branch information
jdarwood007 committed Mar 3, 2024
1 parent 61cb192 commit 5f27462
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 173 deletions.
47 changes: 24 additions & 23 deletions Sources/Maintenance/Migration/v2_1/Migration1000.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

use SMF\Config;
use SMF\Db\DatabaseApi as Db;
use SMF\Db\Schema\v3_0\MemberLogins;
use SMF\Maintenance;
use SMF\Maintenance\Migration;
use SMF\Db\Schema\v3_0;
use SMF\Security;

class Migration0001 extends Migration
Expand Down Expand Up @@ -71,23 +68,24 @@ public function execute(): bool

// Copying the current "allow users to disable word censor" setting.
if (!isset(Config::$modSettings['allow_no_censored'])) {
$request = $this->query('', '
$request = $this->query(
'',
'
SELECT value
FROM {db_prefix}themes
WHERE variable={string:allow_no_censored}
AND id_theme = 1 OR id_theme = {int:default_theme}',
[
'allow_no_censored' => 'allow_no_censored',
'default_theme' => Config::$modSettings['theme_default']
]);

[
'allow_no_censored' => 'allow_no_censored',
'default_theme' => Config::$modSettings['theme_default'],
],
);

// Is it set for either "default" or the one they've set as default?
while ($row = Db::$db->fetch_assoc($request))
{
if ($row['value'] == 1)
{
while ($row = Db::$db->fetch_assoc($request)) {
if ($row['value'] == 1) {
$newSettings['allow_no_censored'] = 1;

// Don't do this twice...
break;
}
Expand All @@ -97,35 +95,38 @@ public function execute(): bool
// Add all any settings to the settings table.
foreach ($newSettings as $key => $default) {
if (!isset(Config::$modSettings[$key])) {
$newSettings[$key] = $default;
$newSettings[$key] = $default;
}
}

// Enable some settings we ripped from Theme settings.
$ripped_settings = array('show_modify', 'show_user_images', 'show_blurb', 'show_profile_buttons', 'subject_toggle', 'hide_post_group');
$ripped_settings = ['show_modify', 'show_user_images', 'show_blurb', 'show_profile_buttons', 'subject_toggle', 'hide_post_group'];

$request = Db::$db->query('', '
$request = Db::$db->query(
'',
'
SELECT variable, value
FROM {db_prefix}themes
WHERE variable IN({array_string:ripped_settings})
AND id_member = 0
AND id_theme = 1',
array(
[
'ripped_settings' => $ripped_settings,
)
],
);

$inserts = array();

$inserts = [];

while ($row = Db::$db->fetch_assoc($request)) {
if (!isset(Config::$modSettings[$row['variable']])) {
$newSettings[$row['variable']] = $row['value'];
$newSettings[$row['variable']] = $row['value'];
}
}
Db::$db->free_result($request);

// Calculate appropriate hash cost.
if (!isset(Config::$modSettings['bcrypt_hash_cost'])) {
$newSettings['bcrypt_hash_cost'] = Security::hashBenchmark();
$newSettings['bcrypt_hash_cost'] = Security::hashBenchmark();
}

// Adding new profile data export settings.
Expand Down
4 changes: 1 addition & 3 deletions Sources/Maintenance/Migration/v2_1/Migration1003.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
use SMF\Config;
use SMF\Db\DatabaseApi as Db;
use SMF\Db\Schema\v3_0\MemberLogins;
use SMF\Maintenance;
use SMF\Maintenance\Migration;
use SMF\Db\Schema\v3_0;

class Migration0001 extends Migration
{
Expand All @@ -46,7 +44,7 @@ public function execute(): bool

if (!in_array(Config::$db_prefix . 'member_logins', $tables)) {
$member_logins = new MemberLogins();
$member_logins->create();
$member_logins->create();
}

return true;
Expand Down
18 changes: 9 additions & 9 deletions Sources/Maintenance/Migration/v2_1/Migration1004.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

use SMF\Config;
use SMF\Db\DatabaseApi as Db;
use SMF\Db\Schema\v3_0\MemberLogins;
use SMF\Maintenance;
use SMF\Maintenance\Migration;
use SMF\Db\Schema\v3_0;

class Migration0001 extends Migration
{
Expand Down Expand Up @@ -48,19 +45,22 @@ public function execute(): bool
SELECT id_member, id_cat
FROM {db_prefix}collapsed_categories');

$inserts = array();
while ($row = Db::$db->fetch_assoc($request))
$inserts[] = array($row['id_member'], 1, 'collapse_category_' . $row['id_cat'], $row['id_cat']);
$inserts = [];

while ($row = Db::$db->fetch_assoc($request)) {
$inserts[] = [$row['id_member'], 1, 'collapse_category_' . $row['id_cat'], $row['id_cat']];
}
Db::$db->free_result($request);

$result = false;

if (!empty($inserts)) {
$result = Db::$db->insert('replace',
$result = Db::$db->insert(
'replace',
'{db_prefix}themes',
array('id_member' => 'int', 'id_theme' => 'int', 'variable' => 'string', 'value' => 'string'),
['id_member' => 'int', 'id_theme' => 'int', 'variable' => 'string', 'value' => 'string'],
$inserts,
array('id_theme', 'id_member', 'variable')
['id_theme', 'id_member', 'variable'],
);
}

Expand Down
22 changes: 12 additions & 10 deletions Sources/Maintenance/Migration/v2_1/Migration1005.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
use SMF\BBCodeParser;
use SMF\Config;
use SMF\Db\DatabaseApi as Db;
use SMF\Db\Schema\v3_0\MemberLogins;
use SMF\Maintenance;
use SMF\Maintenance\Migration;
use SMF\Db\Schema\v3_0;
use SMF\Utils;

class Migration0001 extends Migration
Expand All @@ -45,26 +43,30 @@ public function isCandidate(): bool
public function execute(): bool
{

$request = Db::$db->query('', '
$request = Db::$db->query(
'',
'
SELECT name, description, id_board
FROM {db_prefix}boards
WHERE id_board > {int:start}',
[
'start' => Maintenance::getCurrentStart()
]
'start' => Maintenance::getCurrentStart(),
],
);

while ($row = Db::$db->fetch_assoc($request))
{
Db::$db->query('', '
while ($row = Db::$db->fetch_assoc($request)) {
Db::$db->query(
'',
'
UPDATE {db_prefix}boards
SET name = {string:name}, description = {string:description}
WHERE id = {int:id}',
[
'id' => $row['id'],
'name' => Utils::htmlspecialchars(strip_tags(BBCodeParser::load()->unparse($row['name']))),
'description' => Utils::htmlspecialchars(strip_tags(BBCodeParser::load()->unparse($row['description']))),
]);
'description' => Utils::htmlspecialchars(strip_tags(BBCodeParser::load()->unparse($row['description']))),
],
);

Maintenance::setCurrentStart();
$this->handleTimeout();
Expand Down
Loading

0 comments on commit 5f27462

Please sign in to comment.