diff --git a/database/2023_01_07_023235_initial_structure_ndx.php b/database/2023_01_07_023235_initial_structure_ndx.php index 38260614..5768c04f 100644 --- a/database/2023_01_07_023235_initial_structure_ndx.php +++ b/database/2023_01_07_023235_initial_structure_ndx.php @@ -22,7 +22,7 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { return; } - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_roles ( role_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, role_hierarchy INT(11) NOT NULL DEFAULT 1, @@ -37,9 +37,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { KEY roles_hierarchy_index (role_hierarchy), KEY roles_hidden_index (role_hidden) ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_users ( user_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, username VARCHAR(255) NOT NULL, @@ -48,7 +48,7 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { register_ip VARBINARY(16) NOT NULL, last_ip VARBINARY(16) NOT NULL, user_super TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - user_country CHAR(2) NOT NULL DEFAULT \'XX\', + user_country CHAR(2) NOT NULL DEFAULT 'XX', user_colour INT(11) DEFAULT NULL, user_created TIMESTAMP NOT NULL DEFAULT current_timestamp(), user_active TIMESTAMP NULL DEFAULT NULL, @@ -73,16 +73,16 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_audit_log ( user_id INT(10) UNSIGNED DEFAULT NULL, log_action VARCHAR(50) NOT NULL, log_params TEXT NOT NULL, log_created TIMESTAMP NOT NULL DEFAULT current_timestamp(), log_ip VARBINARY(16) DEFAULT NULL, - log_country CHAR(2) NOT NULL DEFAULT \'XX\', + log_country CHAR(2) NOT NULL DEFAULT 'XX', KEY audit_log_user_id_foreign (user_id), KEY audit_log_created_index (log_created), CONSTRAINT audit_log_user_id_foreign @@ -91,9 +91,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_auth_tfa ( user_id INT(10) UNSIGNED NOT NULL, tfa_token CHAR(32) NOT NULL, @@ -107,9 +107,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_changelog_changes ( change_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT(10) UNSIGNED DEFAULT NULL, @@ -127,9 +127,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_changelog_tags ( tag_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, tag_name VARCHAR(255) NOT NULL, @@ -140,9 +140,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { UNIQUE KEY tag_name (tag_name), KEY tag_archived (tag_archived) ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_changelog_change_tags ( change_id INT(10) UNSIGNED NOT NULL, tag_id INT(10) UNSIGNED NOT NULL, @@ -159,9 +159,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_comments_categories ( category_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, category_name VARCHAR(255) NOT NULL, @@ -178,9 +178,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_comments_posts ( comment_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, category_id INT(10) UNSIGNED NOT NULL, @@ -207,9 +207,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_comments_votes ( comment_id INT(10) UNSIGNED NOT NULL, user_id INT(10) UNSIGNED NOT NULL, @@ -228,17 +228,17 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_config ( config_name varchar(100) NOT NULL, - config_value blob NOT NULL DEFAULT \'\', + config_value blob NOT NULL DEFAULT '', PRIMARY KEY (config_name) ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_emoticons ( emote_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, emote_order MEDIUMINT(9) NOT NULL DEFAULT 0, @@ -249,9 +249,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { KEY emotes_order (emote_order), KEY emotes_hierarchy (emote_hierarchy) ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_emoticons_strings ( emote_id INT(10) UNSIGNED NOT NULL, emote_string_order MEDIUMINT(9) NOT NULL DEFAULT 0, @@ -265,9 +265,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_forum_categories ( forum_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, forum_order INT(10) UNSIGNED NOT NULL DEFAULT 1, @@ -291,9 +291,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { KEY forum_link_clicks_index (forum_link_clicks), KEY forum_hidden_index (forum_hidden) ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_forum_permissions ( user_id INT(10) UNSIGNED DEFAULT NULL, role_id INT(10) UNSIGNED DEFAULT NULL, @@ -319,9 +319,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_forum_topics ( topic_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, forum_id INT(10) UNSIGNED NOT NULL, @@ -353,9 +353,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_forum_topics_track ( user_id INT(10) UNSIGNED NOT NULL, topic_id INT(10) UNSIGNED NOT NULL, @@ -382,9 +382,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_forum_posts ( post_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, topic_id INT(10) UNSIGNED NOT NULL, @@ -424,16 +424,16 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_login_attempts ( user_id INT(10) UNSIGNED DEFAULT NULL, attempt_success TINYINT(1) NOT NULL, attempt_ip VARBINARY(16) NOT NULL, - attempt_country CHAR(2) NOT NULL DEFAULT \'XX\', + attempt_country CHAR(2) NOT NULL DEFAULT 'XX', attempt_created TIMESTAMP NOT NULL DEFAULT current_timestamp(), - attempt_user_agent VARCHAR(255) NOT NULL DEFAULT \'\', + attempt_user_agent VARCHAR(255) NOT NULL DEFAULT '', KEY login_attempts_user_id_foreign (user_id), KEY login_attempts_created_index (attempt_created), KEY login_attempts_success_index (attempt_success), @@ -444,9 +444,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_news_categories ( category_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, category_name VARCHAR(255) NOT NULL, @@ -456,9 +456,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { PRIMARY KEY (category_id), KEY news_categories_is_hidden_index (category_is_hidden) ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_news_posts ( post_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, category_id INT(10) UNSIGNED NOT NULL, @@ -497,9 +497,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_permissions ( user_id INT(10) UNSIGNED DEFAULT NULL, role_id INT(10) UNSIGNED DEFAULT NULL, @@ -528,9 +528,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_profile_fields ( field_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, field_order INT(11) NOT NULL DEFAULT 0, @@ -541,15 +541,15 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { UNIQUE KEY profile_fields_key_unique (field_key), KEY profile_fields_order_key (field_order) ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_profile_fields_formats ( format_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, field_id INT(10) UNSIGNED NOT NULL DEFAULT 0, format_regex VARCHAR(255) DEFAULT NULL, format_link VARCHAR(255) DEFAULT NULL, - format_display VARCHAR(255) NOT NULL DEFAULT \'%s\', + format_display VARCHAR(255) NOT NULL DEFAULT '%s', PRIMARY KEY (format_id), KEY profile_field_format_field_foreign (field_id), CONSTRAINT profile_field_format_field_foreign @@ -558,9 +558,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_profile_fields_values ( field_id INT(10) UNSIGNED NOT NULL, user_id INT(10) UNSIGNED NOT NULL, @@ -586,9 +586,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_sessions ( session_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT(10) UNSIGNED NOT NULL, @@ -596,7 +596,7 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { session_ip VARBINARY(16) NOT NULL, session_ip_last VARBINARY(16) DEFAULT NULL, session_user_agent VARCHAR(255) NOT NULL, - session_country CHAR(2) NOT NULL DEFAULT \'XX\', + session_country CHAR(2) NOT NULL DEFAULT 'XX', session_expires TIMESTAMP NOT NULL DEFAULT (current_timestamp() + INTERVAL 1 MONTH), session_expires_bump TINYINT(3) UNSIGNED NOT NULL DEFAULT 1, session_created TIMESTAMP NOT NULL DEFAULT current_timestamp(), @@ -612,9 +612,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_users_password_resets ( user_id INT(10) UNSIGNED NOT NULL, reset_ip VARBINARY(16) NOT NULL, @@ -629,9 +629,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_user_roles ( user_id INT(10) UNSIGNED NOT NULL, role_id INT(10) UNSIGNED NOT NULL, @@ -648,9 +648,9 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_user_warnings ( warning_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT(10) UNSIGNED NOT NULL, @@ -680,6 +680,6 @@ final class InitialStructureNdx_20230107_023235 implements DbMigration { ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); } } diff --git a/database/2023_04_30_001226_create_topic_redirs_table.php b/database/2023_04_30_001226_create_topic_redirs_table.php index a9ee5cba..276f7e16 100644 --- a/database/2023_04_30_001226_create_topic_redirs_table.php +++ b/database/2023_04_30_001226_create_topic_redirs_table.php @@ -4,7 +4,7 @@ use Index\Db\Migration\DbMigration; final class CreateTopicRedirsTable_20230430_001226 implements DbMigration { public function migrate(DbConnection $conn): void { - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_forum_topics_redirects ( topic_id INT(10) UNSIGNED NOT NULL, user_id INT(10) UNSIGNED NULL DEFAULT NULL, @@ -18,6 +18,6 @@ final class CreateTopicRedirsTable_20230430_001226 implements DbMigration { ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); } } diff --git a/database/2023_07_21_121854_update_user_agent_storage.php b/database/2023_07_21_121854_update_user_agent_storage.php index 451ce8bd..4354018b 100644 --- a/database/2023_07_21_121854_update_user_agent_storage.php +++ b/database/2023_07_21_121854_update_user_agent_storage.php @@ -6,16 +6,16 @@ use Misuzu\ClientInfo; final class UpdateUserAgentStorage_20230721_121854 implements DbMigration { public function migrate(DbConnection $conn): void { // convert user agent fields to BLOB and add field for client info storage - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_login_attempts - CHANGE COLUMN attempt_user_agent attempt_user_agent TEXT NOT NULL COLLATE "utf8mb4_bin" AFTER attempt_created, + CHANGE COLUMN attempt_user_agent attempt_user_agent TEXT NOT NULL COLLATE 'utf8mb4_bin' AFTER attempt_created, ADD COLUMN attempt_client_info TEXT NULL DEFAULT NULL AFTER attempt_user_agent - '); - $conn->execute(' + SQL); + $conn->execute(<<<SQL ALTER TABLE msz_sessions - CHANGE column session_user_agent session_user_agent TEXT NOT NULL COLLATE "utf8mb4_bin" AFTER session_ip_last, + CHANGE column session_user_agent session_user_agent TEXT NOT NULL COLLATE 'utf8mb4_bin' AFTER session_ip_last, ADD COLUMN session_client_info TEXT NULL DEFAULT NULL AFTER session_user_agent - '); + SQL); // make sure all existing fields have client info fields filled $updateLoginAttempts = $conn->prepare('UPDATE msz_login_attempts SET attempt_client_info = ? WHERE attempt_user_agent = ?'); @@ -39,13 +39,13 @@ final class UpdateUserAgentStorage_20230721_121854 implements DbMigration { } // make client info fields NOT NULL - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_login_attempts - CHANGE COLUMN attempt_client_info attempt_client_info TEXT NOT NULL COLLATE "utf8mb4_bin" AFTER attempt_user_agent - '); - $conn->execute(' + CHANGE COLUMN attempt_client_info attempt_client_info TEXT NOT NULL COLLATE 'utf8mb4_bin' AFTER attempt_user_agent + SQL); + $conn->execute(<<<SQL ALTER TABLE msz_sessions - CHANGE COLUMN session_client_info session_client_info TEXT NOT NULL COLLATE "utf8mb4_bin" AFTER session_user_agent - '); + CHANGE COLUMN session_client_info session_client_info TEXT NOT NULL COLLATE 'utf8mb4_bin' AFTER session_user_agent + SQL); } } diff --git a/database/2023_07_24_201010_add_moderator_notes_table.php b/database/2023_07_24_201010_add_moderator_notes_table.php index 5d80532a..cb297c8a 100644 --- a/database/2023_07_24_201010_add_moderator_notes_table.php +++ b/database/2023_07_24_201010_add_moderator_notes_table.php @@ -4,7 +4,7 @@ use Index\Db\Migration\DbMigration; final class AddModeratorNotesTable_20230724_201010 implements DbMigration { public function migrate(DbConnection $conn): void { - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_users_modnotes ( note_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT(10) UNSIGNED NOT NULL, @@ -27,15 +27,15 @@ final class AddModeratorNotesTable_20230724_201010 implements DbMigration { ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB COLLATE=utf8mb4_bin - '); + SQL); // migrate existing notes - $conn->execute(' + $conn->execute(<<<SQL INSERT INTO msz_users_modnotes (user_id, author_id, note_created, note_title, note_body) - SELECT user_id, issuer_id, warning_created, warning_note, COALESCE(warning_note_private, "") + SELECT user_id, issuer_id, warning_created, warning_note, COALESCE(warning_note_private, '') FROM msz_user_warnings WHERE warning_type = 0 - '); + SQL); // delete notes from the warnings table $conn->execute('DELETE FROM msz_user_warnings WHERE warning_type = 0'); diff --git a/database/2023_07_26_175936_add_new_bans_table.php b/database/2023_07_26_175936_add_new_bans_table.php index 4b802bd0..84ec2d60 100644 --- a/database/2023_07_26_175936_add_new_bans_table.php +++ b/database/2023_07_26_175936_add_new_bans_table.php @@ -4,7 +4,7 @@ use Index\Db\Migration\DbMigration; final class AddNewBansTable_20230726_175936 implements DbMigration { public function migrate(DbConnection $conn): void { - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_users_bans ( ban_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT(10) UNSIGNED NOT NULL, @@ -31,14 +31,14 @@ final class AddNewBansTable_20230726_175936 implements DbMigration { ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB COLLATE=utf8mb4_bin - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL INSERT INTO msz_users_bans (user_id, mod_id, ban_severity, ban_reason_public, ban_reason_private, ban_created, ban_expires) SELECT user_id, issuer_id, 0, warning_note, COALESCE(warning_note_private, ""), warning_created, warning_duration FROM msz_user_warnings WHERE warning_type = 3 - '); + SQL); $conn->execute('DELETE FROM msz_user_warnings WHERE warning_type = 3'); } diff --git a/database/2023_07_26_210150_redo_warnings_table.php b/database/2023_07_26_210150_redo_warnings_table.php index f3017e9e..e79e0213 100644 --- a/database/2023_07_26_210150_redo_warnings_table.php +++ b/database/2023_07_26_210150_redo_warnings_table.php @@ -4,7 +4,7 @@ use Index\Db\Migration\DbMigration; final class RedoWarningsTable_20230726_210150 implements DbMigration { public function migrate(DbConnection $conn): void { - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_users_warnings ( warn_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT(10) UNSIGNED NOT NULL, @@ -26,16 +26,16 @@ final class RedoWarningsTable_20230726_210150 implements DbMigration { ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB COLLATE=utf8mb4_bin - '); + SQL); // migrate existing warnings, public and private note have been merged but that's fine in prod // still specifying type = 1 as well even though that should be the only type remaining - $conn->execute(' + $conn->execute(<<<SQL INSERT INTO msz_users_warnings (user_id, mod_id, warn_body, warn_created) - SELECT user_id, issuer_id, TRIM(CONCAT(COALESCE(warning_note, ""), "\n", COALESCE(warning_note_private, ""))), warning_created + SELECT user_id, issuer_id, TRIM(CONCAT(COALESCE(warning_note, ''), "\n", COALESCE(warning_note_private, ''))), warning_created FROM msz_user_warnings WHERE warning_type = 1 - '); + SQL); // drop the old table with non-plural "user" $conn->execute('DROP TABLE msz_user_warnings'); diff --git a/database/2023_07_28_212101_create_counters_table.php b/database/2023_07_28_212101_create_counters_table.php index 668e5948..3a681cb8 100644 --- a/database/2023_07_28_212101_create_counters_table.php +++ b/database/2023_07_28_212101_create_counters_table.php @@ -4,13 +4,13 @@ use Index\Db\Migration\DbMigration; final class CreateCountersTable_20230728_212101 implements DbMigration { public function migrate(DbConnection $conn): void { - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_counters ( counter_name VARBINARY(64) NOT NULL, - counter_value BIGINT(20) NOT NULL DEFAULT "0", + counter_value BIGINT(20) NOT NULL DEFAULT '0', counter_updated TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (counter_name) ) ENGINE=InnoDB COLLATE=utf8mb4_bin - '); + SQL); } } diff --git a/database/2023_08_03_114403_update_collations_in_various_tables.php b/database/2023_08_03_114403_update_collations_in_various_tables.php index 6e0fff19..ab2a6bb6 100644 --- a/database/2023_08_03_114403_update_collations_in_various_tables.php +++ b/database/2023_08_03_114403_update_collations_in_various_tables.php @@ -4,159 +4,159 @@ use Index\Db\Migration\DbMigration; final class UpdateCollationsInVariousTables_20230803_114403 implements DbMigration { public function migrate(DbConnection $conn): void { - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_audit_log - CHANGE COLUMN log_action log_action VARCHAR(50) NOT NULL COLLATE "ascii_general_ci" AFTER user_id, - CHANGE COLUMN log_country log_country CHAR(2) NOT NULL DEFAULT "XX" COLLATE "ascii_general_ci" AFTER log_ip; - '); + CHANGE COLUMN log_action log_action VARCHAR(50) NOT NULL COLLATE 'ascii_general_ci' AFTER user_id, + CHANGE COLUMN log_country log_country CHAR(2) NOT NULL DEFAULT 'XX' COLLATE 'ascii_general_ci' AFTER log_ip; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_auth_tfa - CHANGE COLUMN tfa_token tfa_token CHAR(32) NOT NULL COLLATE "ascii_bin" AFTER user_id; - '); + CHANGE COLUMN tfa_token tfa_token CHAR(32) NOT NULL COLLATE 'ascii_bin' AFTER user_id; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_changelog_changes - CHANGE COLUMN change_log change_log VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER change_created, - CHANGE COLUMN change_text change_text TEXT NULL DEFAULT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER change_log; - '); + CHANGE COLUMN change_log change_log VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER change_created, + CHANGE COLUMN change_text change_text TEXT NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER change_log; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_changelog_tags - CHANGE COLUMN tag_name tag_name VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER tag_id, - CHANGE COLUMN tag_description tag_description TEXT NULL DEFAULT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER tag_name; - '); + CHANGE COLUMN tag_name tag_name VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER tag_id, + CHANGE COLUMN tag_description tag_description TEXT NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER tag_name; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_comments_categories - CHANGE COLUMN category_name category_name VARCHAR(255) NOT NULL COLLATE "ascii_bin" AFTER category_id; - '); + CHANGE COLUMN category_name category_name VARCHAR(255) NOT NULL COLLATE 'ascii_bin' AFTER category_id; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_comments_posts - CHANGE COLUMN comment_text comment_text TEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER comment_reply_to; - '); + CHANGE COLUMN comment_text comment_text TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER comment_reply_to; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_config - CHANGE COLUMN config_name config_name VARCHAR(100) NOT NULL COLLATE "ascii_general_ci" FIRST; - '); + CHANGE COLUMN config_name config_name VARCHAR(100) NOT NULL COLLATE 'ascii_general_ci' FIRST; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_emoticons - CHANGE COLUMN emote_url emote_url VARCHAR(255) NOT NULL COLLATE "ascii_bin" AFTER emote_hierarchy; - '); + CHANGE COLUMN emote_url emote_url VARCHAR(255) NOT NULL COLLATE 'ascii_bin' AFTER emote_hierarchy; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_emoticons_strings - CHANGE COLUMN emote_string emote_string VARCHAR(50) NOT NULL COLLATE "ascii_general_ci" AFTER emote_string_order; - '); + CHANGE COLUMN emote_string emote_string VARCHAR(50) NOT NULL COLLATE 'ascii_general_ci' AFTER emote_string_order; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_forum_categories - CHANGE COLUMN forum_name forum_name VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER forum_parent, - CHANGE COLUMN forum_description forum_description TEXT NULL DEFAULT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER forum_type, - CHANGE COLUMN forum_icon forum_icon VARCHAR(50) NULL DEFAULT NULL COLLATE "ascii_bin" AFTER forum_description, - CHANGE COLUMN forum_link forum_link VARCHAR(255) NULL DEFAULT NULL COLLATE "ascii_bin" AFTER forum_colour; - '); + CHANGE COLUMN forum_name forum_name VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER forum_parent, + CHANGE COLUMN forum_description forum_description TEXT NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER forum_type, + CHANGE COLUMN forum_icon forum_icon VARCHAR(50) NULL DEFAULT NULL COLLATE 'ascii_bin' AFTER forum_description, + CHANGE COLUMN forum_link forum_link VARCHAR(255) NULL DEFAULT NULL COLLATE 'ascii_bin' AFTER forum_colour; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_forum_posts - CHANGE COLUMN post_text post_text MEDIUMTEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER post_ip; - '); + CHANGE COLUMN post_text post_text MEDIUMTEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER post_ip; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_forum_topics - CHANGE COLUMN topic_title topic_title VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER topic_type; - '); + CHANGE COLUMN topic_title topic_title VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER topic_type; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_forum_topics_redirects - CHANGE COLUMN topic_redir_url topic_redir_url VARCHAR(255) NOT NULL COLLATE "ascii_bin" AFTER user_id; - '); + CHANGE COLUMN topic_redir_url topic_redir_url VARCHAR(255) NOT NULL COLLATE 'ascii_bin' AFTER user_id; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_login_attempts - CHANGE COLUMN attempt_country attempt_country CHAR(2) NOT NULL DEFAULT "XX" COLLATE "ascii_general_ci" AFTER attempt_ip, - CHANGE COLUMN attempt_user_agent attempt_user_agent TEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER attempt_created; - '); + CHANGE COLUMN attempt_country attempt_country CHAR(2) NOT NULL DEFAULT 'XX' COLLATE 'ascii_general_ci' AFTER attempt_ip, + CHANGE COLUMN attempt_user_agent attempt_user_agent TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER attempt_created; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_news_categories - CHANGE COLUMN category_name category_name VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER category_id, - CHANGE COLUMN category_description category_description TEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER category_name; - '); + CHANGE COLUMN category_name category_name VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER category_id, + CHANGE COLUMN category_description category_description TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER category_name; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_news_posts - CHANGE COLUMN post_title post_title VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER post_is_featured, - CHANGE COLUMN post_text post_text TEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER post_title; - '); + CHANGE COLUMN post_title post_title VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER post_is_featured, + CHANGE COLUMN post_text post_text TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER post_title; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_profile_fields - CHANGE COLUMN field_key field_key VARCHAR(50) NOT NULL COLLATE "ascii_general_ci" AFTER field_order, - CHANGE COLUMN field_title field_title VARCHAR(50) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER field_key, - CHANGE COLUMN field_regex field_regex VARCHAR(255) NOT NULL COLLATE "ascii_bin" AFTER field_title; - '); + CHANGE COLUMN field_key field_key VARCHAR(50) NOT NULL COLLATE 'ascii_general_ci' AFTER field_order, + CHANGE COLUMN field_title field_title VARCHAR(50) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER field_key, + CHANGE COLUMN field_regex field_regex VARCHAR(255) NOT NULL COLLATE 'ascii_bin' AFTER field_title; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_profile_fields_formats - CHANGE COLUMN format_regex format_regex VARCHAR(255) NULL DEFAULT NULL COLLATE "ascii_bin" AFTER field_id, - CHANGE COLUMN format_link format_link VARCHAR(255) NULL DEFAULT NULL COLLATE "ascii_bin" AFTER format_regex, - CHANGE COLUMN format_display format_display VARCHAR(255) NOT NULL DEFAULT "%s" COLLATE "utf8mb4_unicode_520_ci" AFTER format_link; - '); + CHANGE COLUMN format_regex format_regex VARCHAR(255) NULL DEFAULT NULL COLLATE 'ascii_bin' AFTER field_id, + CHANGE COLUMN format_link format_link VARCHAR(255) NULL DEFAULT NULL COLLATE 'ascii_bin' AFTER format_regex, + CHANGE COLUMN format_display format_display VARCHAR(255) NOT NULL DEFAULT '%s' COLLATE 'utf8mb4_unicode_520_ci' AFTER format_link; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_profile_fields_values - CHANGE COLUMN field_value field_value VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER format_id; - '); + CHANGE COLUMN field_value field_value VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER format_id; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_roles - CHANGE COLUMN role_name role_name VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER role_hierarchy, - CHANGE COLUMN role_title role_title VARCHAR(64) NULL DEFAULT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER role_name, - CHANGE COLUMN role_description role_description TEXT NULL DEFAULT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER role_title; - '); + CHANGE COLUMN role_name role_name VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER role_hierarchy, + CHANGE COLUMN role_title role_title VARCHAR(64) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER role_name, + CHANGE COLUMN role_description role_description TEXT NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER role_title; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_sessions - CHANGE COLUMN session_user_agent session_user_agent TEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER session_ip_last, - CHANGE COLUMN session_country session_country CHAR(2) NOT NULL DEFAULT "XX" COLLATE "ascii_general_ci" AFTER session_client_info; - '); + CHANGE COLUMN session_user_agent session_user_agent TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER session_ip_last, + CHANGE COLUMN session_country session_country CHAR(2) NOT NULL DEFAULT 'XX' COLLATE 'ascii_general_ci' AFTER session_client_info; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_users - CHANGE COLUMN username username VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER user_id, - CHANGE COLUMN password password VARCHAR(255) NULL DEFAULT NULL COLLATE "ascii_bin" AFTER username, - CHANGE COLUMN email email VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER password, - CHANGE COLUMN user_country user_country CHAR(2) NOT NULL DEFAULT "XX" COLLATE "ascii_general_ci" AFTER user_super, - CHANGE COLUMN user_totp_key user_totp_key CHAR(26) NULL DEFAULT NULL COLLATE "ascii_bin" AFTER display_role, - CHANGE COLUMN user_about_content user_about_content TEXT NULL DEFAULT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER user_totp_key, - CHANGE COLUMN user_signature_content user_signature_content TEXT NULL DEFAULT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER user_about_parser, - CHANGE COLUMN user_title user_title VARCHAR(64) NULL DEFAULT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER user_background_settings; - '); + CHANGE COLUMN username username VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER user_id, + CHANGE COLUMN password password VARCHAR(255) NULL DEFAULT NULL COLLATE 'ascii_bin' AFTER username, + CHANGE COLUMN email email VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER password, + CHANGE COLUMN user_country user_country CHAR(2) NOT NULL DEFAULT 'XX' COLLATE 'ascii_general_ci' AFTER user_super, + CHANGE COLUMN user_totp_key user_totp_key CHAR(26) NULL DEFAULT NULL COLLATE 'ascii_bin' AFTER display_role, + CHANGE COLUMN user_about_content user_about_content TEXT NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER user_totp_key, + CHANGE COLUMN user_signature_content user_signature_content TEXT NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER user_about_parser, + CHANGE COLUMN user_title user_title VARCHAR(64) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER user_background_settings; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_users_bans - CHANGE COLUMN ban_reason_public ban_reason_public TEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER ban_severity, - CHANGE COLUMN ban_reason_private ban_reason_private TEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER ban_reason_public; - '); + CHANGE COLUMN ban_reason_public ban_reason_public TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER ban_severity, + CHANGE COLUMN ban_reason_private ban_reason_private TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER ban_reason_public; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_users_modnotes - CHANGE COLUMN note_title note_title VARCHAR(255) NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER note_created, - CHANGE COLUMN note_body note_body TEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER note_title; - '); + CHANGE COLUMN note_title note_title VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER note_created, + CHANGE COLUMN note_body note_body TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER note_title; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_users_password_resets - CHANGE COLUMN verification_code verification_code CHAR(12) NULL DEFAULT NULL COLLATE "ascii_general_ci" AFTER reset_requested; - '); + CHANGE COLUMN verification_code verification_code CHAR(12) NULL DEFAULT NULL COLLATE 'ascii_general_ci' AFTER reset_requested; + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_users_warnings - CHANGE COLUMN warn_body warn_body TEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci" AFTER mod_id; - '); + CHANGE COLUMN warn_body warn_body TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci' AFTER mod_id; + SQL); } } diff --git a/database/2023_08_30_213930_new_permissions_system.php b/database/2023_08_30_213930_new_permissions_system.php index 9ed92095..399f01bb 100644 --- a/database/2023_08_30_213930_new_permissions_system.php +++ b/database/2023_08_30_213930_new_permissions_system.php @@ -7,7 +7,7 @@ final class NewPermissionsSystem_20230830_213930 implements DbMigration { // make sure cron doesn't fuck us over $conn->execute('DELETE FROM msz_config WHERE config_name = "perms.needsRecalc"'); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_perms ( user_id INT(10) UNSIGNED NULL DEFAULT NULL, role_id INT(10) UNSIGNED NULL DEFAULT NULL, @@ -36,15 +36,15 @@ final class NewPermissionsSystem_20230830_213930 implements DbMigration { ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_perms ADD CONSTRAINT perms_53bit CHECK (perms_allow >= 0 AND perms_deny >= 0 AND perms_allow <= 9007199254740991 AND perms_deny <= 9007199254740991) - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_perms_calculated ( user_id INT(10) UNSIGNED NULL DEFAULT NULL, forum_id INT(10) UNSIGNED NULL DEFAULT NULL, @@ -65,21 +65,34 @@ final class NewPermissionsSystem_20230830_213930 implements DbMigration { ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB COLLATE=utf8mb4_bin - '); + SQL); - $conn->execute(' + $conn->execute(<<<SQL ALTER TABLE msz_perms_calculated ADD CONSTRAINT perms_calculated_53bit CHECK (perms_calculated >= 0 AND perms_calculated <= 9007199254740991) - '); + SQL); - $insert = $conn->prepare('INSERT INTO msz_perms (user_id, role_id, forum_id, perms_category, perms_allow, perms_deny) VALUES (?, ?, ?, ?, ?, ?)'); + $insert = $conn->prepare(<<<SQL + INSERT INTO msz_perms ( + user_id, role_id, forum_id, perms_category, perms_allow, perms_deny + ) VALUES (?, ?, ?, ?, ?, ?) + SQL); - $result = $conn->query('SELECT user_id, role_id, general_perms_allow, general_perms_deny, user_perms_allow, user_perms_deny, changelog_perms_allow, changelog_perms_deny, news_perms_allow, news_perms_deny, forum_perms_allow, forum_perms_deny, comments_perms_allow, comments_perms_deny FROM msz_permissions'); + $result = $conn->query(<<<SQL + SELECT user_id, role_id, + general_perms_allow, general_perms_deny, + user_perms_allow, user_perms_deny, + changelog_perms_allow, changelog_perms_deny, + news_perms_allow, news_perms_deny, + forum_perms_allow, forum_perms_deny, + comments_perms_allow, comments_perms_deny + FROM msz_permissions + SQL); while($result->next()) { $insert->reset(); - $insert->nextParameter($result->isNull(0) ? null : $result->getString(0)); - $insert->nextParameter($result->isNull(1) ? null : $result->getString(1)); + $insert->nextParameter($result->getStringOrNull(0)); + $insert->nextParameter($result->getStringOrNull(1)); $insert->nextParameter(null); $insert->nextParameter('user'); $insert->nextParameter($result->getInteger(4)); @@ -104,11 +117,15 @@ final class NewPermissionsSystem_20230830_213930 implements DbMigration { $insert->execute(); } - $result = $conn->query('SELECT user_id, role_id, forum_id, forum_perms_allow, forum_perms_deny FROM msz_forum_permissions'); + $result = $conn->query(<<<SQL + SELECT user_id, role_id, forum_id, + forum_perms_allow, forum_perms_deny + FROM msz_forum_permissions + SQL); while($result->next()) { $insert->reset(); - $insert->nextParameter($result->isNull(0) ? null : $result->getString(0)); - $insert->nextParameter($result->isNull(1) ? null : $result->getString(1)); + $insert->nextParameter($result->getStringOrNull(0)); + $insert->nextParameter($result->getStringOrNull(1)); $insert->nextParameter($result->getString(2)); $insert->nextParameter('forum'); $insert->nextParameter($result->getInteger(3)); diff --git a/database/2024_01_30_233734_create_messages_table.php b/database/2024_01_30_233734_create_messages_table.php index b127243c..d14d95b3 100644 --- a/database/2024_01_30_233734_create_messages_table.php +++ b/database/2024_01_30_233734_create_messages_table.php @@ -4,20 +4,20 @@ use Index\Db\Migration\DbMigration; final class CreateMessagesTable_20240130_233734 implements DbMigration { public function migrate(DbConnection $conn): void { - $conn->execute(' + $conn->execute(<<<SQL CREATE TABLE msz_messages ( - msg_id BINARY(8) NOT NULL, - msg_owner_id INT(10) UNSIGNED NOT NULL, - msg_author_id INT(10) UNSIGNED NULL DEFAULT NULL, - msg_recipient_id INT(10) UNSIGNED NULL DEFAULT NULL, - msg_reply_to BINARY(8) NULL DEFAULT NULL, - msg_title TINYTEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci", - msg_body TEXT NOT NULL COLLATE "utf8mb4_unicode_520_ci", - msg_parser TINYINT(3) UNSIGNED NOT NULL, - msg_created TIMESTAMP NOT NULL DEFAULT current_timestamp(), - msg_sent TIMESTAMP NULL DEFAULT NULL, - msg_read TIMESTAMP NULL DEFAULT NULL, - msg_deleted TIMESTAMP NULL DEFAULT NULL, + msg_id BINARY(8) NOT NULL, + msg_owner_id INT(10) UNSIGNED NOT NULL, + msg_author_id INT(10) UNSIGNED NULL DEFAULT NULL, + msg_recipient_id INT(10) UNSIGNED NULL DEFAULT NULL, + msg_reply_to BINARY(8) NULL DEFAULT NULL, + msg_title TINYTEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci', + msg_body TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci', + msg_parser TINYINT(3) UNSIGNED NOT NULL, + msg_created TIMESTAMP NOT NULL DEFAULT current_timestamp(), + msg_sent TIMESTAMP NULL DEFAULT NULL, + msg_read TIMESTAMP NULL DEFAULT NULL, + msg_deleted TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (msg_id, msg_owner_id), KEY messages_owner_foreign (msg_owner_id), KEY messages_author_foreign (msg_author_id), @@ -43,6 +43,6 @@ final class CreateMessagesTable_20240130_233734 implements DbMigration { ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB COLLATE=utf8mb4_bin; - '); + SQL); } } diff --git a/database/2024_06_02_194809_base_sixty_four_encode_pms_in_db.php b/database/2024_06_02_194809_base_sixty_four_encode_pms_in_db.php index fb74b355..2697ff47 100644 --- a/database/2024_06_02_194809_base_sixty_four_encode_pms_in_db.php +++ b/database/2024_06_02_194809_base_sixty_four_encode_pms_in_db.php @@ -4,11 +4,15 @@ use Index\Db\Migration\DbMigration; final class BaseSixtyFourEncodePmsInDb_20240602_194809 implements DbMigration { public function migrate(DbConnection $conn): void { - $conn->execute('UPDATE msz_messages SET msg_title = TO_BASE64(msg_title), msg_body = TO_BASE64(msg_body)'); - $conn->execute(' - ALTER TABLE `msz_messages` - CHANGE COLUMN `msg_title` `msg_title` TINYBLOB NOT NULL AFTER `msg_reply_to`, - CHANGE COLUMN `msg_body` `msg_body` BLOB NOT NULL AFTER `msg_title`; - '); + $conn->execute(<<<SQL + UPDATE msz_messages + SET msg_title = TO_BASE64(msg_title), + msg_body = TO_BASE64(msg_body) + SQL); + $conn->execute(<<<SQL + ALTER TABLE msz_messages + CHANGE COLUMN msg_title msg_title TINYBLOB NOT NULL AFTER msg_reply_to, + CHANGE COLUMN msg_body msg_body BLOB NOT NULL AFTER msg_title; + SQL); } } diff --git a/misuzu.php b/misuzu.php index 0588eab3..73b4532b 100644 --- a/misuzu.php +++ b/misuzu.php @@ -38,7 +38,10 @@ if($env->hasValues('sentry:dsn')) })($env->scopeTo('sentry')); $db = DbBackends::create($env->getString('database:dsn', 'null:')); -$db->execute('SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';'); +$db->execute(<<<SQL + SET SESSION time_zone = '+00:00', + sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; +SQL); $cfg = new DbConfig($db, 'msz_config'); diff --git a/public-legacy/comments.php b/public-legacy/comments.php index 323c2ae7..a5407619 100644 --- a/public-legacy/comments.php +++ b/public-legacy/comments.php @@ -157,7 +157,7 @@ switch($commentMode) { : 0; $categoryInfo = $msz->comments->getCategory(categoryId: (string)$categoryId); } catch(RuntimeException $ex) { - Template::displayInfo('This comment category doesn\'t exist.', 404); + Template::displayInfo("This comment category doesn't exist.", 404); } $canLock = $perms->check(Perm::G_COMMENTS_LOCK); diff --git a/public-legacy/manage/users/role.php b/public-legacy/manage/users/role.php index bfc13faa..5a10a11d 100644 --- a/public-legacy/manage/users/role.php +++ b/public-legacy/manage/users/role.php @@ -36,7 +36,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) { $userRank = $msz->usersCtx->users->getUserRank($currentUser); if(!$isNew && !$currentUser->super && $roleInfo->rank >= $userRank) { - echo 'You aren\'t allowed to edit this role.'; + echo "You aren't allowed to edit this role."; break; } @@ -67,7 +67,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) { ]); if(!$currentUser->super && $roleRank >= $userRank) { - echo 'You aren\'t allowed to make a role with equal rank to your own.'; + echo "You aren't allowed to make a role with equal rank to your own."; break; } diff --git a/public-legacy/manage/users/user.php b/public-legacy/manage/users/user.php index 5e837bb7..3e09b65d 100644 --- a/public-legacy/manage/users/user.php +++ b/public-legacy/manage/users/user.php @@ -52,7 +52,7 @@ if(CSRF::validateRequest() && $canEdit) { if(!$canImpersonate) { $notices[] = 'You must be a super user to do this.'; } elseif(!is_string($_POST['impersonate_user']) || $_POST['impersonate_user'] !== 'meow') { - $notices[] = 'You didn\'t say the magic word.'; + $notices[] = "You didn't say the magic word!"; } else { $allowToImpersonate = $currentUser->super; @@ -71,7 +71,7 @@ if(CSRF::validateRequest() && $canEdit) { AuthTokenCookie::apply($msz->authCtx->createAuthTokenPacker()->pack($tokenInfo)); Tools::redirect($msz->urls->format('index')); return; - } else $notices[] = 'You aren\'t allowed to impersonate this user.'; + } else $notices[] = "You aren't allowed to impersonate this user."; } } @@ -147,7 +147,7 @@ if(CSRF::validateRequest() && $canEdit) { $displayRole = (string)($_POST['user']['display_role'] ?? 0); if(!$msz->usersCtx->users->hasRole($userInfo, $displayRole)) - $notices[] = 'User does not have the role you\'re trying to assign as primary.'; + $notices[] = "User does not have the role you're trying to assign as primary."; $countryValidation = strlen($setCountry) === 2 && ctype_alpha($setCountry) diff --git a/public-legacy/profile.php b/public-legacy/profile.php index 2d5ee719..729ae48e 100644 --- a/public-legacy/profile.php +++ b/public-legacy/profile.php @@ -109,13 +109,13 @@ if($isEditing) { if(!empty($_POST)) { if(!CSRF::validateRequest()) { - $notices[] = 'Couldn\'t verify you, please refresh the page and retry.'; + $notices[] = "Couldn't verify you, please refresh the page and retry."; } else { $profileFieldsSubmit = filter_input(INPUT_POST, 'profile', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); if(!empty($profileFieldsSubmit)) { if(!$perms->edit_profile) { - $notices[] = 'You\'re not allowed to edit your profile'; + $notices[] = "You're not allowed to edit your profile."; } else { $profileFieldInfos = iterator_to_array($msz->profileCtx->fields->getFields()); $profileFieldsSetInfos = []; @@ -135,7 +135,7 @@ if($isEditing) { $profileFieldsSetInfos[] = $fieldInfo; $profileFieldsSetValues[] = $fieldValue; } else - $notices[] = sprintf('%s isn\'t properly formatted.', $fieldInfo->title); + $notices[] = sprintf("%s isn't properly formatted.", $fieldInfo->title); unset($fieldName, $fieldValue, $fieldInfo); } @@ -209,7 +209,7 @@ if($isEditing) { $avatarAsset->delete(); } else { if(!$perms->edit_avatar) { - $notices[] = 'You aren\'t allow to change your avatar.'; + $notices[] = "You aren't allow to change your avatar."; } elseif(!empty($_FILES['avatar']) && is_array($_FILES['avatar']) && !empty($_FILES['avatar']['name']['file'])) { @@ -237,7 +237,7 @@ if($isEditing) { $notices[] = match($exMessage) { '$path is not a valid image.' => 'The file you uploaded was not an image!', '$path is not an allowed image file.' => 'This type of image is not supported, keep to PNG, JPG or GIF!', - 'Dimensions of $path are too large.' => sprintf('Your avatar can\'t be larger than %dx%d!', $avatarAsset->getMaxWidth(), $avatarAsset->getMaxHeight()), + 'Dimensions of $path are too large.' => sprintf("Your avatar can't be larger than %dx%d!", $avatarAsset->getMaxWidth(), $avatarAsset->getMaxHeight()), 'File size of $path is too large.' => sprintf('Your avatar is not allowed to be larger in file size than %s!', ByteFormat::format($avatarAsset->getMaxBytes())), default => $exMessage, }; @@ -258,7 +258,7 @@ if($isEditing) { $backgroundAsset = null; } else { if(!$perms->edit_background) { - $notices[] = 'You aren\'t allow to change your background.'; + $notices[] = "You aren't allow to change your background."; } elseif(!empty($_FILES['bg_file']) && is_array($_FILES['bg_file'])) { if(!empty($_FILES['bg_file']['name'])) { if($_FILES['bg_file']['error'] !== UPLOAD_ERR_OK) { @@ -285,7 +285,7 @@ if($isEditing) { $notices[] = match($exMessage) { '$path is not a valid image.' => 'The file you uploaded was not an image!', '$path is not an allowed image file.' => 'This type of image is not supported, keep to PNG, JPG or GIF!', - 'Dimensions of $path are too large.' => sprintf('Your background can\'t be larger than %dx%d!', $backgroundAsset->getMaxWidth(), $backgroundAsset->getMaxHeight()), + 'Dimensions of $path are too large.' => sprintf("Your background can't be larger than %dx%d!", $backgroundAsset->getMaxWidth(), $backgroundAsset->getMaxHeight()), 'File size of $path is too large.' => sprintf('Your background is not allowed to be larger in file size than %s!', ByteFormat::format($backgroundAsset->getMaxBytes())), default => $exMessage, }; diff --git a/src/Perm.php b/src/Perm.php index a5fb52ca..574eb03c 100644 --- a/src/Perm.php +++ b/src/Perm.php @@ -362,7 +362,7 @@ final class Perm { //self::C_USER_SILENCE => 'Can silence other users.', self::C_MESSAGE_BROADCAST => 'Can broadcast messages across all channels.', self::C_NICK_SET_OWN => 'Can change own nickname.', - self::C_NICK_SET_ANY => 'Can change ANYONE\'s nickname.', + self::C_NICK_SET_ANY => "Can change ANYONE's nickname.", self::C_CHANNEL_CREATE => 'Can create channels.', self::C_CHANNEL_SET_PERSIST => 'Can set channels to persist after all users leave it.', self::C_CHANNEL_SET_PASSWORD => 'Can set passwords for own channel.',