diff --git a/Languages/en_US/Maintenance.php b/Languages/en_US/Maintenance.php index 38b817e242..3f3f4ee447 100644 --- a/Languages/en_US/Maintenance.php +++ b/Languages/en_US/Maintenance.php @@ -65,13 +65,7 @@ $txt['maintenance_step'] = 'Step'; $txt['maintenance_overall_progress'] = 'Overall Progress'; $txt['maintenance_substep_progress'] = 'Step Progress'; -$txt['maintenance_time_elasped_ms'] = 'Time Elapsed {m, plural, - one {# minute} - other {# minutes} -} and {s, plural, - one {# second} - other {# seconds} -}'; +$txt['maintenance_time_elapsed'] = 'Time Elapsed: '; // File Permissions. $txt['chmod_linux_info'] = 'If you have a shell account, the following command can automatically correct permissions on these files'; diff --git a/Sources/Config.php b/Sources/Config.php index 8fe92224cb..33b2cb09ff 100644 --- a/Sources/Config.php +++ b/Sources/Config.php @@ -998,23 +998,23 @@ public static function set(array $settings): void } // Make sure the paths are correct... at least try to fix them. - if (empty(self::$boarddir) || !is_dir(realpath(self::$boarddir))) { + if (empty(self::$boarddir) || !is_dir((string) realpath(self::$boarddir))) { self::$boarddir = !empty($_SERVER['SCRIPT_FILENAME']) ? \dirname(realpath($_SERVER['SCRIPT_FILENAME'])) : \dirname(__DIR__); } - if ((empty(self::$sourcedir) || !is_dir(realpath(self::$sourcedir))) && is_dir(self::$boarddir . '/Sources')) { + if ((empty(self::$sourcedir) || !is_dir((string) realpath(self::$sourcedir))) && is_dir(self::$boarddir . '/Sources')) { self::$sourcedir = self::$boarddir . '/Sources'; } - if ((empty(self::$vendordir) || !is_dir(realpath(self::$vendordir))) && is_dir(self::$boarddir . '/vendor')) { + if ((empty(self::$vendordir) || !is_dir((string) realpath(self::$vendordir))) && is_dir(self::$boarddir . '/vendor')) { self::$vendordir = self::$boarddir . '/vendor'; } - if ((empty(self::$packagesdir) || !is_dir(realpath(self::$packagesdir))) && is_dir(self::$boarddir . '/Packages')) { + if ((empty(self::$packagesdir) || !is_dir((string) realpath(self::$packagesdir))) && is_dir(self::$boarddir . '/Packages')) { self::$packagesdir = self::$boarddir . '/Packages'; } - if ((empty(self::$languagesdir) || !is_dir(realpath(self::$languagesdir))) && is_dir(self::$boarddir . '/Languages')) { + if ((empty(self::$languagesdir) || !is_dir((string) realpath(self::$languagesdir))) && is_dir(self::$boarddir . '/Languages')) { self::$languagesdir = self::$boarddir . '/Languages'; } diff --git a/Sources/Db/APIs/MySQL.php b/Sources/Db/APIs/MySQL.php index 9356391cb8..8c4f4dea08 100644 --- a/Sources/Db/APIs/MySQL.php +++ b/Sources/Db/APIs/MySQL.php @@ -938,19 +938,29 @@ public function backup_table(string $table, string $backup_table): object|bool ], ); - // If this failed, we go old school. if ($result) { + $columns = []; + + // Do we have any generated columns to deal with? + foreach ($this->list_columns($table, true) as $column) { + // Skip generated columns in the insert statement. + if (empty($column['generation_expression'])) { + $columns[] = $column['name']; + } + } + $request = $this->query( 'INSERT INTO {raw:backup_table} - SELECT * + ({raw:columns}) + SELECT {raw:columns} FROM {raw:table}', [ 'backup_table' => $backup_table, 'table' => $table, + 'columns' => implode(', ', $columns), ], ); - // Old school or no school? if ($request) { return $request; } @@ -1047,6 +1057,13 @@ public function backup_table(string $table, string $backup_table): object|bool ); } + // Restore the generation expressions on any generated columns. + foreach ($this->list_columns($table, true) as $column) { + if (!empty($column['generation_expression'])) { + $this->change_column($backup_table, $column['name'], $column); + } + } + return $request; } @@ -1373,7 +1390,7 @@ public function add_column(string $table_name, array $column_info, array $parame $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; // Now add the thing! - $this->query( + $result = $this->query( 'ALTER TABLE ' . $short_table_name . ' ADD ' . $this->create_query_column($column_info) . (empty($column_info['auto']) ? '' : ' primary key'), [ @@ -1381,7 +1398,7 @@ public function add_column(string $table_name, array $column_info, array $parame ], ); - return true; + return $result !== false; } /** @@ -1913,7 +1930,7 @@ public function create_table(string $table_name, array $columns, array $indexes } // Create the table! - $this->query( + $result = $this->query( $table_query, [ 'security_override' => true, @@ -1954,7 +1971,7 @@ public function create_table(string $table_name, array $columns, array $indexes $this->drop_table($short_table_name . '_old'); } - return true; + return $result !== false; } /** @@ -1980,15 +1997,14 @@ public function drop_table(string $table_name, array $parameters = [], string $e $tables = $this->list_tables($database); if (\in_array($full_table_name, $tables)) { - $query = 'DROP TABLE ' . $short_table_name; - $this->query( - $query, + $result = $this->query( + 'DROP TABLE ' . $short_table_name, [ 'security_override' => true, ], ); - return true; + return $result !== false; } // Otherwise do 'nout. @@ -2032,14 +2048,14 @@ public function rename_table(string $old_name, string $new_name, bool $allowed_r return false; } - $this->query( + $result = $this->query( 'ALTER TABLE ' . $short_old_name . ' RENAME ' . $short_new_name, [ 'security_override' => true, ], ); - return true; + return $result !== false; } /** @@ -2088,14 +2104,12 @@ public function list_columns(string $table_name, bool $detail = false, array $pa $database = !empty($match[2]) ? $match[2] : $this->name; $result = $this->query( - 'SELECT column_name "Field", COLUMN_TYPE "Type", is_nullable "Null", COLUMN_KEY "Key" , column_default "Default", extra "Extra", generation_expression "generation_expression" - FROM information_schema.columns - WHERE table_name = {string:table_name} - AND table_schema = {string:db_name} - ORDER BY ordinal_position', + 'SHOW COLUMNS + FROM {identifier:table_name} + IN {identifier:db}', [ + 'db' => strtr($database, ['`' => '']), 'table_name' => $real_table_name, - 'db_name' => $this->name, ], ); $columns = []; @@ -2109,8 +2123,7 @@ public function list_columns(string $table_name, bool $detail = false, array $pa // Can we split out the size? if (preg_match('~^(.+?)\s*\((\d+)\)$~', $row['Type'], $matches)) { - $type = $matches[1]; - $size = $matches[2]; + [$type, $size] = $this->calculate_type($matches[1], (int) $matches[2], true); } elseif (preg_match('~^(.+?)\s+unsigned$~', $row['Type'], $matches)) { $type = $matches[1]; $size = null; @@ -2135,12 +2148,32 @@ public function list_columns(string $table_name, bool $detail = false, array $pa unset($unsigned); } + // If this is a generated column, look up its generation expression. if (str_contains($row['Extra'], 'GENERATED')) { - $columns[$row['Field']]['generation_expression'] = $row['generation_expression']; + $result2 = $this->query( + 'SELECT generation_expression + FROM information_schema.columns + WHERE column_name = {string:field} + AND table_name = {string:table_name} + AND table_schema = {string:db}', + [ + 'db' => strtr($database, ['`' => '']), + 'table_name' => $real_table_name, + 'field' => $row['Field'], + ], + ); + + [$generation_expression] = $this->fetch_row($result2); + + $this->free_result($result2); + + $columns[$row['Field']]['generation_expression'] = $this->unescape_string($generation_expression); + $columns[$row['Field']]['stored'] = str_contains($row['Extra'], 'STORED'); } } } + $this->free_result($result); return $columns; @@ -2215,7 +2248,7 @@ public function remove_column(string $table_name, string $column_name, array $pa foreach ($columns as $column) { if ($column['name'] == $column_name) { - $this->query( + $result = $this->query( 'ALTER TABLE ' . $short_table_name . ' DROP COLUMN ' . $column_name, [ @@ -2223,7 +2256,7 @@ public function remove_column(string $table_name, string $column_name, array $pa ], ); - return true; + return $result !== false; } } @@ -2245,7 +2278,7 @@ public function remove_index(string $table_name, string $index_name, array $para // If the name is primary we want the primary key! if ($index['type'] == 'primary' && $index_name == 'primary') { // Dropping primary key? - $this->query( + $result = $this->query( 'ALTER TABLE ' . $short_table_name . ' DROP PRIMARY KEY', [ @@ -2253,12 +2286,12 @@ public function remove_index(string $table_name, string $index_name, array $para ], ); - return true; + return $result !== false; } if ($index['name'] == $index_name) { // Drop the bugger... - $this->query( + $result = $this->query( 'ALTER TABLE ' . $short_table_name . ' DROP INDEX ' . $index_name, [ @@ -2266,7 +2299,7 @@ public function remove_index(string $table_name, string $index_name, array $para ], ); - return true; + return $result !== false; } } @@ -2399,11 +2432,11 @@ public function setSqlMode(string $mode = 'default'): bool $sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT'; } - $this->query('SET SESSION sql_mode = {string:sql_mode}', [ + $result = $this->query('SET SESSION sql_mode = {string:sql_mode}', [ 'sql_mode' => $sql_mode, ]); - return true; + return $result !== false; } /** diff --git a/Sources/Db/APIs/PostgreSQL.php b/Sources/Db/APIs/PostgreSQL.php index 9dc4b497d2..744245fc68 100644 --- a/Sources/Db/APIs/PostgreSQL.php +++ b/Sources/Db/APIs/PostgreSQL.php @@ -1314,7 +1314,7 @@ public function add_column(string $table_name, array $column_info, array $parame } // Now add the thing! - $this->query( + $result = $this->query( 'ALTER TABLE ' . $short_table_name . ' ADD COLUMN ' . $column_info['name'] . ' ' . $type . $generated, [ @@ -1334,7 +1334,7 @@ public function add_column(string $table_name, array $column_info, array $parame return $this->change_column($table_name, $column_info['name'], $column_info); } - return true; + return $result !== false; } /** @@ -1876,7 +1876,7 @@ public function create_table(string $table_name, array $columns, array $indexes $table_query .= ')'; // Create the table! - $this->query( + $result = $this->query( $table_query, [ 'security_override' => true, @@ -1931,7 +1931,7 @@ public function create_table(string $table_name, array $columns, array $indexes $this->drop_table($table_name . '_old'); } - return true; + return $result !== false; } /** @@ -1966,7 +1966,7 @@ public function drop_table(string $table_name, array $parameters = [], string $e $sequence_query = 'DROP SEQUENCE IF EXISTS ' . $short_table_name . '_seq'; // drop them - $this->query( + $result = $this->query( $table_query, [ 'security_override' => true, @@ -1981,7 +1981,7 @@ public function drop_table(string $table_name, array $parameters = [], string $e $this->transaction('commit'); - return true; + return $result !== false; } // Otherwise do 'nout. @@ -2025,14 +2025,14 @@ public function rename_table(string $old_name, string $new_name, bool $allowed_r return false; } - $this->query( + $result = $this->query( 'ALTER TABLE ' . $short_old_name . ' RENAME TO ' . $short_new_name, [ 'security_override' => true, ], ); - return true; + return $result !== false; } /** @@ -2198,7 +2198,7 @@ public function remove_column(string $table_name, string $column_name, array $pa ); } - $this->query( + $result = $this->query( 'ALTER TABLE ' . $short_table_name . ' DROP COLUMN ' . $column_name, [ @@ -2206,7 +2206,7 @@ public function remove_column(string $table_name, string $column_name, array $pa ], ); - return true; + return $result !== false; } } @@ -2234,7 +2234,7 @@ public function remove_index(string $table_name, string $index_name, array $para // If the name is primary we want the primary key! if ($index['type'] == 'primary' && $index_name == 'primary') { // Dropping primary key? - $this->query( + $result = $this->query( 'ALTER TABLE ' . $real_table_name . ' DROP CONSTRAINT ' . $index['name'], [ @@ -2242,19 +2242,19 @@ public function remove_index(string $table_name, string $index_name, array $para ], ); - return true; + return $result !== false; } if ($index['name'] == $index_name) { // Drop the bugger... - $this->query( + $result = $this->query( 'DROP INDEX ' . $real_table_name . '_' . $index_name, [ 'security_override' => true, ], ); - return true; + return $result !== false; } } diff --git a/Sources/Db/Schema/Column.php b/Sources/Db/Schema/Column.php index 63539d6f2c..f5210c1cc9 100644 --- a/Sources/Db/Schema/Column.php +++ b/Sources/Db/Schema/Column.php @@ -91,8 +91,6 @@ class Column * @var bool * * Set this to true to drop the default during an ALTER TABLE operation. - * - * This is not set by __construct(). It can be set afterward. */ public bool $drop_default = false; @@ -116,6 +114,8 @@ class Column * Only applicable to integer columns. * @param ?string $charset The character set for string data. * Only applicable to string types. If null, will be set automatically. + * @param bool $drop_default Whether to drop the column's default during + * ALTER TABLE operations. Default: false. */ public function __construct( string $name, @@ -126,6 +126,7 @@ public function __construct( string|float|int|bool|null $default = null, ?bool $auto = null, ?string $charset = null, + bool $drop_default = false, ) { $this->name = strtolower($name); $this->type = strtolower($type); @@ -134,7 +135,7 @@ public function __construct( $this->default = $default === 'NULL' ? null : $default; } - foreach (['auto', 'size', 'unsigned', 'not_null'] as $var) { + foreach (['auto', 'size', 'unsigned', 'not_null', 'drop_default'] as $var) { if (isset($var)) { $this->{$var} = ${$var}; } diff --git a/Sources/Db/Schema/Table.php b/Sources/Db/Schema/Table.php index 7bd0239212..c91e3e8322 100644 --- a/Sources/Db/Schema/Table.php +++ b/Sources/Db/Schema/Table.php @@ -22,7 +22,7 @@ /** * Represents a database table. */ -class Table +abstract class Table { /******************* * Public properties @@ -61,7 +61,20 @@ class Table * * The default character set for the table. */ - public ?string $default_charset; + public ?string $default_charset { + get { + // As of SMF 3.0, all tables always use four-byte UTF-8. + if ( + !isset($this->default_charset) + && preg_match('/\\\\v(\d+_\d+)\\\\/', $this::class, $matches) + && version_compare(strtr($matches[1], '_', '.'), '3.0', '>=') + ) { + $this->default_charset = Db::$db->title === MYSQL_TITLE ? 'utf8mb4' : 'utf8'; + } + + return $this->default_charset ?? null; + } + } /** * @var int @@ -76,22 +89,34 @@ class Table */ public ?int $auto_start; + /**************************** + * Internal static properties + ****************************/ + + /** + * @var array + * + * Cached output of Db::$db->list_tables + */ + protected static array $existing_tables = []; + /**************** * Public methods ****************/ /** - * Constructor. + * Checks whether a table with this name exists in the database. + * + * @param bool $force_refresh If true, force a refresh of the tables list. + * @return bool Whether this table exists. */ - public function __construct() + public function exists(bool $force_refresh = false) { - // As of SMF 3.0, all tables always use four-byte UTF-8. - if ( - preg_match('/\\\\v(\d+_\d+)\\\\/', $this::class, $matches) - && version_compare(strtr($matches[1], '_', '.'), '3.0', '>=') - ) { - $this->default_charset = Db::$db->title === MYSQL_TITLE ? 'utf8mb4' : 'utf8'; + if ($force_refresh || empty(self::$existing_tables)) { + self::$existing_tables = Db::$db->list_tables(); } + + return \in_array(Db::$db->prefix . $this->name, self::$existing_tables); } /** @@ -106,7 +131,7 @@ public function normalize(): bool return false; } - if (empty(Db::$db->list_tables(false, Db::$db->prefix . $this->name))) { + if (!$this->exists()) { return $this->create(); } @@ -287,13 +312,20 @@ public function create(array $parameters = [], string $if_exists = 'ignore'): bo return false; } - return Db::$db->create_table( + $success = Db::$db->create_table( '{db_prefix}' . $this->name, array_map('get_object_vars', array_values($this->columns)), array_map('get_object_vars', array_values($this->indexes)), $parameters, $if_exists, ); + + if ($success) { + // Force a refresh of the list of tables. + self::$existing_tables = []; + } + + return $success; } /** @@ -305,7 +337,14 @@ public function create(array $parameters = [], string $if_exists = 'ignore'): bo */ public function drop(): bool { - return Db::$db->drop_table('{db_prefix}' . $this->name); + $success = Db::$db->drop_table('{db_prefix}' . $this->name); + + if ($success) { + // Force a refresh of the list of tables. + self::$existing_tables = []; + } + + return $success; } /** @@ -636,23 +675,21 @@ final public static function find(string $table_name, string $schema_version): ? } /** - * Gets all known table schemas. + * Gets database initializer queries for the indicated SMF version. * + * @param string $schema_version E.g. 'v3_0'. * @return array All known table schemas. */ - final public static function getInitializers(string $schema_version, string $title): array + final public static function getInitializers(string $schema_version): array { - if (file_exists(__DIR__ . '/' . $schema_version . '/Initialize/' . $title . '.php')) { + if (file_exists(__DIR__ . '/' . $schema_version . '/Initialize/' . Db::$db->title . '.php')) { - $fully_qualified_class_name = __NAMESPACE__ . '\\' . $schema_version . '\\Initialize\\' . $title; + $fully_qualified_class_name = __NAMESPACE__ . '\\' . $schema_version . '\\Initialize\\' . Db::$db->title; if (!class_exists($fully_qualified_class_name)) { return []; } - /** - * @var \SMF\Db\Schema\v3_0\Initialize\Base - */ $intializer = new $fully_qualified_class_name(Db::$db->get_version()); return $intializer->getAll(); diff --git a/Sources/Db/Schema/v2_1/AdminInfoFiles.php b/Sources/Db/Schema/v2_1/AdminInfoFiles.php index 54b5910c86..2ae4e0f864 100644 --- a/Sources/Db/Schema/v2_1/AdminInfoFiles.php +++ b/Sources/Db/Schema/v2_1/AdminInfoFiles.php @@ -142,7 +142,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/ApprovalQueue.php b/Sources/Db/Schema/v2_1/ApprovalQueue.php index b3cf37c02c..21c1eb8650 100644 --- a/Sources/Db/Schema/v2_1/ApprovalQueue.php +++ b/Sources/Db/Schema/v2_1/ApprovalQueue.php @@ -57,7 +57,5 @@ public function __construct() default: 0, ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Attachments.php b/Sources/Db/Schema/v2_1/Attachments.php index 1cbdb673dc..ec42f9e84d 100644 --- a/Sources/Db/Schema/v2_1/Attachments.php +++ b/Sources/Db/Schema/v2_1/Attachments.php @@ -187,7 +187,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/BackgroundTasks.php b/Sources/Db/Schema/v2_1/BackgroundTasks.php index 635ca8fe55..34d3c1b860 100644 --- a/Sources/Db/Schema/v2_1/BackgroundTasks.php +++ b/Sources/Db/Schema/v2_1/BackgroundTasks.php @@ -81,7 +81,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/BanGroups.php b/Sources/Db/Schema/v2_1/BanGroups.php index c9aec8cb9c..9f2d29b409 100644 --- a/Sources/Db/Schema/v2_1/BanGroups.php +++ b/Sources/Db/Schema/v2_1/BanGroups.php @@ -61,6 +61,9 @@ public function __construct() name: 'expire_time', type: 'int', unsigned: true, + not_null: false, + default: null, + drop_default: true, ), 'cannot_access' => new Column( name: 'cannot_access', @@ -114,7 +117,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/BanItems.php b/Sources/Db/Schema/v2_1/BanItems.php index 364d727ce4..7636b3e0be 100644 --- a/Sources/Db/Schema/v2_1/BanItems.php +++ b/Sources/Db/Schema/v2_1/BanItems.php @@ -119,7 +119,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/BoardPermissions.php b/Sources/Db/Schema/v2_1/BoardPermissions.php index af42240baf..c2c3a6ae95 100644 --- a/Sources/Db/Schema/v2_1/BoardPermissions.php +++ b/Sources/Db/Schema/v2_1/BoardPermissions.php @@ -1629,7 +1629,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/BoardPermissionsView.php b/Sources/Db/Schema/v2_1/BoardPermissionsView.php index ac7f52e3a6..dfe7a72bf9 100644 --- a/Sources/Db/Schema/v2_1/BoardPermissionsView.php +++ b/Sources/Db/Schema/v2_1/BoardPermissionsView.php @@ -98,7 +98,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Boards.php b/Sources/Db/Schema/v2_1/Boards.php index a30a89601d..f0559dc875 100644 --- a/Sources/Db/Schema/v2_1/Boards.php +++ b/Sources/Db/Schema/v2_1/Boards.php @@ -244,7 +244,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Calendar.php b/Sources/Db/Schema/v2_1/Calendar.php index a7e827271c..21cb82f243 100644 --- a/Sources/Db/Schema/v2_1/Calendar.php +++ b/Sources/Db/Schema/v2_1/Calendar.php @@ -142,7 +142,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/CalendarHolidays.php b/Sources/Db/Schema/v2_1/CalendarHolidays.php index 07d96e820c..9b5c9f425f 100644 --- a/Sources/Db/Schema/v2_1/CalendarHolidays.php +++ b/Sources/Db/Schema/v2_1/CalendarHolidays.php @@ -900,7 +900,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Categories.php b/Sources/Db/Schema/v2_1/Categories.php index e8d98f3497..3ddd0b53cc 100644 --- a/Sources/Db/Schema/v2_1/Categories.php +++ b/Sources/Db/Schema/v2_1/Categories.php @@ -98,7 +98,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/CustomFields.php b/Sources/Db/Schema/v2_1/CustomFields.php index ccac78a5d9..4ef639294f 100644 --- a/Sources/Db/Schema/v2_1/CustomFields.php +++ b/Sources/Db/Schema/v2_1/CustomFields.php @@ -278,7 +278,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/GroupModerators.php b/Sources/Db/Schema/v2_1/GroupModerators.php index 086b8a4885..80cfe89ab1 100644 --- a/Sources/Db/Schema/v2_1/GroupModerators.php +++ b/Sources/Db/Schema/v2_1/GroupModerators.php @@ -63,7 +63,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogActions.php b/Sources/Db/Schema/v2_1/LogActions.php index ff9f22a980..3a8cd455b5 100644 --- a/Sources/Db/Schema/v2_1/LogActions.php +++ b/Sources/Db/Schema/v2_1/LogActions.php @@ -165,7 +165,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogActivity.php b/Sources/Db/Schema/v2_1/LogActivity.php index 4a492a8ce6..efc1bd978f 100644 --- a/Sources/Db/Schema/v2_1/LogActivity.php +++ b/Sources/Db/Schema/v2_1/LogActivity.php @@ -88,7 +88,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogBanned.php b/Sources/Db/Schema/v2_1/LogBanned.php index f6fb686eed..d3b8d52a7e 100644 --- a/Sources/Db/Schema/v2_1/LogBanned.php +++ b/Sources/Db/Schema/v2_1/LogBanned.php @@ -89,7 +89,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogBoards.php b/Sources/Db/Schema/v2_1/LogBoards.php index 16a2f0fcc6..308c4ad153 100644 --- a/Sources/Db/Schema/v2_1/LogBoards.php +++ b/Sources/Db/Schema/v2_1/LogBoards.php @@ -70,7 +70,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogComments.php b/Sources/Db/Schema/v2_1/LogComments.php index 32e4acc89b..2aaabebd00 100644 --- a/Sources/Db/Schema/v2_1/LogComments.php +++ b/Sources/Db/Schema/v2_1/LogComments.php @@ -140,7 +140,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogDigest.php b/Sources/Db/Schema/v2_1/LogDigest.php index 0426c63b6c..399c406d43 100644 --- a/Sources/Db/Schema/v2_1/LogDigest.php +++ b/Sources/Db/Schema/v2_1/LogDigest.php @@ -71,7 +71,5 @@ public function __construct() default: 0, ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogErrors.php b/Sources/Db/Schema/v2_1/LogErrors.php index fedebb7206..b08c4f03b5 100644 --- a/Sources/Db/Schema/v2_1/LogErrors.php +++ b/Sources/Db/Schema/v2_1/LogErrors.php @@ -143,7 +143,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogFloodcontrol.php b/Sources/Db/Schema/v2_1/LogFloodcontrol.php index d9e4eba42d..96dac986a4 100644 --- a/Sources/Db/Schema/v2_1/LogFloodcontrol.php +++ b/Sources/Db/Schema/v2_1/LogFloodcontrol.php @@ -69,7 +69,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogGroupRequests.php b/Sources/Db/Schema/v2_1/LogGroupRequests.php index d96f4e337f..78d28df28f 100644 --- a/Sources/Db/Schema/v2_1/LogGroupRequests.php +++ b/Sources/Db/Schema/v2_1/LogGroupRequests.php @@ -125,7 +125,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogMarkRead.php b/Sources/Db/Schema/v2_1/LogMarkRead.php index 4bab7c5d9e..221cd055f0 100644 --- a/Sources/Db/Schema/v2_1/LogMarkRead.php +++ b/Sources/Db/Schema/v2_1/LogMarkRead.php @@ -70,7 +70,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogMemberNotices.php b/Sources/Db/Schema/v2_1/LogMemberNotices.php index 6095c5646e..d78cb68a8d 100644 --- a/Sources/Db/Schema/v2_1/LogMemberNotices.php +++ b/Sources/Db/Schema/v2_1/LogMemberNotices.php @@ -67,7 +67,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogNotify.php b/Sources/Db/Schema/v2_1/LogNotify.php index 74242bc0ed..6b78b5fa47 100644 --- a/Sources/Db/Schema/v2_1/LogNotify.php +++ b/Sources/Db/Schema/v2_1/LogNotify.php @@ -98,7 +98,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogOnline.php b/Sources/Db/Schema/v2_1/LogOnline.php index 999a16a521..28cccb258d 100644 --- a/Sources/Db/Schema/v2_1/LogOnline.php +++ b/Sources/Db/Schema/v2_1/LogOnline.php @@ -102,7 +102,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogPackages.php b/Sources/Db/Schema/v2_1/LogPackages.php index 7b9d7ced46..feb14eb4f6 100644 --- a/Sources/Db/Schema/v2_1/LogPackages.php +++ b/Sources/Db/Schema/v2_1/LogPackages.php @@ -162,7 +162,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogPolls.php b/Sources/Db/Schema/v2_1/LogPolls.php index 453171779a..ea4484e6cf 100644 --- a/Sources/Db/Schema/v2_1/LogPolls.php +++ b/Sources/Db/Schema/v2_1/LogPolls.php @@ -75,7 +75,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogReported.php b/Sources/Db/Schema/v2_1/LogReported.php index bae750ab45..809e7b50b3 100644 --- a/Sources/Db/Schema/v2_1/LogReported.php +++ b/Sources/Db/Schema/v2_1/LogReported.php @@ -172,7 +172,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogReportedComments.php b/Sources/Db/Schema/v2_1/LogReportedComments.php index e37bc14b91..04537b4818 100644 --- a/Sources/Db/Schema/v2_1/LogReportedComments.php +++ b/Sources/Db/Schema/v2_1/LogReportedComments.php @@ -114,7 +114,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogScheduledTasks.php b/Sources/Db/Schema/v2_1/LogScheduledTasks.php index 1bc46d901c..da222782bd 100644 --- a/Sources/Db/Schema/v2_1/LogScheduledTasks.php +++ b/Sources/Db/Schema/v2_1/LogScheduledTasks.php @@ -72,7 +72,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogSearchMessages.php b/Sources/Db/Schema/v2_1/LogSearchMessages.php index 1683514bf3..8bd2e6ab08 100644 --- a/Sources/Db/Schema/v2_1/LogSearchMessages.php +++ b/Sources/Db/Schema/v2_1/LogSearchMessages.php @@ -63,7 +63,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogSearchResults.php b/Sources/Db/Schema/v2_1/LogSearchResults.php index 7fa047b63f..3d6d945678 100644 --- a/Sources/Db/Schema/v2_1/LogSearchResults.php +++ b/Sources/Db/Schema/v2_1/LogSearchResults.php @@ -87,7 +87,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogSearchSubjects.php b/Sources/Db/Schema/v2_1/LogSearchSubjects.php index 85b4b03787..60e79ae1a6 100644 --- a/Sources/Db/Schema/v2_1/LogSearchSubjects.php +++ b/Sources/Db/Schema/v2_1/LogSearchSubjects.php @@ -71,7 +71,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogSearchTopics.php b/Sources/Db/Schema/v2_1/LogSearchTopics.php index 04a768eecd..345edb0639 100644 --- a/Sources/Db/Schema/v2_1/LogSearchTopics.php +++ b/Sources/Db/Schema/v2_1/LogSearchTopics.php @@ -63,7 +63,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogSpiderHits.php b/Sources/Db/Schema/v2_1/LogSpiderHits.php index d3c57c98d2..75125a971f 100644 --- a/Sources/Db/Schema/v2_1/LogSpiderHits.php +++ b/Sources/Db/Schema/v2_1/LogSpiderHits.php @@ -106,7 +106,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogSpiderStats.php b/Sources/Db/Schema/v2_1/LogSpiderStats.php index 67c2c54f3a..964de3450d 100644 --- a/Sources/Db/Schema/v2_1/LogSpiderStats.php +++ b/Sources/Db/Schema/v2_1/LogSpiderStats.php @@ -75,7 +75,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogSubscribed.php b/Sources/Db/Schema/v2_1/LogSubscribed.php index 00606af7a5..812917512a 100644 --- a/Sources/Db/Schema/v2_1/LogSubscribed.php +++ b/Sources/Db/Schema/v2_1/LogSubscribed.php @@ -168,7 +168,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/LogTopics.php b/Sources/Db/Schema/v2_1/LogTopics.php index 15b088f21a..8a7fa84c0f 100644 --- a/Sources/Db/Schema/v2_1/LogTopics.php +++ b/Sources/Db/Schema/v2_1/LogTopics.php @@ -84,7 +84,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/MailQueue.php b/Sources/Db/Schema/v2_1/MailQueue.php index 6751fb879e..35cb3e409c 100644 --- a/Sources/Db/Schema/v2_1/MailQueue.php +++ b/Sources/Db/Schema/v2_1/MailQueue.php @@ -122,7 +122,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/MemberLogins.php b/Sources/Db/Schema/v2_1/MemberLogins.php index 448bedf8cf..4c1f04785d 100644 --- a/Sources/Db/Schema/v2_1/MemberLogins.php +++ b/Sources/Db/Schema/v2_1/MemberLogins.php @@ -92,7 +92,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Membergroups.php b/Sources/Db/Schema/v2_1/Membergroups.php index 908af6d2c3..d42ce72e8e 100644 --- a/Sources/Db/Schema/v2_1/Membergroups.php +++ b/Sources/Db/Schema/v2_1/Membergroups.php @@ -210,7 +210,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Members.php b/Sources/Db/Schema/v2_1/Members.php index 7f1c3572c8..1b2c6948e7 100644 --- a/Sources/Db/Schema/v2_1/Members.php +++ b/Sources/Db/Schema/v2_1/Members.php @@ -514,7 +514,5 @@ public function __construct() ], ); } - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Mentions.php b/Sources/Db/Schema/v2_1/Mentions.php index cf0ecf647b..1d3ac97085 100644 --- a/Sources/Db/Schema/v2_1/Mentions.php +++ b/Sources/Db/Schema/v2_1/Mentions.php @@ -102,7 +102,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/MessageIcons.php b/Sources/Db/Schema/v2_1/MessageIcons.php index 2a96064170..bbc8280691 100644 --- a/Sources/Db/Schema/v2_1/MessageIcons.php +++ b/Sources/Db/Schema/v2_1/MessageIcons.php @@ -168,7 +168,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Messages.php b/Sources/Db/Schema/v2_1/Messages.php index 2e6ed12f43..289c205374 100644 --- a/Sources/Db/Schema/v2_1/Messages.php +++ b/Sources/Db/Schema/v2_1/Messages.php @@ -306,7 +306,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/ModeratorGroups.php b/Sources/Db/Schema/v2_1/ModeratorGroups.php index bb2cb04a7a..0b48096a5e 100644 --- a/Sources/Db/Schema/v2_1/ModeratorGroups.php +++ b/Sources/Db/Schema/v2_1/ModeratorGroups.php @@ -63,7 +63,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Moderators.php b/Sources/Db/Schema/v2_1/Moderators.php index 6f68363df5..ea10b8a00b 100644 --- a/Sources/Db/Schema/v2_1/Moderators.php +++ b/Sources/Db/Schema/v2_1/Moderators.php @@ -63,7 +63,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/PackageServers.php b/Sources/Db/Schema/v2_1/PackageServers.php index da62ed09e7..1af5508281 100644 --- a/Sources/Db/Schema/v2_1/PackageServers.php +++ b/Sources/Db/Schema/v2_1/PackageServers.php @@ -102,7 +102,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/PermissionProfiles.php b/Sources/Db/Schema/v2_1/PermissionProfiles.php index 78080e1bf4..c17d950ff5 100644 --- a/Sources/Db/Schema/v2_1/PermissionProfiles.php +++ b/Sources/Db/Schema/v2_1/PermissionProfiles.php @@ -89,7 +89,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Permissions.php b/Sources/Db/Schema/v2_1/Permissions.php index 789f9ab8f8..08f0f961d7 100644 --- a/Sources/Db/Schema/v2_1/Permissions.php +++ b/Sources/Db/Schema/v2_1/Permissions.php @@ -284,7 +284,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/PersonalMessages.php b/Sources/Db/Schema/v2_1/PersonalMessages.php index 5da9e6248c..75a2c484e4 100644 --- a/Sources/Db/Schema/v2_1/PersonalMessages.php +++ b/Sources/Db/Schema/v2_1/PersonalMessages.php @@ -129,7 +129,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/PmLabeledMessages.php b/Sources/Db/Schema/v2_1/PmLabeledMessages.php index ce302fc216..d3092e229b 100644 --- a/Sources/Db/Schema/v2_1/PmLabeledMessages.php +++ b/Sources/Db/Schema/v2_1/PmLabeledMessages.php @@ -63,7 +63,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/PmLabels.php b/Sources/Db/Schema/v2_1/PmLabels.php index 6a2b9fdd90..47475c5c86 100644 --- a/Sources/Db/Schema/v2_1/PmLabels.php +++ b/Sources/Db/Schema/v2_1/PmLabels.php @@ -69,7 +69,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/PmRecipients.php b/Sources/Db/Schema/v2_1/PmRecipients.php index 011cb258fe..2490c52db7 100644 --- a/Sources/Db/Schema/v2_1/PmRecipients.php +++ b/Sources/Db/Schema/v2_1/PmRecipients.php @@ -112,7 +112,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/PmRules.php b/Sources/Db/Schema/v2_1/PmRules.php index 61994d16ad..de53f625ae 100644 --- a/Sources/Db/Schema/v2_1/PmRules.php +++ b/Sources/Db/Schema/v2_1/PmRules.php @@ -108,7 +108,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/PollChoices.php b/Sources/Db/Schema/v2_1/PollChoices.php index 36f314dafc..bcdcd951e6 100644 --- a/Sources/Db/Schema/v2_1/PollChoices.php +++ b/Sources/Db/Schema/v2_1/PollChoices.php @@ -77,7 +77,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Polls.php b/Sources/Db/Schema/v2_1/Polls.php index 1271cfe6a6..80c155077b 100644 --- a/Sources/Db/Schema/v2_1/Polls.php +++ b/Sources/Db/Schema/v2_1/Polls.php @@ -131,7 +131,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Qanda.php b/Sources/Db/Schema/v2_1/Qanda.php index 3864d43fe0..bddb6c1563 100644 --- a/Sources/Db/Schema/v2_1/Qanda.php +++ b/Sources/Db/Schema/v2_1/Qanda.php @@ -83,7 +83,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/ScheduledTasks.php b/Sources/Db/Schema/v2_1/ScheduledTasks.php index 317dd41e02..0d67d89aee 100644 --- a/Sources/Db/Schema/v2_1/ScheduledTasks.php +++ b/Sources/Db/Schema/v2_1/ScheduledTasks.php @@ -247,7 +247,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Sessions.php b/Sources/Db/Schema/v2_1/Sessions.php index 9d087af6f7..bd141cf681 100644 --- a/Sources/Db/Schema/v2_1/Sessions.php +++ b/Sources/Db/Schema/v2_1/Sessions.php @@ -67,7 +67,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Settings.php b/Sources/Db/Schema/v2_1/Settings.php index ae650e5f75..fc25eee96e 100644 --- a/Sources/Db/Schema/v2_1/Settings.php +++ b/Sources/Db/Schema/v2_1/Settings.php @@ -888,9 +888,5 @@ public function __construct() ], ), ]; - - parent::__construct(); - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/SmileyFiles.php b/Sources/Db/Schema/v2_1/SmileyFiles.php index e4cd600496..c78a1c9dad 100644 --- a/Sources/Db/Schema/v2_1/SmileyFiles.php +++ b/Sources/Db/Schema/v2_1/SmileyFiles.php @@ -71,7 +71,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Smileys.php b/Sources/Db/Schema/v2_1/Smileys.php index b1da505ae3..138331eaef 100644 --- a/Sources/Db/Schema/v2_1/Smileys.php +++ b/Sources/Db/Schema/v2_1/Smileys.php @@ -234,7 +234,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Spiders.php b/Sources/Db/Schema/v2_1/Spiders.php index 95f1ab2f1f..e56c0683be 100644 --- a/Sources/Db/Schema/v2_1/Spiders.php +++ b/Sources/Db/Schema/v2_1/Spiders.php @@ -198,7 +198,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Subscriptions.php b/Sources/Db/Schema/v2_1/Subscriptions.php index 451678630b..6ed5a51bf9 100644 --- a/Sources/Db/Schema/v2_1/Subscriptions.php +++ b/Sources/Db/Schema/v2_1/Subscriptions.php @@ -131,7 +131,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Themes.php b/Sources/Db/Schema/v2_1/Themes.php index 7fa4cf45bb..9f5ed168b8 100644 --- a/Sources/Db/Schema/v2_1/Themes.php +++ b/Sources/Db/Schema/v2_1/Themes.php @@ -170,7 +170,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/Topics.php b/Sources/Db/Schema/v2_1/Topics.php index 7472a5cc9f..3129dd822b 100644 --- a/Sources/Db/Schema/v2_1/Topics.php +++ b/Sources/Db/Schema/v2_1/Topics.php @@ -269,7 +269,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/UserAlerts.php b/Sources/Db/Schema/v2_1/UserAlerts.php index eb7843586f..ede222962c 100644 --- a/Sources/Db/Schema/v2_1/UserAlerts.php +++ b/Sources/Db/Schema/v2_1/UserAlerts.php @@ -132,7 +132,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/UserAlertsPrefs.php b/Sources/Db/Schema/v2_1/UserAlertsPrefs.php index 02f632dfd9..73cdab9a67 100644 --- a/Sources/Db/Schema/v2_1/UserAlertsPrefs.php +++ b/Sources/Db/Schema/v2_1/UserAlertsPrefs.php @@ -226,7 +226,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/UserDrafts.php b/Sources/Db/Schema/v2_1/UserDrafts.php index ed155b228e..6ce19d96ce 100644 --- a/Sources/Db/Schema/v2_1/UserDrafts.php +++ b/Sources/Db/Schema/v2_1/UserDrafts.php @@ -155,7 +155,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v2_1/UserLikes.php b/Sources/Db/Schema/v2_1/UserLikes.php index 7aa0cc676e..e693698a01 100644 --- a/Sources/Db/Schema/v2_1/UserLikes.php +++ b/Sources/Db/Schema/v2_1/UserLikes.php @@ -98,7 +98,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/AdminInfoFiles.php b/Sources/Db/Schema/v3_0/AdminInfoFiles.php index 238643326e..204f07c870 100644 --- a/Sources/Db/Schema/v3_0/AdminInfoFiles.php +++ b/Sources/Db/Schema/v3_0/AdminInfoFiles.php @@ -142,7 +142,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/ApprovalQueue.php b/Sources/Db/Schema/v3_0/ApprovalQueue.php index 9443facdeb..8ae3404324 100644 --- a/Sources/Db/Schema/v3_0/ApprovalQueue.php +++ b/Sources/Db/Schema/v3_0/ApprovalQueue.php @@ -57,7 +57,5 @@ public function __construct() default: 0, ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Attachments.php b/Sources/Db/Schema/v3_0/Attachments.php index 0ce9d2c263..da9d498bd0 100644 --- a/Sources/Db/Schema/v3_0/Attachments.php +++ b/Sources/Db/Schema/v3_0/Attachments.php @@ -187,7 +187,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/BackgroundTasks.php b/Sources/Db/Schema/v3_0/BackgroundTasks.php index efdca3f210..4b07f655b1 100644 --- a/Sources/Db/Schema/v3_0/BackgroundTasks.php +++ b/Sources/Db/Schema/v3_0/BackgroundTasks.php @@ -81,7 +81,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/BanGroups.php b/Sources/Db/Schema/v3_0/BanGroups.php index 221135416a..e043169946 100644 --- a/Sources/Db/Schema/v3_0/BanGroups.php +++ b/Sources/Db/Schema/v3_0/BanGroups.php @@ -63,6 +63,7 @@ public function __construct() unsigned: true, not_null: false, default: null, + drop_default: true, ), 'cannot_access' => new Column( name: 'cannot_access', @@ -116,7 +117,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/BanItems.php b/Sources/Db/Schema/v3_0/BanItems.php index 9139af5056..733c7960e8 100644 --- a/Sources/Db/Schema/v3_0/BanItems.php +++ b/Sources/Db/Schema/v3_0/BanItems.php @@ -119,7 +119,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/BoardPermissions.php b/Sources/Db/Schema/v3_0/BoardPermissions.php index 0bc1b076a9..6cfa3a85b8 100644 --- a/Sources/Db/Schema/v3_0/BoardPermissions.php +++ b/Sources/Db/Schema/v3_0/BoardPermissions.php @@ -1632,7 +1632,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/BoardPermissionsView.php b/Sources/Db/Schema/v3_0/BoardPermissionsView.php index 66b9d4b42f..f05aadd018 100644 --- a/Sources/Db/Schema/v3_0/BoardPermissionsView.php +++ b/Sources/Db/Schema/v3_0/BoardPermissionsView.php @@ -98,7 +98,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Boards.php b/Sources/Db/Schema/v3_0/Boards.php index ee3eb54d40..136fbab854 100644 --- a/Sources/Db/Schema/v3_0/Boards.php +++ b/Sources/Db/Schema/v3_0/Boards.php @@ -244,7 +244,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Calendar.php b/Sources/Db/Schema/v3_0/Calendar.php index f0af14ee2e..2ce6fe81f8 100644 --- a/Sources/Db/Schema/v3_0/Calendar.php +++ b/Sources/Db/Schema/v3_0/Calendar.php @@ -593,7 +593,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Categories.php b/Sources/Db/Schema/v3_0/Categories.php index 4058603d2b..be2555becd 100644 --- a/Sources/Db/Schema/v3_0/Categories.php +++ b/Sources/Db/Schema/v3_0/Categories.php @@ -99,7 +99,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/CustomFields.php b/Sources/Db/Schema/v3_0/CustomFields.php index eaefdf307a..febd5f8a8c 100644 --- a/Sources/Db/Schema/v3_0/CustomFields.php +++ b/Sources/Db/Schema/v3_0/CustomFields.php @@ -278,7 +278,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/GroupModerators.php b/Sources/Db/Schema/v3_0/GroupModerators.php index ae1a87dc94..c0aac55929 100644 --- a/Sources/Db/Schema/v3_0/GroupModerators.php +++ b/Sources/Db/Schema/v3_0/GroupModerators.php @@ -65,7 +65,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Initialize/Base.php b/Sources/Db/Schema/v3_0/Initialize/Base.php index 498b91235d..94cc1aed0a 100644 --- a/Sources/Db/Schema/v3_0/Initialize/Base.php +++ b/Sources/Db/Schema/v3_0/Initialize/Base.php @@ -31,21 +31,41 @@ class Base * Public methods ****************/ - public function __construct(?string $version) + /** + * Constructor. + * + * @param string $version Version of the database engine. + */ + public function __construct(string $version) { $this->version = $version; } + /** + * Gets queries that create custom SQL functions and operators. + * + * @return array SQL queries. + */ public function getAll(): array { return $this->functions() + $this->operators(); } + /** + * Gets queries that create custom SQL functions. + * + * @return array SQL queries. + */ public function functions(): array { return []; } + /** + * Gets queries that create custom SQL operators. + * + * @return array SQL queries. + */ public function operators(): array { return []; diff --git a/Sources/Db/Schema/v3_0/LogActions.php b/Sources/Db/Schema/v3_0/LogActions.php index 416c399eb8..3a2b4d2943 100644 --- a/Sources/Db/Schema/v3_0/LogActions.php +++ b/Sources/Db/Schema/v3_0/LogActions.php @@ -165,7 +165,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogActivity.php b/Sources/Db/Schema/v3_0/LogActivity.php index 6d121e4c46..a2f9693e2d 100644 --- a/Sources/Db/Schema/v3_0/LogActivity.php +++ b/Sources/Db/Schema/v3_0/LogActivity.php @@ -88,7 +88,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogBanned.php b/Sources/Db/Schema/v3_0/LogBanned.php index 0e0d7aa4dc..4772142d46 100644 --- a/Sources/Db/Schema/v3_0/LogBanned.php +++ b/Sources/Db/Schema/v3_0/LogBanned.php @@ -89,7 +89,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogBoards.php b/Sources/Db/Schema/v3_0/LogBoards.php index 79942402cb..a6b5f0ca43 100644 --- a/Sources/Db/Schema/v3_0/LogBoards.php +++ b/Sources/Db/Schema/v3_0/LogBoards.php @@ -72,7 +72,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogComments.php b/Sources/Db/Schema/v3_0/LogComments.php index f7d2d8f401..fb84d13e9b 100644 --- a/Sources/Db/Schema/v3_0/LogComments.php +++ b/Sources/Db/Schema/v3_0/LogComments.php @@ -140,7 +140,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogDigest.php b/Sources/Db/Schema/v3_0/LogDigest.php index 9489926197..654fd78647 100644 --- a/Sources/Db/Schema/v3_0/LogDigest.php +++ b/Sources/Db/Schema/v3_0/LogDigest.php @@ -71,7 +71,5 @@ public function __construct() default: 0, ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogErrors.php b/Sources/Db/Schema/v3_0/LogErrors.php index bd8d2c7779..c36f06dd7a 100644 --- a/Sources/Db/Schema/v3_0/LogErrors.php +++ b/Sources/Db/Schema/v3_0/LogErrors.php @@ -141,7 +141,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogFloodcontrol.php b/Sources/Db/Schema/v3_0/LogFloodcontrol.php index 4d4c05bcee..f770dfe05a 100644 --- a/Sources/Db/Schema/v3_0/LogFloodcontrol.php +++ b/Sources/Db/Schema/v3_0/LogFloodcontrol.php @@ -71,7 +71,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogGroupRequests.php b/Sources/Db/Schema/v3_0/LogGroupRequests.php index 889963caed..c592571a03 100644 --- a/Sources/Db/Schema/v3_0/LogGroupRequests.php +++ b/Sources/Db/Schema/v3_0/LogGroupRequests.php @@ -132,7 +132,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogMarkRead.php b/Sources/Db/Schema/v3_0/LogMarkRead.php index 7f9e498c06..ee6ceb8b1a 100644 --- a/Sources/Db/Schema/v3_0/LogMarkRead.php +++ b/Sources/Db/Schema/v3_0/LogMarkRead.php @@ -72,7 +72,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogMemberNotices.php b/Sources/Db/Schema/v3_0/LogMemberNotices.php index 3631f61d88..6c61bf5b4d 100644 --- a/Sources/Db/Schema/v3_0/LogMemberNotices.php +++ b/Sources/Db/Schema/v3_0/LogMemberNotices.php @@ -67,7 +67,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogNotify.php b/Sources/Db/Schema/v3_0/LogNotify.php index fce6b1f2e4..23373ae5f1 100644 --- a/Sources/Db/Schema/v3_0/LogNotify.php +++ b/Sources/Db/Schema/v3_0/LogNotify.php @@ -101,7 +101,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogOnline.php b/Sources/Db/Schema/v3_0/LogOnline.php index 2fbe34210a..d28d018d62 100644 --- a/Sources/Db/Schema/v3_0/LogOnline.php +++ b/Sources/Db/Schema/v3_0/LogOnline.php @@ -103,7 +103,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogPackages.php b/Sources/Db/Schema/v3_0/LogPackages.php index 3725188dc1..b8e9e9c7b6 100644 --- a/Sources/Db/Schema/v3_0/LogPackages.php +++ b/Sources/Db/Schema/v3_0/LogPackages.php @@ -182,7 +182,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogPolls.php b/Sources/Db/Schema/v3_0/LogPolls.php index 439d2b6d41..dfe6d70f7b 100644 --- a/Sources/Db/Schema/v3_0/LogPolls.php +++ b/Sources/Db/Schema/v3_0/LogPolls.php @@ -75,7 +75,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogReported.php b/Sources/Db/Schema/v3_0/LogReported.php index 97409d59cc..d623d092f7 100644 --- a/Sources/Db/Schema/v3_0/LogReported.php +++ b/Sources/Db/Schema/v3_0/LogReported.php @@ -172,7 +172,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogReportedComments.php b/Sources/Db/Schema/v3_0/LogReportedComments.php index 4ff9cc925d..3139f0d5b3 100644 --- a/Sources/Db/Schema/v3_0/LogReportedComments.php +++ b/Sources/Db/Schema/v3_0/LogReportedComments.php @@ -114,7 +114,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogScheduledTasks.php b/Sources/Db/Schema/v3_0/LogScheduledTasks.php index cfe871b95e..502e70a1a2 100644 --- a/Sources/Db/Schema/v3_0/LogScheduledTasks.php +++ b/Sources/Db/Schema/v3_0/LogScheduledTasks.php @@ -72,7 +72,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogSearchMessages.php b/Sources/Db/Schema/v3_0/LogSearchMessages.php index a276eded7a..762dc5b571 100644 --- a/Sources/Db/Schema/v3_0/LogSearchMessages.php +++ b/Sources/Db/Schema/v3_0/LogSearchMessages.php @@ -65,7 +65,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogSearchResults.php b/Sources/Db/Schema/v3_0/LogSearchResults.php index ffa380d8c4..db2a3d2ed4 100644 --- a/Sources/Db/Schema/v3_0/LogSearchResults.php +++ b/Sources/Db/Schema/v3_0/LogSearchResults.php @@ -89,7 +89,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogSearchSubjects.php b/Sources/Db/Schema/v3_0/LogSearchSubjects.php index 6e82688886..0cb1416ed1 100644 --- a/Sources/Db/Schema/v3_0/LogSearchSubjects.php +++ b/Sources/Db/Schema/v3_0/LogSearchSubjects.php @@ -73,7 +73,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogSearchTopics.php b/Sources/Db/Schema/v3_0/LogSearchTopics.php index 7284a2892a..5686bcc8eb 100644 --- a/Sources/Db/Schema/v3_0/LogSearchTopics.php +++ b/Sources/Db/Schema/v3_0/LogSearchTopics.php @@ -65,7 +65,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogSpiderHits.php b/Sources/Db/Schema/v3_0/LogSpiderHits.php index 0533b5479a..41192ee289 100644 --- a/Sources/Db/Schema/v3_0/LogSpiderHits.php +++ b/Sources/Db/Schema/v3_0/LogSpiderHits.php @@ -90,7 +90,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogSpiderStats.php b/Sources/Db/Schema/v3_0/LogSpiderStats.php index 9e31aaa7a8..d2464ae665 100644 --- a/Sources/Db/Schema/v3_0/LogSpiderStats.php +++ b/Sources/Db/Schema/v3_0/LogSpiderStats.php @@ -77,7 +77,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogSubscribed.php b/Sources/Db/Schema/v3_0/LogSubscribed.php index 31da2bde37..4bcb192df2 100644 --- a/Sources/Db/Schema/v3_0/LogSubscribed.php +++ b/Sources/Db/Schema/v3_0/LogSubscribed.php @@ -156,7 +156,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/LogTopics.php b/Sources/Db/Schema/v3_0/LogTopics.php index 8b5fb6580f..cc898a6a3f 100644 --- a/Sources/Db/Schema/v3_0/LogTopics.php +++ b/Sources/Db/Schema/v3_0/LogTopics.php @@ -86,7 +86,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/MailQueue.php b/Sources/Db/Schema/v3_0/MailQueue.php index bd455e1d9a..f2c218c348 100644 --- a/Sources/Db/Schema/v3_0/MailQueue.php +++ b/Sources/Db/Schema/v3_0/MailQueue.php @@ -141,7 +141,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/MemberLogins.php b/Sources/Db/Schema/v3_0/MemberLogins.php index 8574710aa1..f0d61a04c8 100644 --- a/Sources/Db/Schema/v3_0/MemberLogins.php +++ b/Sources/Db/Schema/v3_0/MemberLogins.php @@ -92,7 +92,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Membergroups.php b/Sources/Db/Schema/v3_0/Membergroups.php index 247e01c4fe..2dc5c195f1 100644 --- a/Sources/Db/Schema/v3_0/Membergroups.php +++ b/Sources/Db/Schema/v3_0/Membergroups.php @@ -210,7 +210,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Members.php b/Sources/Db/Schema/v3_0/Members.php index 1c581787f6..9e3e2674c5 100644 --- a/Sources/Db/Schema/v3_0/Members.php +++ b/Sources/Db/Schema/v3_0/Members.php @@ -542,7 +542,5 @@ public function __construct() ], ); } - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Mentions.php b/Sources/Db/Schema/v3_0/Mentions.php index 6712e7bb23..bc9ac69f27 100644 --- a/Sources/Db/Schema/v3_0/Mentions.php +++ b/Sources/Db/Schema/v3_0/Mentions.php @@ -102,7 +102,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/MessageIcons.php b/Sources/Db/Schema/v3_0/MessageIcons.php index af769018f9..9e477b6e43 100644 --- a/Sources/Db/Schema/v3_0/MessageIcons.php +++ b/Sources/Db/Schema/v3_0/MessageIcons.php @@ -168,7 +168,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Messages.php b/Sources/Db/Schema/v3_0/Messages.php index fb0519ac28..4ffa60043a 100644 --- a/Sources/Db/Schema/v3_0/Messages.php +++ b/Sources/Db/Schema/v3_0/Messages.php @@ -320,7 +320,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/ModeratorGroups.php b/Sources/Db/Schema/v3_0/ModeratorGroups.php index 82a9c2902b..77205911d5 100644 --- a/Sources/Db/Schema/v3_0/ModeratorGroups.php +++ b/Sources/Db/Schema/v3_0/ModeratorGroups.php @@ -65,7 +65,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Moderators.php b/Sources/Db/Schema/v3_0/Moderators.php index 25dd7141d6..24535a275a 100644 --- a/Sources/Db/Schema/v3_0/Moderators.php +++ b/Sources/Db/Schema/v3_0/Moderators.php @@ -63,7 +63,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/PackageServers.php b/Sources/Db/Schema/v3_0/PackageServers.php index 227e0c6c09..a6f5d17001 100644 --- a/Sources/Db/Schema/v3_0/PackageServers.php +++ b/Sources/Db/Schema/v3_0/PackageServers.php @@ -102,7 +102,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/PermissionProfiles.php b/Sources/Db/Schema/v3_0/PermissionProfiles.php index 20c51cf4fc..c38e3810c9 100644 --- a/Sources/Db/Schema/v3_0/PermissionProfiles.php +++ b/Sources/Db/Schema/v3_0/PermissionProfiles.php @@ -89,7 +89,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Permissions.php b/Sources/Db/Schema/v3_0/Permissions.php index 3842f48000..12f440b052 100644 --- a/Sources/Db/Schema/v3_0/Permissions.php +++ b/Sources/Db/Schema/v3_0/Permissions.php @@ -278,7 +278,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/PersonalMessages.php b/Sources/Db/Schema/v3_0/PersonalMessages.php index ab4983a079..6353eb2c01 100644 --- a/Sources/Db/Schema/v3_0/PersonalMessages.php +++ b/Sources/Db/Schema/v3_0/PersonalMessages.php @@ -136,7 +136,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/PmLabeledMessages.php b/Sources/Db/Schema/v3_0/PmLabeledMessages.php index 7dc8d2a1e9..0da586f0e1 100644 --- a/Sources/Db/Schema/v3_0/PmLabeledMessages.php +++ b/Sources/Db/Schema/v3_0/PmLabeledMessages.php @@ -65,7 +65,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/PmLabels.php b/Sources/Db/Schema/v3_0/PmLabels.php index f20e4107e6..dd5929aaee 100644 --- a/Sources/Db/Schema/v3_0/PmLabels.php +++ b/Sources/Db/Schema/v3_0/PmLabels.php @@ -69,7 +69,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/PmRecipients.php b/Sources/Db/Schema/v3_0/PmRecipients.php index 94568ae0bf..74ad5947c1 100644 --- a/Sources/Db/Schema/v3_0/PmRecipients.php +++ b/Sources/Db/Schema/v3_0/PmRecipients.php @@ -115,7 +115,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/PmRules.php b/Sources/Db/Schema/v3_0/PmRules.php index 1556ed77eb..6310d6af89 100644 --- a/Sources/Db/Schema/v3_0/PmRules.php +++ b/Sources/Db/Schema/v3_0/PmRules.php @@ -108,7 +108,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/PollChoices.php b/Sources/Db/Schema/v3_0/PollChoices.php index d91a48f59a..cd4ec9f36a 100644 --- a/Sources/Db/Schema/v3_0/PollChoices.php +++ b/Sources/Db/Schema/v3_0/PollChoices.php @@ -79,7 +79,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Polls.php b/Sources/Db/Schema/v3_0/Polls.php index 62e325b3a8..15fe43979b 100644 --- a/Sources/Db/Schema/v3_0/Polls.php +++ b/Sources/Db/Schema/v3_0/Polls.php @@ -132,7 +132,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Qanda.php b/Sources/Db/Schema/v3_0/Qanda.php index 6de1a883a7..579c4912a5 100644 --- a/Sources/Db/Schema/v3_0/Qanda.php +++ b/Sources/Db/Schema/v3_0/Qanda.php @@ -83,7 +83,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/ScheduledTasks.php b/Sources/Db/Schema/v3_0/ScheduledTasks.php index 0a590e642b..d8012af83f 100644 --- a/Sources/Db/Schema/v3_0/ScheduledTasks.php +++ b/Sources/Db/Schema/v3_0/ScheduledTasks.php @@ -247,7 +247,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Sessions.php b/Sources/Db/Schema/v3_0/Sessions.php index c69cf0ca6d..9082dee99b 100644 --- a/Sources/Db/Schema/v3_0/Sessions.php +++ b/Sources/Db/Schema/v3_0/Sessions.php @@ -67,7 +67,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Settings.php b/Sources/Db/Schema/v3_0/Settings.php index c117a02ced..96d78a4835 100644 --- a/Sources/Db/Schema/v3_0/Settings.php +++ b/Sources/Db/Schema/v3_0/Settings.php @@ -893,7 +893,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/SmileyFiles.php b/Sources/Db/Schema/v3_0/SmileyFiles.php index d9a989b74a..d370915cf3 100644 --- a/Sources/Db/Schema/v3_0/SmileyFiles.php +++ b/Sources/Db/Schema/v3_0/SmileyFiles.php @@ -303,7 +303,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Smileys.php b/Sources/Db/Schema/v3_0/Smileys.php index a3ef276d46..8d4e222ce4 100644 --- a/Sources/Db/Schema/v3_0/Smileys.php +++ b/Sources/Db/Schema/v3_0/Smileys.php @@ -278,7 +278,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Spiders.php b/Sources/Db/Schema/v3_0/Spiders.php index f39abd760b..2e2498b7a4 100644 --- a/Sources/Db/Schema/v3_0/Spiders.php +++ b/Sources/Db/Schema/v3_0/Spiders.php @@ -198,7 +198,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Subscriptions.php b/Sources/Db/Schema/v3_0/Subscriptions.php index 38dac28db3..5d70c27547 100644 --- a/Sources/Db/Schema/v3_0/Subscriptions.php +++ b/Sources/Db/Schema/v3_0/Subscriptions.php @@ -131,7 +131,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Themes.php b/Sources/Db/Schema/v3_0/Themes.php index 7f479afe11..bfbf8bb7e5 100644 --- a/Sources/Db/Schema/v3_0/Themes.php +++ b/Sources/Db/Schema/v3_0/Themes.php @@ -150,7 +150,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/Topics.php b/Sources/Db/Schema/v3_0/Topics.php index cc0588310a..c174fdb013 100644 --- a/Sources/Db/Schema/v3_0/Topics.php +++ b/Sources/Db/Schema/v3_0/Topics.php @@ -269,7 +269,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/UserAlerts.php b/Sources/Db/Schema/v3_0/UserAlerts.php index 80e5dc358a..169f11d477 100644 --- a/Sources/Db/Schema/v3_0/UserAlerts.php +++ b/Sources/Db/Schema/v3_0/UserAlerts.php @@ -132,7 +132,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/UserAlertsPrefs.php b/Sources/Db/Schema/v3_0/UserAlertsPrefs.php index 39217ce40f..55cc55f49a 100644 --- a/Sources/Db/Schema/v3_0/UserAlertsPrefs.php +++ b/Sources/Db/Schema/v3_0/UserAlertsPrefs.php @@ -228,7 +228,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/UserDrafts.php b/Sources/Db/Schema/v3_0/UserDrafts.php index 52ac28dd99..9f72b50f41 100644 --- a/Sources/Db/Schema/v3_0/UserDrafts.php +++ b/Sources/Db/Schema/v3_0/UserDrafts.php @@ -155,7 +155,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Db/Schema/v3_0/UserLikes.php b/Sources/Db/Schema/v3_0/UserLikes.php index 6fbd37d72c..a49cb9ebc8 100644 --- a/Sources/Db/Schema/v3_0/UserLikes.php +++ b/Sources/Db/Schema/v3_0/UserLikes.php @@ -101,7 +101,5 @@ public function __construct() ], ), ]; - - parent::__construct(); } } diff --git a/Sources/Maintenance/Cleanup/CleanupBase.php b/Sources/Maintenance/Cleanup/CleanupBase.php index 4f37911097..7bdce49640 100644 --- a/Sources/Maintenance/Cleanup/CleanupBase.php +++ b/Sources/Maintenance/Cleanup/CleanupBase.php @@ -38,9 +38,7 @@ abstract class CleanupBase implements SubStepInterface ****************/ /** - * Check if the task should be performed or not. * - * @return bool True if this task needs to be run, false otherwise. */ public function isCandidate(): bool { diff --git a/Sources/Maintenance/Cleanup/v3_0/OldFiles.php b/Sources/Maintenance/Cleanup/OldFilesBase.php similarity index 91% rename from Sources/Maintenance/Cleanup/v3_0/OldFiles.php rename to Sources/Maintenance/Cleanup/OldFilesBase.php index 1f04f87e28..7d376fea78 100644 --- a/Sources/Maintenance/Cleanup/v3_0/OldFiles.php +++ b/Sources/Maintenance/Cleanup/OldFilesBase.php @@ -13,13 +13,16 @@ declare(strict_types=1); -namespace SMF\Maintenance\Cleanup\v3_0; +namespace SMF\Maintenance\Cleanup; use SMF\Config; -use SMF\Maintenance\Cleanup\CleanupBase; use SMF\Utils; -class OldFiles extends CleanupBase +/** + * Base class for cleanup tasks that delete files that have been removed in a + * new version of SMF. + */ +abstract class OldFilesBase extends CleanupBase { /******************* * Public properties @@ -37,7 +40,7 @@ class OldFiles extends CleanupBase /** * @var array * - * List of files removed in SMF 3.0. + * List of files removed in the relevant version of SMF. */ protected array $removed = [ // Files in the Themes directory. @@ -57,9 +60,7 @@ class OldFiles extends CleanupBase ****************/ /** - * Check if the task should be performed or not. * - * @return bool True if this task needs to be run, false otherwise. */ public function isCandidate(): bool { diff --git a/Sources/Maintenance/Cleanup/v2_1/OldFiles.php b/Sources/Maintenance/Cleanup/v2_1/OldFiles.php index e69755f663..7b0717e342 100644 --- a/Sources/Maintenance/Cleanup/v2_1/OldFiles.php +++ b/Sources/Maintenance/Cleanup/v2_1/OldFiles.php @@ -15,10 +15,10 @@ namespace SMF\Maintenance\Cleanup\v2_1; -use SMF\Maintenance\Cleanup\v3_0\OldFiles as OldFilesBase; +use SMF\Maintenance\Cleanup\OldFilesBase; /** - * Just like the v3_0 version of OldFiles, but with a different list of files. + * Deletes files that were present in SMF 2.0 but not in SMF 2.1. */ class OldFiles extends OldFilesBase { diff --git a/Sources/Maintenance/Cleanup/v3_0/TasksDirCase.php b/Sources/Maintenance/Cleanup/v3_0/TasksDirCase.php index 6bf62068a1..140713af43 100644 --- a/Sources/Maintenance/Cleanup/v3_0/TasksDirCase.php +++ b/Sources/Maintenance/Cleanup/v3_0/TasksDirCase.php @@ -35,9 +35,7 @@ class TasksDirCase extends CleanupBase ****************/ /** - * Check if the task should be performed or not. * - * @return bool True if this task needs to be run, false otherwise. */ public function isCandidate(): bool { diff --git a/Sources/Maintenance/Maintenance.php b/Sources/Maintenance/Maintenance.php index 2043f29264..5c9997a639 100644 --- a/Sources/Maintenance/Maintenance.php +++ b/Sources/Maintenance/Maintenance.php @@ -228,7 +228,7 @@ class Maintenance public function __construct() { Security::frameOptionsHeader('SAMEORIGIN'); - self::$theme_dir = \dirname(SMF_SETTINGS_FILE) . '/Themes/default'; + self::$theme_dir = self::getBaseDir() . '/Themes/default'; // This might be overwritten by the tool, but we need a default value. self::$context['started'] = (int) TIME_START; @@ -744,12 +744,17 @@ public static function loginWithDatabasePassword( */ public static function getTimeElapsed(): string { - // How long have we been running this? - $elapsed = time() - (int) self::$context['started']; - $mins = (int) ($elapsed / 60); - $seconds = $elapsed - $mins * 60; + $duration = (new \DateTime('@' . self::$context['started']))->diff(new \DateTime()); - return Lang::getTxt('maintenance_time_elasped_ms', ['m' => $mins, 's' => $seconds]); + if ((int) $duration->format('%a') > 0) { + return \strval((int) $duration->format('%h') + ((int) $duration->format('%a') * 24)) . $duration->format(':%I:%S'); + } + + if ((int) $duration->format('%h') > 0) { + return $duration->format('%h:%I:%S'); + } + + return $duration->format('%i:%S'); } /** diff --git a/Sources/Maintenance/Migration/v2_1/AgreementUpdate.php b/Sources/Maintenance/Migration/v2_1/AgreementUpdate.php index adf662aaac..eaae86caec 100644 --- a/Sources/Maintenance/Migration/v2_1/AgreementUpdate.php +++ b/Sources/Maintenance/Migration/v2_1/AgreementUpdate.php @@ -110,7 +110,7 @@ public function execute(): bool $this->handleTimeout($start); $extras = []; - $request = Db::$db->query( + $request = $this->query( 'SELECT id_action, extra FROM {db_prefix}log_actions WHERE id_member = {int:blank_id} @@ -145,7 +145,7 @@ public function execute(): bool } if (!empty($extra['applicator'])) { - $request = Db::$db->query( + $request = $this->query( 'UPDATE {db_prefix}log_actions SET id_member = {int:id_member} WHERE id_action = {int:id_action}', diff --git a/Sources/Maintenance/Migration/v2_1/BoardPermissionsView.php b/Sources/Maintenance/Migration/v2_1/BoardPermissionsView.php index b77b509c14..04bec7f32b 100644 --- a/Sources/Maintenance/Migration/v2_1/BoardPermissionsView.php +++ b/Sources/Maintenance/Migration/v2_1/BoardPermissionsView.php @@ -15,7 +15,6 @@ namespace SMF\Maintenance\Migration\v2_1; -use SMF\Config; use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; use SMF\Maintenance\Maintenance; @@ -46,11 +45,7 @@ public function execute(): bool // Create table board_permissions_view if ($start <= 0) { $table = new Schema\v2_1\BoardPermissionsView(); - $existing_tables = Db::$db->list_tables(); - - if (!\in_array(Config::$db_prefix . $table->name, $existing_tables)) { - $table->create(); - } + $table->create(); $this->handleTimeout(++$start); } diff --git a/Sources/Maintenance/Migration/v2_1/CreateAlerts.php b/Sources/Maintenance/Migration/v2_1/CreateAlerts.php index cfe950fc98..5fab23bd87 100644 --- a/Sources/Maintenance/Migration/v2_1/CreateAlerts.php +++ b/Sources/Maintenance/Migration/v2_1/CreateAlerts.php @@ -60,15 +60,8 @@ public function execute(): bool $user_alert_table = new Schema\v2_1\UserAlerts(); $user_alert_prefs_table = new Schema\v2_1\UserAlertsPrefs(); - $tables = Db::$db->list_tables(); - - if (!\in_array($user_alert_table->name, $tables)) { - $user_alert_table->create(); - } - - if (!\in_array($user_alert_prefs_table->name, $tables)) { - $user_alert_prefs_table->create(); - } + $user_alert_table->create(); + $user_alert_prefs_table->create(); $existing_structure = $members_table->getCurrentStructure(); @@ -150,25 +143,10 @@ public function execute(): bool } while (Maintenance::getCurrentStart() < Maintenance::$total_items); } - if (\in_array('notify_send_body', $member_columns)) { - Db::$db->remove_column('{db_prefix}members', 'notify_send_body'); - $this->handleTimeout(); - } - - if (\in_array('notify_types', $member_columns)) { - Db::$db->remove_column('{db_prefix}members', 'notify_types'); - $this->handleTimeout(); - } - - if (\in_array('notify_regularity', $member_columns)) { - Db::$db->remove_column('{db_prefix}members', 'notify_regularity'); - $this->handleTimeout(); - } - - if (\in_array('notify_announcements', $member_columns)) { - Db::$db->remove_column('{db_prefix}members', 'notify_announcements'); - $this->handleTimeout(); - } + $members_table->dropColumn('notify_send_body'); + $members_table->dropColumn('notify_types'); + $members_table->dropColumn('notify_regularity'); + $members_table->dropColumn('notify_announcements'); return true; } diff --git a/Sources/Maintenance/Migration/v2_1/CreateBackgroundTasks.php b/Sources/Maintenance/Migration/v2_1/CreateBackgroundTasks.php index 6f4d5c0dde..f0bdc1b205 100644 --- a/Sources/Maintenance/Migration/v2_1/CreateBackgroundTasks.php +++ b/Sources/Maintenance/Migration/v2_1/CreateBackgroundTasks.php @@ -15,8 +15,6 @@ namespace SMF\Maintenance\Migration\v2_1; -use SMF\Config; -use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; use SMF\Maintenance\Migration\MigrationBase; @@ -41,12 +39,7 @@ class CreateBackgroundTasks extends MigrationBase public function execute(): bool { $background_tasks_table = new Schema\v2_1\BackgroundTasks(); - - $tables = Db::$db->list_tables(); - - if (!\in_array(Config::$db_prefix . $background_tasks_table->name, $tables)) { - $background_tasks_table->create(); - } + $background_tasks_table->create(); return true; } diff --git a/Sources/Maintenance/Migration/v2_1/CreateMemberLogins.php b/Sources/Maintenance/Migration/v2_1/CreateMemberLogins.php index 10a6ccae77..26a91fb77d 100644 --- a/Sources/Maintenance/Migration/v2_1/CreateMemberLogins.php +++ b/Sources/Maintenance/Migration/v2_1/CreateMemberLogins.php @@ -15,8 +15,6 @@ namespace SMF\Maintenance\Migration\v2_1; -use SMF\Config; -use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; use SMF\Maintenance\Migration\MigrationBase; @@ -40,12 +38,8 @@ class CreateMemberLogins extends MigrationBase */ public function execute(): bool { - $tables = Db::$db->list_tables(); - - if (!\in_array(Config::$db_prefix . 'member_logins', $tables)) { - $member_logins = new Schema\v2_1\MemberLogins(); - $member_logins->create(); - } + $member_logins = new Schema\v2_1\MemberLogins(); + $member_logins->create(); return true; } diff --git a/Sources/Maintenance/Migration/v2_1/FixDates.php b/Sources/Maintenance/Migration/v2_1/FixDates.php index 81e46379c6..3f9b22e7f7 100644 --- a/Sources/Maintenance/Migration/v2_1/FixDates.php +++ b/Sources/Maintenance/Migration/v2_1/FixDates.php @@ -19,6 +19,12 @@ use SMF\Maintenance\Maintenance; use SMF\Maintenance\Migration\MigrationBase; +/** + * @todo Find a SQL standard way of handling this. + * Maybe DATEADD with a calc on YEAR() to find what it takes to make it 1004? + * PostgreSQL does not have DATEFROMPARTS, but does have make_date (9.4>), + * which would be similar the more standard DATEFROMPARTS. + */ class FixDates extends MigrationBase { /******************* @@ -39,121 +45,61 @@ class FixDates extends MigrationBase */ public function execute(): bool { - // @@ TODO: Find a SQL standard way of handling this. Maybe DATEADD with a calc on YEAR() to find what it takes to make it 1004? - // PostgreSQL does not have DATEFROMPARTS, but does have make_date (9.4>), which would be similar the more standard DATEFROMPARTS. - - // PostgreSQL does the query a bit different. - $is_pgsql = Db::$db->title === POSTGRE_TITLE; - - if (Maintenance::getCurrentStart() < 1 && $is_pgsql) { - $this->query( - 'UPDATE {db_prefix}calendar - SET start_date = concat_ws({literal:-}, CASE WHEN EXTRACT(YEAR FROM start_date) < 1004 THEN 1004 END, EXTRACT(MONTH FROM start_date), EXTRACT(DAY FROM start_date))::date - WHERE EXTRACT(YEAR FROM start_date) < 1004', - [], - ); - } elseif (Maintenance::getCurrentStart() < 1) { - $this->query( - 'UPDATE {db_prefix}calendar - SET start_date = DATE(CONCAT(1004, {literal:-}, MONTH(start_date), {literal:-}, DAY(start_date))) - WHERE YEAR(start_date) < 1004', - [], - ); + if (Db::$db->title === POSTGRE_TITLE) { + $boilerplate = 'UPDATE {db_prefix}%1$s + SET %2$s = concat_ws({literal:-}, CASE WHEN EXTRACT(YEAR FROM %2$s) < 1004 THEN 1004 END, EXTRACT(MONTH FROM %2$s), EXTRACT(DAY FROM %2$s))::date + WHERE EXTRACT(YEAR FROM %2$s) < 1004'; + + $bday_query = 'UPDATE {db_prefix}members + SET birthdate = concat_ws({literal:-}, CASE WHEN EXTRACT(YEAR FROM birthdate) < 1004 THEN 1004 END, CASE WHEN EXTRACT(MONTH FROM birthdate) < 1 THEN 1 ELSE EXTRACT(MONTH FROM birthdate) END, CASE WHEN EXTRACT(DAY FROM birthdate) < 1 THEN 1 ELSE EXTRACT(DAY FROM birthdate) END)::date + WHERE EXTRACT(YEAR FROM birthdate) < 1004 OR EXTRACT(MONTH FROM birthdate) < 1 OR EXTRACT(DAY FROM birthdate) < 1'; + + } else { + $boilerplate = 'UPDATE {db_prefix}%1$s + SET %2$s = DATE(CONCAT(1004, {literal:-}, MONTH(%2$s), {literal:-}, DAY(%2$s))) + WHERE YEAR(%2$s) < 1004'; + + $bday_query = 'UPDATE {db_prefix}members + SET birthdate = DATE(CONCAT(IF(YEAR(birthdate) < 1004, 1004, YEAR(birthdate)), {literal:-}, IF(MONTH(birthdate) < 1, 1, MONTH(birthdate)), {literal:-}, IF(DAY(birthdate) < 1, 1, DAY(birthdate)))) + WHERE YEAR(birthdate) < 1004 OR MONTH(birthdate) < 1 OR DAY(birthdate) < 1'; } - Maintenance::setCurrentStart(); - $this->handleTimeout(); - - if (Maintenance::getCurrentStart() < 2 && $is_pgsql) { - $this->query( - 'UPDATE {db_prefix}calendar - SET end_date = concat_ws({literal:-}, CASE WHEN EXTRACT(YEAR FROM end_date) < 1004 THEN 1004 END, EXTRACT(MONTH FROM end_date), EXTRACT(DAY FROM end_date))::date - WHERE EXTRACT(YEAR FROM end_date) < 1004', - [], - ); - } elseif (Maintenance::getCurrentStart() < 2) { - $this->query( - 'UPDATE {db_prefix}calendar - SET end_date = DATE(CONCAT(1004, {literal:-}, MONTH(end_date), {literal:-}, DAY(end_date))) - WHERE YEAR(end_date) < 1004', - [], - ); + + if (Maintenance::getCurrentStart() < 1) { + $this->query(\sprintf($boilerplate, 'calendar', 'start_date')); + + Maintenance::setCurrentStart(); + $this->handleTimeout(); } - Maintenance::setCurrentStart(); - $this->handleTimeout(); - - if (Maintenance::getCurrentStart() < 3 && $is_pgsql) { - $this->query( - 'UPDATE {db_prefix}calendar_holidays - SET event_date = concat_ws({literal:-}, CASE WHEN EXTRACT(YEAR FROM event_date) < 1004 THEN 1004 END, EXTRACT(MONTH FROM event_date), EXTRACT(DAY FROM event_date))::date - WHERE EXTRACT(YEAR FROM event_date) < 1004', - [], - ); - } elseif (Maintenance::getCurrentStart() < 3) { - $this->query( - 'UPDATE {db_prefix}calendar_holidays - SET event_date = DATE(CONCAT(1004, {literal:-}, MONTH(event_date), {literal:-}, DAY(event_date))) - WHERE YEAR(event_date) < 1004', - [], - ); + + if (Maintenance::getCurrentStart() < 2) { + $this->query(\sprintf($boilerplate, 'calendar', 'end_date')); + + Maintenance::setCurrentStart(); + $this->handleTimeout(); } - Maintenance::setCurrentStart(); - $this->handleTimeout(); - - if (Maintenance::getCurrentStart() < 4 && $is_pgsql) { - $this->query( - 'UPDATE {db_prefix}log_spider_stats - SET stat_date = concat_ws({literal:-}, CASE WHEN EXTRACT(YEAR FROM stat_date) < 1004 THEN 1004 END, EXTRACT(MONTH FROM stat_date), EXTRACT(DAY FROM stat_date))::date - WHERE EXTRACT(YEAR FROM stat_date) < 1004', - [], - ); - } elseif (Maintenance::getCurrentStart() < 4) { - $this->query( - 'UPDATE {db_prefix}log_spider_stats - SET stat_date = DATE(CONCAT(1004, {literal:-}, MONTH(stat_date), {literal:-}, DAY(stat_date))) - WHERE YEAR(stat_date) < 1004', - [], - ); + + if (Maintenance::getCurrentStart() < 3) { + $this->query(\sprintf($boilerplate, 'calendar_holidays', 'event_date')); + + Maintenance::setCurrentStart(); + $this->handleTimeout(); } - Maintenance::setCurrentStart(); - $this->handleTimeout(); - if (Maintenance::getCurrentStart() < 5 && $is_pgsql) { - $this->query( - 'UPDATE {db_prefix}log_spider_stats - SET birthdate = concat_ws({literal:-}, CASE WHEN EXTRACT(YEAR FROM birthdate) < 1004 THEN 1004 END, CASE WHEN EXTRACT(MONTH FROM birthdate) < 1 THEN 1 ELSE EXTRACT(MONTH FROM birthdate) END, CASE WHEN EXTRACT(DAY FROM birthdate) < 1 THEN 1 ELSE EXTRACT(DAY FROM birthdate) END)::date - WHERE EXTRACT(YEAR FROM birthdate) < 1004 OR EXTRACT(MONTH FROM birthdate) < 1 OR EXTRACT(DAY FROM birthdate) < 1', - [], - ); - } elseif (Maintenance::getCurrentStart() < 5) { - $this->query( - 'UPDATE {db_prefix}members - SET birthdate = DATE(CONCAT(IF(YEAR(birthdate) < 1004, 1004, YEAR(birthdate)), {literal:-}, IF(MONTH(birthdate) < 1, 1, MONTH(birthdate)), {literal:-}, IF(DAY(birthdate) < 1, 1, DAY(birthdate)))) - WHERE YEAR(birthdate) < 1004 OR MONTH(birthdate) < 1 OR DAY(birthdate) < 1', - [], - ); + if (Maintenance::getCurrentStart() < 4) { + $this->query(\sprintf($boilerplate, 'log_spider_stats', 'stat_date')); + + Maintenance::setCurrentStart(); + $this->handleTimeout(); } - Maintenance::setCurrentStart(); - $this->handleTimeout(); - if (Maintenance::getCurrentStart() < 6 && $is_pgsql) { - $this->query( - 'UPDATE {db_prefix}members - SET birthdate = concat_ws({literal:-}, CASE WHEN EXTRACT(YEAR FROM birthdate) < 1004 THEN 1004 END, CASE WHEN EXTRACT(MONTH FROM birthdate) < 1 THEN 1 ELSE EXTRACT(MONTH FROM birthdate) END, CASE WHEN EXTRACT(DAY FROM birthdate) < 1 THEN 1 ELSE EXTRACT(DAY FROM birthdate) END)::date - WHERE EXTRACT(YEAR FROM birthdate) < 1004 OR EXTRACT(MONTH FROM birthdate) < 1 OR EXTRACT(DAY FROM birthdate) < 1', - [], - ); - } elseif (Maintenance::getCurrentStart() < 6) { - $this->query( - 'UPDATE {db_prefix}members - SET birthdate = DATE(CONCAT(IF(YEAR(birthdate) < 1004, 1004, YEAR(birthdate)), {literal:-}, IF(MONTH(birthdate) < 1, 1, MONTH(birthdate)), {literal:-}, IF(DAY(birthdate) < 1, 1, DAY(birthdate)))) - WHERE YEAR(birthdate) < 1004 OR MONTH(birthdate) < 1 OR DAY(birthdate) < 1', - [], - ); + if (Maintenance::getCurrentStart() < 5) { + $this->query($bday_query); + + Maintenance::setCurrentStart(); + $this->handleTimeout(); } - Maintenance::setCurrentStart(); - $this->handleTimeout(); - if (Maintenance::getCurrentStart() < 7) { + if (Maintenance::getCurrentStart() < 6) { Db::$db->change_column( '{db_prefix}log_activity', 'DATE', @@ -162,22 +108,63 @@ public function execute(): bool 'default' => null, ], ); + + Maintenance::setCurrentStart(); + $this->handleTimeout(); + } + + if (Maintenance::getCurrentStart() < 7) { + Db::$db->change_column( + '{db_prefix}calendar', + 'start_date', + ['default' => '1004-01-01'], + ); + + Maintenance::setCurrentStart(); + $this->handleTimeout(); + } + + if (Maintenance::getCurrentStart() < 8) { + Db::$db->change_column( + '{db_prefix}calendar', + 'end_date', + ['default' => '1004-01-01'], + ); + + Maintenance::setCurrentStart(); + $this->handleTimeout(); + } + + if (Maintenance::getCurrentStart() < 9) { + Db::$db->change_column( + '{db_prefix}calendar_holidays', + 'event_date', + ['default' => '1004-01-01'], + ); + + Maintenance::setCurrentStart(); + $this->handleTimeout(); } - Maintenance::setCurrentStart(); - $this->handleTimeout(); - $fixes = [ - ['tbl' => '{db_prefix}calendar', 'col' => 'start_date'], - ['tbl' => '{db_prefix}calendar', 'col' => 'end_date'], - ['tbl' => '{db_prefix}calendar_holidays', 'col' => 'event_date'], - ['tbl' => '{db_prefix}log_spider_stats', 'col' => 'stat_date'], - ['tbl' => '{db_prefix}members', 'col' => 'birthdate'], - ]; + if (Maintenance::getCurrentStart() < 10) { + Db::$db->change_column( + '{db_prefix}log_spider_stats', + 'stat_date', + ['default' => '1004-01-01'], + ); + + Maintenance::setCurrentStart(); + $this->handleTimeout(); + } - for ($key = Maintenance::getCurrentStart(); $key < \count($fixes); Maintenance::setCurrentStart()) { - $fix = $fixes[$key - 7]; + if (Maintenance::getCurrentStart() < 11) { + Db::$db->change_column( + '{db_prefix}members', + 'stat_date', + ['birthdate' => '1004-01-01'], + ); - Db::$db->change_column($fix['tbl'], $fix['col'], ['default' => '1004-01-01']); + Maintenance::setCurrentStart(); $this->handleTimeout(); } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6BanItem.php b/Sources/Maintenance/Migration/v2_1/Ipv6BanItem.php index 20edf01d35..2d2201fc34 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6BanItem.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6BanItem.php @@ -22,6 +22,8 @@ class Ipv6BanItem extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -29,7 +31,7 @@ class Ipv6BanItem extends MigrationBase /** * */ - public string $name = 'Update ban ip with ipv6 support'; + public string $name = 'Updating ban_items table with IPv6 support'; /**************** * Public methods @@ -43,7 +45,16 @@ public function isCandidate(): bool $table = new Schema\v2_1\BanItems(); $existing_structure = $table->getCurrentStructure(); - return !isset($existing_structure['columns']['ip_low']) || !isset($existing_structure['columns']['ip_high']); + return ( + isset($existing_structure['columns']['ip_low1']) + || isset($existing_structure['columns']['ip_low2']) + || isset($existing_structure['columns']['ip_low3']) + || isset($existing_structure['columns']['ip_low4']) + || isset($existing_structure['columns']['ip_high1']) + || isset($existing_structure['columns']['ip_high2']) + || isset($existing_structure['columns']['ip_high3']) + || isset($existing_structure['columns']['ip_high4']) + ); } /** @@ -58,17 +69,12 @@ public function execute(): bool // Add columns to ban_items if ($start <= 0) { - foreach ($table->columns as $column) { - if ( - ( - $column->name === 'ip_low' - || $column->name === 'ip_high' - ) - && !isset($existing_structure['columns'][$column->name]) - ) { - $table->addColumn($column); - continue; - } + if (!isset($existing_structure['columns']['ip_low'])) { + $table->addColumn($table->columns['ip_low']); + } + + if (!isset($existing_structure['columns']['ip_high'])) { + $table->addColumn($table->columns['ip_high']); } $this->handleTimeout(++$start); @@ -80,48 +86,19 @@ public function execute(): bool if (Db::$db->title == POSTGRE_TITLE) { $this->query( 'UPDATE {db_prefix}ban_items - SET ip_low = (ip_low1||{literal:.}||ip_low2||{literal:.}||ip_low3||{literal:.}||ip_low4)::inet, + SET + ip_low = (ip_low1||{literal:.}||ip_low2||{literal:.}||ip_low3||{literal:.}||ip_low4)::inet, ip_high = (ip_high1||{literal:.}||ip_high2||{literal:.}||ip_high3||{literal:.}||ip_high4)::inet WHERE ip_low1 > 0', ); } else { - // Note, We now support MySQL 8+, which means we could use INET6_ATON. - // The upgrade logic was built this way and should remain the same. - // If changed, a full upgrade from 2.0 to 3.0 would need to be tested. - $this->quote( - 'UPDATE IGNORE {db_prefix}ban_items - SET ip_low = - UNHEX( - hex( - INET_ATON(concat(ip_low1,{literal:.},ip_low2,{literal:.},ip_low3,{literal:.},ip_low4)) - ) - ), - ip_high = - UNHEX( - hex( - INET_ATON(concat(ip_high1,{literal:.},ip_high2,{literal:.},ip_high3,{literal:.},ip_high4)) - ) - ) - WHERE ip_low1 > 0', - ); - $this->query( 'UPDATE IGNORE {db_prefix}ban_items - SET ip_low = - UNHEX( - hex( - INET_ATON(concat(ip_low1,{literal:.},ip_low2,{literal:.},ip_low3,{literal:.},ip_low4)) - ) - ), - ip_high = - UNHEX( - hex( - INET_ATON(concat(ip_high1,{literal:.},ip_high2,{literal:.},ip_high3,{literal:.},ip_high4)) - ) - ) + SET + ip_low = INET6_ATON(CONCAT_WS({literal:.}, ip_low1, ip_low2, ip_low3, ip_low4)), + ip_high = INET6_ATON(CONCAT_WS({literal:.}, ip_high1, ip_high2, ip_high3, ip_high4)) WHERE ip_low1 > 0', ); - } $this->handleTimeout(++$start); @@ -129,14 +106,8 @@ public function execute(): bool // Create new index on ban_items. if ($start <= 2) { - foreach ($table->indexes as $idx) { - if ( - $idx->name === 'idx_id_ban_ip' - && !isset($existing_structure['indexes'][$column->name]) - ) { - $table->addIndex($idx); - continue; - } + if (!isset($existing_structure['indexes']['idx_id_ban_ip'])) { + $table->addIndex($table->indexes['idx_id_ban_ip']); } $this->handleTimeout(++$start); @@ -144,16 +115,9 @@ public function execute(): bool // Dropping columns from ban_items if ($start <= 3) { - foreach ($table->columns as $column) { - if ( - ( - $column->name === 'ip_low1' || $column->name === 'ip_low2' || $column->name === 'ip_low3' || $column->name === 'ip_low4' - || $column->name === 'ip_high1' || $column->name === 'ip_high2' || $column->name === 'ip_high3' || $column->name === 'ip_high4' - ) - && !isset($existing_structure['columns'][$column->name]) - ) { - $table->dropColumn($column); - continue; + foreach (['ip_low1', 'ip_low2', 'ip_low3', 'ip_low4', 'ip_high1', 'ip_high2', 'ip_high3', 'ip_high4'] as $col_name) { + if (isset($existing_structure['columns'][$col_name])) { + $table->dropColumn($col_name); } } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6Base.php b/Sources/Maintenance/Migration/v2_1/Ipv6Base.php deleted file mode 100644 index 68ff0e508d..0000000000 --- a/Sources/Maintenance/Migration/v2_1/Ipv6Base.php +++ /dev/null @@ -1,343 +0,0 @@ -query( - ' - SELECT COUNT(DISTINCT {raw:col}) - FROM {db_prefix}{raw:table}', - [ - 'col' => $col . '_old', - 'table' => $table, - ], - ); - - // failed? We may have not renamed yet. - if ($request === false) { - $request = $this->query( - ' - SELECT COUNT(DISTINCT {raw:col}) - FROM {db_prefix}{raw:table}', - [ - 'col' => $col, - 'table' => $table, - ], - ); - } - - if ($request === false) { - return 0; - } - - list($items) = Db::$db->fetch_row($request); - - return (int) $items; - } - - public function convertData(string $targetTable, string $oldCol, string $newCol, int $limit = 50000, int $setSize = 100): bool - { - // mysql default max length is 1mb https://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html - $arIp = []; - - $request = $this->query( - ' - SELECT DISTINCT {raw:old_col} - FROM {db_prefix}{raw:table_name} - WHERE {raw:new_col} = {string:empty} - LIMIT {int:limit}', - [ - 'old_col' => $oldCol, - 'new_col' => $newCol, - 'table_name' => $targetTable, - 'empty' => '', - 'limit' => $limit, - ], - ); - - while ($row = Db::$db->fetch_assoc($request)) { - $arIp[] = $row[$oldCol]; - } - - Db::$db->free_result($request); - - if (empty($arIp)) { - return true; - } - - $updates = []; - $new_ips = []; - $cases = []; - $count = \count($arIp); - - for ($i = 0; $i < $count; $i++) { - $new_ip = trim($arIp[$i]); - - $new_ip = filter_var($new_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6); - - if ($new_ip === false) { - $new_ip = ''; - } - - $updates['ip' . $i] = $arIp[$i]; - $new_ips['newip' . $i] = $new_ip; - $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:newip' . $i . '}'; - - // Execute updates every $setSize & also when done with contents of $arIp - if ((($i + 1) == $count) || (($i + 1) % $setSize === 0)) { - $updates['whereSet'] = array_values($updates); - Db::$db->query( - 'UPDATE {db_prefix}' . $targetTable . ' - SET ' . $newCol . ' = CASE ' . - implode(' - ', $cases) . ' - ELSE NULL - END - WHERE ' . $oldCol . ' IN ({array_string:whereSet})', - array_merge($updates, $new_ips), - ); - - $updates = []; - $new_ips = []; - $cases = []; - } - } - - return false; - } - - public function migrateData(Table $table, string $col): bool - { - $start = Maintenance::getCurrentStart(); - - // Get our total items. - Maintenance::$total_items = $this->getTotalItems('members', 'member_ip2'); - - $existing_structure = $table->getCurrentStructure(); - - // PostgreSQL we use a migration function. - if (Db::$db->title === POSTGRE_TITLE) { - $this->query( - 'ALTER TABLE {db_prefix}{raw:table} - ALTER {raw:col} DROP not null, - ALTER {raw:col} DROP default, - ALTER {raw:col} TYPE inet USING migrate_inet({raw:col})', - [ - 'table' => $table->name, - 'col' => $col, - ], - ); - - return true; - } - - // Add columns to ban_items - if ($start >= 0) { - // Does the old IP exist? - foreach ($table->columns as $column) { - if ( - $column->name === $col - && !isset($existing_structure['columns'][$col . '_old']) - ) { - $this->query( - 'ALTER TABLE {db_prefix}{raw:table} - CHANGE {raw:col} {raw:col}_old varchar(200)', - [ - 'table' => $table->name, - 'col' => $col, - ], - ); - } - } - - $this->handleTimeout(++$start); - } - - if ($start >= 1 || !isset($existing_structure['columns'][$col])) { - if (isset($existing_structure['columns'][$col . '_old']) && !isset($existing_structure['columns'][$col])) { - $table->addColumn($table->columns[$col]); - } - - $this->handleTimeout(++$start); - } - - // Make sure our temp index exists. - if ($start >= 2) { - if (!isset($existing_structure['indexes']['temp_old_' . $col])) { - $this->query( - 'CREATE INDEX {db_prefix}temp_old_{raw:col} ON {db_prefix}{raw:table} ({raw:col}_old)', - [ - 'table' => $table->name, - 'col' => $col, - ], - ); - } - - $this->handleTimeout(++$start); - } - - // Initialize new ip column. - if ($start >= 3) { - $this->query( - 'UPDATE {db_prefix}{raw:table} - SET {raw:col} = {empty}', - [ - 'table' => $table->name, - 'col' => $col, - ], - ); - - $this->handleTimeout(++$start); - } - - if ($start >= 4) { - $is_done = false; - - while (!$is_done) { - $this->handleTimeout(); - $is_done = $this->convertData($table->name, $col . '_old', $col); - } - - $this->handleTimeout(++$start); - } - - // Remove the temporary ip indexes. - if ($start >= 5) { - if (isset($existing_structure['indexes']['temp_old_' . $col])) { - $this->query( - 'DROP INDEX {db_prefix}temp_old_{raw:col} ON {db_prefix}{raw:table}', - [ - 'table' => $table->name, - 'col' => $col, - ], - ); - } - - $this->handleTimeout(++$start); - } - - // Remove the old member columns. - if ($start >= 6) { - if (isset($existing_structure['columns'][$col . '_old'])) { - $this->query( - 'ALTER TABLE {db_prefix}{raw:table} - DROP COLUMN {raw:col}_old', - [ - 'table' => $table->name, - 'col' => $col, - ], - ); - } - - $this->handleTimeout(++$start); - } - - return true; - } - - public function truncateAndConvert(Table $table, string|array $columns, bool $force = false): bool - { - $start = Maintenance::getCurrentStart(); - - // PostgreSQL we use a migration function. - if (Db::$db->title !== POSTGRE_TITLE && !$force) { - return $this->postgreSQLmigrate($table, $columns); - } - - if ($start <= 0) { - $this->query( - 'TRUNCATE TABLE {db_prefix}{raw:table}', - [ - 'table' => $table->name, - ], - ); - - $this->handleTimeout(++$start); - } - - if ($start <= 1) { - // Modify ip size - foreach ($table->columns as $col) { - if (\in_array($col->name, (array) $columns)) { - $table->alterColumn($col); - } - } - - $this->handleTimeout(++$start); - } - - return true; - } - - public function convertWithNoDataPreservation(Table $table, string|array $columns, bool $force = false): bool - { - $start = Maintenance::getCurrentStart(); - - // PostgreSQL we use a migration function. - if (Db::$db->title !== POSTGRE_TITLE && !$force) { - return $this->postgreSQLmigrate($table, $columns); - } - - $existing_structure = $table->getCurrentStructure(); - - foreach ($columns as $column) { - foreach ($table->columns as $col) { - if ($col->name == $column && $existing_structure['columns'][$col->name]['type'] !== (Db::$db->title === POSTGRE_TITLE ? 'inet' : 'varbinary')) { - $table->dropColumn($col); - $table->addColumn($col); - - $this->handleTimeout(++$start); - } - } - } - - return true; - } - - /****************** - * Internal methods - ******************/ - - private function postgreSQLmigrate(Table $table, string|array $columns) - { - foreach ($columns as $column) { - $this->query( - 'ALTER TABLE {db_prefix}{raw:table} - ALTER {raw:col} DROP not null, - ALTER {raw:col} DROP default, - ALTER {raw:col} TYPE inet USING migrate_inet({raw:col})', - [ - 'table' => $table->name, - 'col' => $column, - ], - ); - } - - return true; - } -} diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6Converter.php b/Sources/Maintenance/Migration/v2_1/Ipv6Converter.php new file mode 100644 index 0000000000..51410d2d82 --- /dev/null +++ b/Sources/Maintenance/Migration/v2_1/Ipv6Converter.php @@ -0,0 +1,131 @@ +title === POSTGRE_TITLE) { + $this->query( + 'ALTER TABLE {db_prefix}{raw:table} + ALTER {raw:column} DROP not null, + ALTER {raw:column} DROP default, + ALTER {raw:column} TYPE inet USING migrate_inet({raw:column})', + [ + 'table' => $table->name, + 'column' => $column->name, + ], + ); + } else { + $table->addColumn(new Column( + name: 'temp', + type: 'inet', + size: 16, + )); + + $this->query( + 'UPDATE {db_prefix}{raw:table} + SET {raw:temp} = INET6_ATON({raw:column})', + [ + 'table' => $table->name, + 'column' => $column->name, + 'temp' => 'temp', + ], + ); + + $table->alterColumn($column); + + $this->query( + 'UPDATE {db_prefix}{raw:table} + SET {raw:column} = {raw:temp}', + [ + 'table' => $table->name, + 'column' => $column->name, + 'temp' => 'temp', + ], + ); + + $table->dropColumn('temp'); + } + } + + /** + * Converts integer columns that stored IP addresses. + * + * @param Table $table The table containing the column to convert. + * @param Column $column The column to convert. + */ + protected function convertIntegerColumnToInet(Table $table, Column $column): void + { + if (Db::$db->title === POSTGRE_TITLE) { + $this->query( + 'ALTER TABLE {db_prefix}{raw:table} + ALTER {raw:column} DROP not null, + ALTER {raw:column} DROP default, + ALTER {raw:column} TYPE inet USING migrate_inet({raw:column})', + [ + 'table' => $table->name, + 'column' => $column->name, + ], + ); + } else { + $table->addColumn(new Column( + name: 'temp', + type: 'inet', + size: 16, + )); + + $this->query( + 'UPDATE {db_prefix}{raw:table} + SET {raw:temp} = UNHEX(HEX({raw:column}))', + [ + 'table' => $table->name, + 'column' => $column->name, + 'temp' => 'temp', + ], + ); + + $table->alterColumn($column); + + $this->query( + 'UPDATE {db_prefix}{raw:table} + SET {raw:column} = {raw:temp}', + [ + 'table' => $table->name, + 'column' => $column->name, + 'temp' => 'temp', + ], + ); + + $table->dropColumn('temp'); + } + } +} diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6LogAction.php b/Sources/Maintenance/Migration/v2_1/Ipv6LogAction.php index 698cc90aaf..b15c794450 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6LogAction.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6LogAction.php @@ -16,10 +16,13 @@ namespace SMF\Maintenance\Migration\v2_1; use SMF\Db\DatabaseApi as Db; +use SMF\Db\Schema; use SMF\Maintenance\Migration\MigrationBase; class Ipv6LogAction extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -27,28 +30,18 @@ class Ipv6LogAction extends MigrationBase /** * */ - public string $name = 'Update log_action ip with ipv6 support'; + public string $name = 'Updating log_action table with IPv6 support'; /**************** * Public methods ****************/ - /** - * - */ - public function __construct() - { - if (Db::$db->title !== POSTGRE_TITLE) { - $this->name .= ' without converting'; - } - } - /** * */ public function isCandidate(): bool { - $table = new \SMF\Db\Schema\v2_1\LogActions(); + $table = new Schema\v2_1\LogActions(); $existing_structure = $table->getCurrentStructure(); if (Db::$db->title === POSTGRE_TITLE) { @@ -63,25 +56,11 @@ public function isCandidate(): bool */ public function execute(): bool { - $table = new \SMF\Db\Schema\v2_1\LogActions(); - $existing_structure = $table->getCurrentStructure(); + $table = new Schema\v2_1\LogActions(); - if (Db::$db->title === POSTGRE_TITLE) { - $this->query( - 'ALTER TABLE {db_prefix}log_actions - ALTER ip DROP not null, - ALTER ip DROP default, - ALTER ip TYPE inet USING migrate_inet(ip)', - ); - } else { - foreach ($table->columns as $column) { - if ($column->name === 'ip' && $existing_structure['columns'][$column->name]['type'] !== 'varbinary') { - $table->dropColumn($column); - $table->addColumn($column); - continue; - } - } - } + $this->convertStringColumnToInet($table, $table->columns['ip']); + + $this->handleTimeout(); return true; } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6LogBanned.php b/Sources/Maintenance/Migration/v2_1/Ipv6LogBanned.php index 529fe3ad22..9e27c15e73 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6LogBanned.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6LogBanned.php @@ -16,10 +16,13 @@ namespace SMF\Maintenance\Migration\v2_1; use SMF\Db\DatabaseApi as Db; +use SMF\Db\Schema; use SMF\Maintenance\Migration\MigrationBase; class Ipv6LogBanned extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -27,28 +30,18 @@ class Ipv6LogBanned extends MigrationBase /** * */ - public string $name = 'Update log_banned ip with ipv6 support'; + public string $name = 'Updating log_banned table with IPv6 support'; /**************** * Public methods ****************/ - /** - * - */ - public function __construct() - { - if (Db::$db->title !== POSTGRE_TITLE) { - $this->name .= ' without converting'; - } - } - /** * */ public function isCandidate(): bool { - $table = new \SMF\Db\Schema\v2_1\LogBanned(); + $table = new Schema\v2_1\LogBanned(); $existing_structure = $table->getCurrentStructure(); if (Db::$db->title === POSTGRE_TITLE) { @@ -63,25 +56,11 @@ public function isCandidate(): bool */ public function execute(): bool { - $table = new \SMF\Db\Schema\v2_1\LogBanned(); - $existing_structure = $table->getCurrentStructure(); + $table = new Schema\v2_1\LogBanned(); - if (Db::$db->title === POSTGRE_TITLE) { - $this->query( - 'ALTER TABLE {db_prefix}log_banned - ALTER ip DROP not null, - ALTER ip DROP default, - ALTER ip TYPE inet USING migrate_inet(ip)', - ); - } else { - foreach ($table->columns as $column) { - if ($column->name === 'ip' && $existing_structure['columns'][$column->name]['type'] !== 'varbinary') { - $table->dropColumn($column); - $table->addColumn($column); - continue; - } - } - } + $this->convertStringColumnToInet($table, $table->columns['ip']); + + $this->handleTimeout(); return true; } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6LogErrors.php b/Sources/Maintenance/Migration/v2_1/Ipv6LogErrors.php index e4ac499c3f..056d8bd7fd 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6LogErrors.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6LogErrors.php @@ -16,10 +16,13 @@ namespace SMF\Maintenance\Migration\v2_1; use SMF\Db\DatabaseApi as Db; +use SMF\Db\Schema; use SMF\Maintenance\Migration\MigrationBase; class Ipv6LogErrors extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -27,28 +30,18 @@ class Ipv6LogErrors extends MigrationBase /** * */ - public string $name = 'Update log_errors ip with ipv6 support'; + public string $name = 'Updating log_errors table with IPv6 support'; /**************** * Public methods ****************/ - /** - * - */ - public function __construct() - { - if (Db::$db->title !== POSTGRE_TITLE) { - $this->name .= ' without converting'; - } - } - /** * */ public function isCandidate(): bool { - $table = new \SMF\Db\Schema\v2_1\LogErrors(); + $table = new Schema\v2_1\LogErrors(); $existing_structure = $table->getCurrentStructure(); if (Db::$db->title === POSTGRE_TITLE) { @@ -63,35 +56,14 @@ public function isCandidate(): bool */ public function execute(): bool { - $table = new \SMF\Db\Schema\v2_1\LogErrors(); - $existing_structure = $table->getCurrentStructure(); + $table = new Schema\v2_1\LogErrors(); - if (Db::$db->title === POSTGRE_TITLE) { - $this->query( - 'ALTER TABLE {db_prefix}log_errors - ALTER ip DROP not null, - ALTER ip DROP default, - ALTER ip TYPE inet USING migrate_inet(ip)', - ); - } else { - foreach ($table->columns as $column) { - if ($column->name === 'ip' && $existing_structure['columns'][$column->name]['type'] !== 'varbinary') { - $table->dropColumn($column); - $table->addColumn($column); - continue; - } - } - } + $this->convertStringColumnToInet($table, $table->columns['ip']); - foreach ($table->indexes as $idx) { - if ( - $idx->name === 'idx_ip' - && !isset($existing_structure['indexes'][$column->name]) - ) { - $table->addIndex($idx); - continue; - } - } + // Fix indices. + $table->normalize(); + + $this->handleTimeout(); return true; } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6LogFloodControl.php b/Sources/Maintenance/Migration/v2_1/Ipv6LogFloodControl.php index a7fc15829d..385252e55f 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6LogFloodControl.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6LogFloodControl.php @@ -17,10 +17,12 @@ use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; -use SMF\Maintenance\Maintenance; +use SMF\Maintenance\Migration\MigrationBase; -class Ipv6LogFloodControl extends Ipv6Base +class Ipv6LogFloodControl extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -28,7 +30,7 @@ class Ipv6LogFloodControl extends Ipv6Base /** * */ - public string $name = 'Update log_floodcontrol ip with ipv6 support without converting'; + public string $name = 'Updating log_floodcontrol table with IPv6 support'; /**************** * Public methods @@ -56,28 +58,13 @@ public function execute(): bool { $table = new Schema\v2_1\LogFloodcontrol(); - $start = Maintenance::getCurrentStart(); - - // Prep floodcontrol - if ($start <= 0) { - $this->query('TRUNCATE TABLE {db_prefix}log_floodcontrol'); - - $this->handleTimeout(++$start); - } + $this->query('TRUNCATE TABLE {db_prefix}log_floodcontrol'); - if ($start <= 1) { - // Add the new floodcontrol ip column - $table->dropIndex($table->indexes['primary']); + $table->dropIndex($table->indexes['primary']); + $this->convertStringColumnToInet($table, $table->columns['ip']); + $table->normalize(); - // Modify log_type size - $table->alterColumn($table->columns['ip']); - $table->alterColumn($table->columns['log_type']); - - // Create primary key for floodcontrol - $table->addIndex($table->indexes['primary']); - - $this->handleTimeout(++$start); - } + $this->handleTimeout(); return true; } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6LogOnline.php b/Sources/Maintenance/Migration/v2_1/Ipv6LogOnline.php index 491342cdd7..e6670fc33b 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6LogOnline.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6LogOnline.php @@ -17,10 +17,12 @@ use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; -use SMF\Maintenance\Maintenance; +use SMF\Maintenance\Migration\MigrationBase; -class Ipv6LogOnline extends Ipv6Base +class Ipv6LogOnline extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -55,10 +57,15 @@ public function isCandidate(): bool public function execute(): bool { $table = new Schema\v2_1\LogOnline(); - $existing_structure = $table->getCurrentStructure(); - $start = Maintenance::getCurrentStart(); + $this->query('TRUNCATE TABLE {db_prefix}log_online'); + + $this->convertIntegerColumnToInet($table, $table->columns['ip']); + + $table->normalize(); + + $this->handleTimeout(); - return $this->truncateAndConvert($table, 'ip', true); + return true; } } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6LogReportedComments.php b/Sources/Maintenance/Migration/v2_1/Ipv6LogReportedComments.php index baa8b584f8..7e6b0a137a 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6LogReportedComments.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6LogReportedComments.php @@ -17,9 +17,12 @@ use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; +use SMF\Maintenance\Migration\MigrationBase; -class Ipv6LogReportedComments extends Ipv6Base +class Ipv6LogReportedComments extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -27,35 +30,25 @@ class Ipv6LogReportedComments extends Ipv6Base /** * */ - public string $name = 'Update log_reported_comments member_ip with ipv6 support'; + public string $name = 'Updating log_reported_comments table with IPv6 support'; /**************** * Public methods ****************/ - /** - * - */ - public function __construct() - { - if (Db::$db->title !== POSTGRE_TITLE) { - $this->name .= ' without converting'; - } - } - /** * */ public function isCandidate(): bool { - $table = new Schema\v2_1\LogFloodcontrol(); + $table = new Schema\v2_1\LogReportedComments(); $existing_structure = $table->getCurrentStructure(); if (Db::$db->title === POSTGRE_TITLE) { - return $existing_structure['columns']['ip']['type'] !== 'inet'; + return $existing_structure['columns']['member_ip']['type'] !== 'inet'; } - return $existing_structure['columns']['ip']['type'] !== 'varbinary'; + return $existing_structure['columns']['member_ip']['type'] !== 'varbinary'; } /** @@ -63,8 +56,12 @@ public function isCandidate(): bool */ public function execute(): bool { - $table = new Schema\v2_1\LogFloodcontrol(); + $table = new Schema\v2_1\LogReportedComments(); + + $this->convertStringColumnToInet($table, $table->columns['member_ip']); + + $this->handleTimeout(); - return $this->convertWithNoDataPreservation($table, 'ip'); + return true; } } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6MemberLogins.php b/Sources/Maintenance/Migration/v2_1/Ipv6MemberLogins.php index 52a8911859..292a695ddb 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6MemberLogins.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6MemberLogins.php @@ -17,9 +17,12 @@ use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; +use SMF\Maintenance\Migration\MigrationBase; -class Ipv6MemberLogins extends Ipv6Base +class Ipv6MemberLogins extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -27,22 +30,12 @@ class Ipv6MemberLogins extends Ipv6Base /** * */ - public string $name = 'Update member_logins ip with ipv6 support'; + public string $name = 'Updating member_logins table with IPv6 support'; /**************** * Public methods ****************/ - /** - * - */ - public function __construct() - { - if (Db::$db->title !== POSTGRE_TITLE) { - $this->name .= ' without converting'; - } - } - /** * */ @@ -52,10 +45,16 @@ public function isCandidate(): bool $existing_structure = $table->getCurrentStructure(); if (Db::$db->title === POSTGRE_TITLE) { - return $existing_structure['columns']['ip']['type'] !== 'inet'; + return ( + $existing_structure['columns']['ip']['type'] !== 'inet' + || $existing_structure['columns']['ip2']['type'] !== 'inet' + ); } - return $existing_structure['columns']['ip']['type'] !== 'varbinary'; + return ( + $existing_structure['columns']['ip']['type'] !== 'varbinary' + || $existing_structure['columns']['ip2']['type'] !== 'varbinary' + ); } /** @@ -64,7 +63,28 @@ public function isCandidate(): bool public function execute(): bool { $table = new Schema\v2_1\MemberLogins(); + $existing_structure = $table->getCurrentStructure(); + + foreach (['ip', 'ip2'] as $col) { + if ( + $existing_structure['columns'][$col]['type'] !== (Db::$db->title === POSTGRE_TITLE ? 'inet' : 'varbinary') + ) { + // This table was added in 2.1 and never had the 'CHAR' type. So if + // these columns are somehow the wrong type, their data is useless. + $this->query( + 'UPDATE {db_prefix}{raw:table} + SET {identifier:column} = {empty}', + [ + 'table' => $table->name, + 'column' => $col, + ], + ); + + $table->alterColumn($table->columns[$col]); + $this->handleTimeout(); + } + } - return $this->convertWithNoDataPreservation($table, 'ip') && $this->convertWithNoDataPreservation($table, 'ip2'); + return true; } } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6MembersIP.php b/Sources/Maintenance/Migration/v2_1/Ipv6MembersIP.php index 3cff8e413a..dda0b18559 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6MembersIP.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6MembersIP.php @@ -17,9 +17,12 @@ use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; +use SMF\Maintenance\Migration\MigrationBase; -class Ipv6MembersIP extends Ipv6Base +class Ipv6MembersIP extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -27,7 +30,7 @@ class Ipv6MembersIP extends Ipv6Base /** * */ - public string $name = 'Update members with ipv6 support (IP)'; + public string $name = 'Updating members table with IPv6 support (part 1)'; /**************** * Public methods @@ -45,8 +48,7 @@ public function isCandidate(): bool return $existing_structure['columns']['member_ip']['type'] !== 'inet'; } - return isset($existing_structure['columns']['member_ip_old']) - || $existing_structure['columns']['member_ip']['type'] !== 'varbinary'; + return $existing_structure['columns']['member_ip']['type'] !== 'varbinary'; } /** @@ -56,6 +58,9 @@ public function execute(): bool { $table = new Schema\v2_1\Members(); - return $this->migrateData($table, 'member_ip'); + $this->convertStringColumnToInet($table, $table->columns['member_ip']); + $this->handleTimeout(); + + return true; } } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6MembersIP2.php b/Sources/Maintenance/Migration/v2_1/Ipv6MembersIP2.php index 89c9907f6a..8ec6eb8c05 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6MembersIP2.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6MembersIP2.php @@ -17,9 +17,12 @@ use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; +use SMF\Maintenance\Migration\MigrationBase; -class Ipv6MembersIP2 extends Ipv6Base +class Ipv6MembersIP2 extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -27,7 +30,7 @@ class Ipv6MembersIP2 extends Ipv6Base /** * */ - public string $name = 'Update members with ipv6 support (IP2)'; + public string $name = 'Updating members table with IPv6 support (part 2)'; /**************** * Public methods @@ -45,8 +48,7 @@ public function isCandidate(): bool return $existing_structure['columns']['member_ip2']['type'] !== 'inet'; } - return isset($existing_structure['columns']['member_ip2_old']) - || $existing_structure['columns']['member_ip2']['type'] !== 'varbinary'; + return $existing_structure['columns']['member_ip2']['type'] !== 'varbinary'; } /** @@ -56,6 +58,9 @@ public function execute(): bool { $table = new Schema\v2_1\Members(); - return $this->migrateData($table, 'member_ip2'); + $this->convertStringColumnToInet($table, $table->columns['member_ip2']); + $this->handleTimeout(); + + return true; } } diff --git a/Sources/Maintenance/Migration/v2_1/Ipv6Messages.php b/Sources/Maintenance/Migration/v2_1/Ipv6Messages.php index 474669499a..cda76aa684 100644 --- a/Sources/Maintenance/Migration/v2_1/Ipv6Messages.php +++ b/Sources/Maintenance/Migration/v2_1/Ipv6Messages.php @@ -17,10 +17,12 @@ use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; -use SMF\Maintenance\Maintenance; +use SMF\Maintenance\Migration\MigrationBase; -class Ipv6Messages extends Ipv6Base +class Ipv6Messages extends MigrationBase { + use IPv6Converter; + /******************* * Public properties *******************/ @@ -28,7 +30,7 @@ class Ipv6Messages extends Ipv6Base /** * */ - public string $name = 'Update messages poster_ip with ipv6 support (May take a while)'; + public string $name = 'Updating messages table with IPv6 support'; /**************** * Public methods @@ -46,8 +48,7 @@ public function isCandidate(): bool return $existing_structure['columns']['poster_ip']['type'] !== 'inet'; } - return isset($existing_structure['columns']['poster_ip_old']) - || $existing_structure['columns']['poster_ip']['type'] !== 'varbinary'; + return $existing_structure['columns']['poster_ip']['type'] !== 'varbinary'; } /** @@ -57,22 +58,8 @@ public function execute(): bool { $table = new Schema\v2_1\Messages(); - // This will return true once its done, but we need to do a few more things. - $this->migrateData($table, 'poster_ip'); - - $start = Maintenance::getCurrentStart(); - - if ($start <= 7) { - $table->addIndex($table->indexes['idx_ip_index']); - - $this->handleTimeout(++$start); - } - - if ($start <= 8) { - $table->addIndex($table->indexes['idx_related_ip']); - - $this->handleTimeout(++$start); - } + $this->convertStringColumnToInet($table, $table->columns['poster_ip']); + $this->handleTimeout(); return true; } diff --git a/Sources/Maintenance/Migration/v2_1/Likes.php b/Sources/Maintenance/Migration/v2_1/Likes.php index 61a5866871..7ff4bf2e40 100644 --- a/Sources/Maintenance/Migration/v2_1/Likes.php +++ b/Sources/Maintenance/Migration/v2_1/Likes.php @@ -15,8 +15,7 @@ namespace SMF\Maintenance\Migration\v2_1; -use SMF\Config; -use SMF\Db\DatabaseApi as Db; +use SMF\Db\Schema; use SMF\Maintenance\Maintenance; use SMF\Maintenance\Migration\MigrationBase; @@ -40,9 +39,9 @@ class Likes extends MigrationBase */ public function isCandidate(): bool { - $tables = Db::$db->list_tables(); + $table = new Schema\v2_1\UserLikes(); - return !\in_array(Config::$db_prefix . 'user_likes', $tables); + return !$table->exists(); } /** @@ -52,27 +51,19 @@ public function execute(): bool { $start = Maintenance::getCurrentStart(); - $LikesTable = new \SMF\Db\Schema\v2_1\UserLikes(); - - $tables = Db::$db->list_tables(); - - // Creating draft table. - if ($start <= 0 && !\in_array(Config::$db_prefix . 'user_likes', $tables)) { - $LikesTable->create(); - + if ($start <= 0) { + $likes_table = new Schema\v2_1\UserLikes(); + $likes_table->create(); $this->handleTimeout(++$start); } // Adding likes column to the messages table. (May take a while) if ($start <= 1) { - $MessagesTable = new \SMF\Db\Schema\v2_1\Messages(); - $existing_structure = $MessagesTable->getCurrentStructure(); + $messages_table = new Schema\v2_1\Messages(); + $existing_structure = $messages_table->getCurrentStructure(); - foreach ($MessagesTable->columns as $column) { - // Add the columns. - if ($column->name === 'likes' && !isset($existing_structure['columns'][$column->name])) { - $MessagesTable->addColumn($column); - } + if (!isset($existing_structure['columns']['likes'])) { + $messages_table->addColumn($messages_table->columns['likes']); } $this->handleTimeout(++$start); diff --git a/Sources/Maintenance/Migration/v2_1/Mentions.php b/Sources/Maintenance/Migration/v2_1/Mentions.php index de32bc69fa..61222eb5c5 100644 --- a/Sources/Maintenance/Migration/v2_1/Mentions.php +++ b/Sources/Maintenance/Migration/v2_1/Mentions.php @@ -15,8 +15,6 @@ namespace SMF\Maintenance\Migration\v2_1; -use SMF\Config; -use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; use SMF\Maintenance\Migration\MigrationBase; @@ -40,9 +38,9 @@ class Mentions extends MigrationBase */ public function isCandidate(): bool { - $tables = Db::$db->list_tables(); + $table = new Schema\v2_1\Mentions(); - return !\in_array(Config::$db_prefix . 'mentions', $tables); + return !$table->exists(); } /** diff --git a/Sources/Maintenance/Migration/v2_1/ModeratorGroups.php b/Sources/Maintenance/Migration/v2_1/ModeratorGroups.php index 70be7572da..7c160bcdf0 100644 --- a/Sources/Maintenance/Migration/v2_1/ModeratorGroups.php +++ b/Sources/Maintenance/Migration/v2_1/ModeratorGroups.php @@ -15,8 +15,6 @@ namespace SMF\Maintenance\Migration\v2_1; -use SMF\Config; -use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; use SMF\Maintenance\Migration\MigrationBase; @@ -40,9 +38,9 @@ class ModeratorGroups extends MigrationBase */ public function isCandidate(): bool { - $tables = Db::$db->list_tables(); + $table = new Schema\v2_1\ModeratorGroups(); - return !\in_array(Config::$db_prefix . 'moderator_groups', $tables); + return !$table->exists(); } /** diff --git a/Sources/Maintenance/Migration/v2_1/Permissions.php b/Sources/Maintenance/Migration/v2_1/Permissions.php index 0c8cbcfa90..f7f543ae7c 100644 --- a/Sources/Maintenance/Migration/v2_1/Permissions.php +++ b/Sources/Maintenance/Migration/v2_1/Permissions.php @@ -248,7 +248,7 @@ public function execute(): bool ); } - Db::$db->query( + $this->query( 'DELETE FROM {db_prefix}settings WHERE variable = {string:warning_show}', [ @@ -306,7 +306,7 @@ public function execute(): bool $this->handleTimeout(++$start); - Db::$db->query( + $this->query( 'DELETE FROM {db_prefix}permissions WHERE id_group = {int:guests} AND permission IN ({array_string:illegal_perms})', diff --git a/Sources/Maintenance/Migration/v2_1/PersonalMessageLabels.php b/Sources/Maintenance/Migration/v2_1/PersonalMessageLabels.php index d307db5414..6eacbc7b07 100644 --- a/Sources/Maintenance/Migration/v2_1/PersonalMessageLabels.php +++ b/Sources/Maintenance/Migration/v2_1/PersonalMessageLabels.php @@ -15,7 +15,6 @@ namespace SMF\Maintenance\Migration\v2_1; -use SMF\Config; use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; use SMF\Db\Schema\Column; @@ -75,15 +74,13 @@ public function execute(): bool $pm_labels_table = new Schema\v2_1\PmLabels(); $pm_labeled_messages_table = new Schema\v2_1\PmLabeledMessages(); - $tables = Db::$db->list_tables(); - if ($start <= 0) { - if (!\in_array(Config::$db_prefix . 'pm_labels', $tables)) { + if (!$pm_labels_table->exists()) { $pm_labels_table->create(); $this->handleTimeout(0); } - if (!\in_array(Config::$db_prefix . 'pm_labeled_messages', $tables)) { + if (!$pm_labeled_messages_table->exists()) { $pm_labeled_messages_table->create(); $this->handleTimeout(0); } @@ -116,10 +113,12 @@ public function execute(): bool while (!$is_done) { $this->handleTimeout($start); + $label_info = []; + $member_list = []; $inserts = []; // Pull the label info - $get_labels = Db::$db->query( + $get_labels = $this->query( 'SELECT id_member, message_labels FROM {db_prefix}members WHERE message_labels != {string:blank} @@ -131,9 +130,6 @@ public function execute(): bool ], ); - $label_info = []; - $member_list = []; - while ($row = Db::$db->fetch_assoc($get_labels)) { $member_list[] = $row['id_member']; @@ -149,6 +145,11 @@ public function execute(): bool Db::$db->free_result($get_labels); + if (empty($member_list)) { + $is_done = true; + break; + } + foreach ($label_info as $id_member => $labels) { foreach ($labels as $label => $index) { $inserts[] = [$id_member, $label]; @@ -172,7 +173,7 @@ public function execute(): bool } // This is the easy part - update the inbox stuff - Db::$db->query( + $this->query( 'UPDATE {db_prefix}pm_recipients SET in_inbox = {int:in_inbox} WHERE FIND_IN_SET({int:minusone}, labels) @@ -185,7 +186,7 @@ public function execute(): bool ); // Now we go pull the new IDs for each label - $get_new_label_ids = Db::$db->query( + $get_new_label_ids = $this->query( 'SELECT * FROM {db_prefix}pm_labels WHERE id_member IN ({array_int:member_list})', @@ -206,7 +207,7 @@ public function execute(): bool // Pull label info from pm_recipients // Ignore any that are only in the inbox - $get_pm_labels = Db::$db->query( + $get_pm_labels = $this->query( 'SELECT id_pm, id_member, labels FROM {db_prefix}pm_recipients WHERE deleted = {int:not_deleted} @@ -249,7 +250,7 @@ public function execute(): bool } // Final step of this ridiculously massive process - $get_pm_rules = Db::$db->query( + $get_pm_rules = $this->query( 'SELECT id_member, id_rule, actions FROM {db_prefix}pm_rules WHERE id_member IN ({array_int:member_list})', @@ -278,7 +279,7 @@ public function execute(): bool // Put this back into a string $actions = serialize($actions); - Db::$db->query( + $this->query( 'UPDATE {db_prefix}pm_rules SET actions = {string:actions} WHERE id_rule = {int:id_rule}', @@ -291,7 +292,7 @@ public function execute(): bool } // Remove processed pm labels, to avoid duplicated data if upgrader is restarted. - Db::$db->query( + $this->query( 'UPDATE {db_prefix}members SET message_labels = {string:blank} WHERE id_member IN ({array_int:member_list})', @@ -311,32 +312,10 @@ public function execute(): bool } $pm_recipients_table = new Schema\v2_1\PmRecipients(); - $existing_structure = $pm_recipients_table->getCurrentStructure(); - - foreach ($existing_structure['columns'] as $column) { - if ($column['name'] == 'labels') { - $col = new Column( - name: $column['name'], - type: 'varchar', - ); - - $pm_recipients_table->dropColumn($col); - } - } + $pm_recipients_table->dropColumn('labels'); $members_table = new Schema\v2_1\Members(); - $existing_structure = $members_table->getCurrentStructure(); - - foreach ($existing_structure['columns'] as $column) { - if ($column['name'] == 'message_labels') { - $col = new Column( - name: $column['name'], - type: 'varchar', - ); - - $members_table->dropColumn($col); - } - } + $members_table->dropColumn('message_labels'); return true; } diff --git a/Sources/Maintenance/Migration/v2_1/PostgreSqlFindInSet.php b/Sources/Maintenance/Migration/v2_1/PostgreSqlFindInSet.php index afc99bcfe8..3447004662 100644 --- a/Sources/Maintenance/Migration/v2_1/PostgreSqlFindInSet.php +++ b/Sources/Maintenance/Migration/v2_1/PostgreSqlFindInSet.php @@ -27,7 +27,7 @@ class PostgreSQLFindInSet extends MigrationBase /** * */ - public string $name = 'Add find_in_set function (PostgreSQL)'; + public string $name = 'Adding FIND_IN_SET function (PostgreSQL)'; /**************** * Public methods diff --git a/Sources/Maintenance/Migration/v2_1/PostgreSqlIPv6Helper.php b/Sources/Maintenance/Migration/v2_1/PostgreSqlIPv6Helper.php index b530f5a2e0..22a94f9887 100644 --- a/Sources/Maintenance/Migration/v2_1/PostgreSqlIPv6Helper.php +++ b/Sources/Maintenance/Migration/v2_1/PostgreSqlIPv6Helper.php @@ -27,7 +27,7 @@ class PostgreSQLIPv6Helper extends MigrationBase /** * */ - public string $name = 'helper function for ip convert'; + public string $name = 'Adding helper function for IPv6 conversion'; /**************** * Public methods diff --git a/Sources/Maintenance/Migration/v2_1/PostgreSqlSchemaDiff.php b/Sources/Maintenance/Migration/v2_1/PostgreSqlSchemaDiff.php index 6273cc8e00..b1d91af1e4 100644 --- a/Sources/Maintenance/Migration/v2_1/PostgreSqlSchemaDiff.php +++ b/Sources/Maintenance/Migration/v2_1/PostgreSqlSchemaDiff.php @@ -35,8 +35,10 @@ class PostgreSqlSchemaDiff extends MigrationBase *********************/ /** - * Schmea fixes we will peform, these are not cross database safe as we intend to run this only on PostgreSQL. * @var array + * + * Schmea fixes we will peform, these are not cross database safe as we + * intend to run this only on PostgreSQL. */ private array $schema_fixes = [ ['log_subscribed', 'ALTER pending_details DROP DEFAULT'], @@ -141,6 +143,7 @@ public function execute(): bool $this->query( 'DROP INDEX IF EXISTS {db_prefix}log_actions_id_topic_id_log', ); + $this->query( 'CREATE INDEX {db_prefix}log_actions_id_topic_id_log ON {db_prefix}log_actions (id_topic, id_log)', ); diff --git a/Sources/Maintenance/Migration/v2_1/PostgreSqlSequences.php b/Sources/Maintenance/Migration/v2_1/PostgreSqlSequences.php index 357608b120..72a6a29210 100644 --- a/Sources/Maintenance/Migration/v2_1/PostgreSqlSequences.php +++ b/Sources/Maintenance/Migration/v2_1/PostgreSqlSequences.php @@ -238,7 +238,7 @@ public function isCandidate(): bool */ public function execute(): bool { - for ($i = Maintenance::getCurrentStart(); $i < \count($this->sequences); Maintenance::setCurrentStart()) { + for ($i = Maintenance::getCurrentStart(); $i < \count($this->sequences); $i++) { $this->handleTimeout(); $value = $this->sequences[$i]; @@ -248,9 +248,11 @@ public function execute(): bool [ 'key' => Config::$db_prefix . $value['key'], 'field' => $value['field'], - 'table' => $value['table'], + 'table' => Config::$db_prefix . $value['table'], ], ); + + Maintenance::setCurrentStart(); } return true; diff --git a/Sources/Maintenance/Migration/v2_1/Smileys.php b/Sources/Maintenance/Migration/v2_1/Smileys.php index 007e8c11c4..c4536b8e37 100644 --- a/Sources/Maintenance/Migration/v2_1/Smileys.php +++ b/Sources/Maintenance/Migration/v2_1/Smileys.php @@ -48,12 +48,7 @@ public function execute(): bool // Adding the new `smiley_files` table if ($start <= 0) { $table = new Schema\v2_1\SmileyFiles(); - $existing_tables = Db::$db->list_tables(); - - if (!\in_array(Config::$db_prefix . $table->name, $existing_tables)) { - $table->create(); - } - + $table->create(); $this->handleTimeout(++$start); } diff --git a/Sources/Maintenance/Migration/v2_1/UserDrafts.php b/Sources/Maintenance/Migration/v2_1/UserDrafts.php index 7e32267a52..6abe26cccc 100644 --- a/Sources/Maintenance/Migration/v2_1/UserDrafts.php +++ b/Sources/Maintenance/Migration/v2_1/UserDrafts.php @@ -41,9 +41,9 @@ class UserDrafts extends MigrationBase */ public function isCandidate(): bool { - $tables = Db::$db->list_tables(); + $table = new Schema\v2_1\UserDrafts(); - return !\in_array(Config::$db_prefix . 'user_drafts', $tables) || Maintenance::getCurrentStart() > 0; + return !$table->exists(); } /** @@ -53,14 +53,10 @@ public function execute(): bool { $start = Maintenance::getCurrentStart(); - $drafts_table = new Schema\v2_1\UserDrafts(); - - $tables = Db::$db->list_tables(); - // Creating draft table. - if ($start <= 0 && !\in_array(Config::$db_prefix . 'user_drafts', $tables)) { - $drafts_table->create(); - + if ($start <= 0) { + $table = new Schema\v2_1\UserDrafts(); + $table->create(); $this->handleTimeout(++$start); } @@ -74,8 +70,8 @@ public function execute(): bool ) ) { // Anyone who can currently post unapproved topics we assume can create drafts as well ... - $request = Db::$db->query( - 'SELECT id_group, id_board, add_deny, permission + $request = $this->query( + 'SELECT id_group, id_profile, add_deny, permission FROM {db_prefix}board_permissions WHERE permission = {literal:post_unapproved_topics}', [], @@ -86,7 +82,7 @@ public function execute(): bool while ($row = Db::$db->fetch_assoc($request)) { $inserts[] = [ (int) $row['id_group'], - (int) $row['id_board'], + (int) $row['id_profile'], 'post_draft', (int) $row['add_deny'], ]; @@ -99,7 +95,7 @@ public function execute(): bool '{db_prefix}board_permissions', [ 'id_group' => 'int', - 'id_board' => 'int', + 'id_profile' => 'int', 'permission' => 'string', 'add_deny' => 'int', ], diff --git a/Sources/Maintenance/Migration/v2_1/VerificationQuestions.php b/Sources/Maintenance/Migration/v2_1/VerificationQuestions.php index f0d44b5ee5..e9a500a81a 100644 --- a/Sources/Maintenance/Migration/v2_1/VerificationQuestions.php +++ b/Sources/Maintenance/Migration/v2_1/VerificationQuestions.php @@ -15,7 +15,6 @@ namespace SMF\Maintenance\Migration\v2_1; -use SMF\Config; use SMF\Db\DatabaseApi as Db; use SMF\Db\Schema; use SMF\Maintenance\Maintenance; @@ -41,9 +40,9 @@ class VerificationQuestions extends MigrationBase */ public function isCandidate(): bool { - $tables = Db::$db->list_tables(); + $table = new Schema\v2_1\Qanda(); - return !\in_array(Config::$db_prefix . 'qanda', $tables); + return !$table->exists(); } /** @@ -53,14 +52,10 @@ public function execute(): bool { $start = Maintenance::getCurrentStart(); - $table = new Schema\v2_1\Qanda(); - - $tables = Db::$db->list_tables(); - - // Creating draft table. - if ($start <= 0 && !\in_array(Config::$db_prefix . 'qanda', $tables)) { + // Creating table. + if ($start <= 0) { + $table = new Schema\v2_1\Qanda(); $table->create(); - $this->handleTimeout(++$start); } diff --git a/Sources/Maintenance/Migration/v3_0/ConvertToInnoDb.php b/Sources/Maintenance/Migration/v3_0/ConvertToInnoDb.php index e3d0ffa935..a0a82b4b07 100644 --- a/Sources/Maintenance/Migration/v3_0/ConvertToInnoDb.php +++ b/Sources/Maintenance/Migration/v3_0/ConvertToInnoDb.php @@ -54,7 +54,7 @@ public function execute(): bool $result = true; if ($structure['engine'] !== 'InnoDB') { - $result = Db::$db->query( + $result = $this->query( 'ALTER TABLE {identifier:table} ENGINE {literal:InnoDB} ROW_FORMAT=DYNAMIC', @@ -63,7 +63,7 @@ public function execute(): bool ], ); } elseif ($structure['row_format'] !== 'Dynamic') { - $result = Db::$db->query( + $result = $this->query( 'ALTER TABLE {identifier:table} ROW_FORMAT=DYNAMIC', [ @@ -80,7 +80,7 @@ public function execute(): bool // Try to ensure all future tables use dynamic row format. $can_set_global_default = false; - $request = Db::$db->query('SHOW GRANTS'); + $request = $this->query('SHOW GRANTS'); while ($row = Db::$db->fetch_row($request)) { if ( @@ -95,7 +95,7 @@ public function execute(): bool Db::$db->free_result($request); if ($can_set_global_default) { - $result = Db::$db->query( + $result = $this->query( 'SET GLOBAL innodb_default_row_format=DYNAMIC', [ 'db_error_skip' => true, diff --git a/Sources/Maintenance/Migration/v3_0/EditHistory.php b/Sources/Maintenance/Migration/v3_0/EditHistory.php index 42e559964b..28507c2792 100644 --- a/Sources/Maintenance/Migration/v3_0/EditHistory.php +++ b/Sources/Maintenance/Migration/v3_0/EditHistory.php @@ -50,7 +50,7 @@ public function execute(): bool } // Populate edit_history. - $request = Db::$db->query( + $request = $this->query( 'SELECT id_msg, body, modified_time, modified_name, modified_reason, edit_history FROM {db_prefix}messages WHERE id_msg > {int:start} @@ -77,7 +77,7 @@ public function execute(): bool $row['modified_reason'], ]]); - Db::$db->query( + $this->query( 'UPDATE {db_prefix}messages SET edit_history = {string:edit_history} WHERE id_msg = {int:id_msg}', diff --git a/Sources/Maintenance/Migration/v3_0/EventUids.php b/Sources/Maintenance/Migration/v3_0/EventUids.php index 446978eae0..bf1389e5f2 100644 --- a/Sources/Maintenance/Migration/v3_0/EventUids.php +++ b/Sources/Maintenance/Migration/v3_0/EventUids.php @@ -41,7 +41,7 @@ public function execute(): bool { $calendar_updates = []; - $request = Db::$db->query( + $request = $this->query( 'SELECT id_event, uid FROM {db_prefix}calendar', [], @@ -56,7 +56,7 @@ public function execute(): bool Db::$db->free_result($request); foreach ($calendar_updates as $calendar_update) { - Db::$db->query( + $this->query( 'UPDATE {db_prefix}calendar SET uid = {string:uid} WHERE id_event = {int:id_event}', diff --git a/Sources/Maintenance/Migration/v3_0/HolidaysToEvents.php b/Sources/Maintenance/Migration/v3_0/HolidaysToEvents.php index 199524a028..e5697819e9 100644 --- a/Sources/Maintenance/Migration/v3_0/HolidaysToEvents.php +++ b/Sources/Maintenance/Migration/v3_0/HolidaysToEvents.php @@ -634,7 +634,7 @@ public function execute(): bool User::load(); } - $request = Db::$db->query( + $request = $this->query( 'SELECT title, GROUP_CONCAT(event_date) as rdates FROM {db_prefix}calendar_holidays GROUP BY title', diff --git a/Sources/Maintenance/Migration/v3_0/LanguageDirectory.php b/Sources/Maintenance/Migration/v3_0/LanguageDirectory.php index 57c527cd77..4a85c9fa1c 100644 --- a/Sources/Maintenance/Migration/v3_0/LanguageDirectory.php +++ b/Sources/Maintenance/Migration/v3_0/LanguageDirectory.php @@ -72,7 +72,7 @@ public function execute(): bool $this->handleTimeout(); // Skip errors here so we don't croak if the columns don't exist... - $request = Db::$db->query( + $request = $this->query( 'SELECT id_member FROM {db_prefix}members WHERE lngfile IN ({array_string:possible_languages}) @@ -105,7 +105,7 @@ public function execute(): bool $args['search_members'] = $members; - Db::$db->query( + $this->query( 'UPDATE {db_prefix}members SET lngfile = CASE ' . implode(' ', $statements) . ' diff --git a/Sources/Maintenance/Migration/v3_0/MailType.php b/Sources/Maintenance/Migration/v3_0/MailType.php index c8e1a005d4..d60f295789 100644 --- a/Sources/Maintenance/Migration/v3_0/MailType.php +++ b/Sources/Maintenance/Migration/v3_0/MailType.php @@ -15,7 +15,6 @@ namespace SMF\Maintenance\Migration\v3_0; -use SMF\Db\DatabaseApi as Db; use SMF\Maintenance\Migration\MigrationBase; class MailType extends MigrationBase @@ -38,7 +37,7 @@ class MailType extends MigrationBase */ public function execute(): bool { - Db::$db->query( + $this->query( 'UPDATE {db_prefix}settings SET value = CASE diff --git a/Sources/Maintenance/Migration/v3_0/PermissionChanges.php b/Sources/Maintenance/Migration/v3_0/PermissionChanges.php index 17061c1b74..75cd3dabb1 100644 --- a/Sources/Maintenance/Migration/v3_0/PermissionChanges.php +++ b/Sources/Maintenance/Migration/v3_0/PermissionChanges.php @@ -15,7 +15,6 @@ namespace SMF\Maintenance\Migration\v3_0; -use SMF\Db\DatabaseApi as Db; use SMF\Maintenance\Migration\MigrationBase; class PermissionChanges extends MigrationBase @@ -38,7 +37,7 @@ class PermissionChanges extends MigrationBase */ public function execute(): bool { - Db::$db->query( + $this->query( 'DELETE FROM {db_prefix}permissions WHERE permission IN ({array_string:perms})', [ diff --git a/Sources/Maintenance/Migration/v3_0/PostgreSqlFunctions.php b/Sources/Maintenance/Migration/v3_0/PostgreSqlFunctions.php index 493a23bf26..bf3ace41f8 100644 --- a/Sources/Maintenance/Migration/v3_0/PostgreSqlFunctions.php +++ b/Sources/Maintenance/Migration/v3_0/PostgreSqlFunctions.php @@ -49,7 +49,7 @@ public function execute(): bool { $schema_version = substr(__NAMESPACE__, strrpos(__NAMESPACE__, '\\', -1) + 1); - $queries = Table::getInitializers($schema_version, POSTGRE_TITLE); + $queries = Table::getInitializers($schema_version); foreach ($queries as $query) { // Use the upgrade query handler. diff --git a/Sources/Maintenance/Migration/v3_0/RecurringEvents.php b/Sources/Maintenance/Migration/v3_0/RecurringEvents.php index ce10d2a8e5..c3cc255fb6 100644 --- a/Sources/Maintenance/Migration/v3_0/RecurringEvents.php +++ b/Sources/Maintenance/Migration/v3_0/RecurringEvents.php @@ -51,13 +51,13 @@ public function execute(): bool } if (Db::$db->title === MYSQL_TITLE) { - Db::$db->query( + $this->query( 'ALTER TABLE {db_prefix}calendar MODIFY COLUMN start_date DATE AFTER id_member', [], ); - Db::$db->query( + $this->query( 'ALTER TABLE {db_prefix}calendar MODIFY COLUMN end_date DATE AFTER start_date', [], @@ -67,7 +67,7 @@ public function execute(): bool $updates = []; - $request = Db::$db->query( + $request = $this->query( 'SELECT id_event, start_date, end_date, start_time, end_time, timezone FROM {db_prefix}calendar', [], @@ -120,7 +120,7 @@ public function execute(): bool Db::$db->free_result($request); foreach ($updates as $id_event => $changes) { - Db::$db->query( + $this->query( 'UPDATE {db_prefix}calendar SET duration = {string:duration}, end_date = {date:end_date}, rrule = {string:rrule} WHERE id_event = {int:id_event}', diff --git a/Sources/Maintenance/Tools/Install.php b/Sources/Maintenance/Tools/Install.php index 29a50f32ad..72b77c54b6 100644 --- a/Sources/Maintenance/Tools/Install.php +++ b/Sources/Maintenance/Tools/Install.php @@ -742,7 +742,7 @@ public function databasePopulation(): bool // Some initialization may exist. Db::$db->disableQueryCheck = true; - foreach (Table::getInitializers($this->schema_version, Db::$db->title) as $query) { + foreach (Table::getInitializers($this->schema_version) as $query) { Db::$db->query($query, [ 'security_override' => true, ]); diff --git a/Sources/Maintenance/Tools/ToolsBase.php b/Sources/Maintenance/Tools/ToolsBase.php index abe6ee09fa..8442c464b0 100644 --- a/Sources/Maintenance/Tools/ToolsBase.php +++ b/Sources/Maintenance/Tools/ToolsBase.php @@ -559,7 +559,7 @@ public function checkAndHandleTimeout(): void Maintenance::setQueryString(); } - Maintenance::exit(); + Maintenance::exit(Maintenance::isJson()); throw new \Exception('Zombies!'); } @@ -585,6 +585,15 @@ public function updateSettingsFile(array $config_vars, ?bool $keep_quotes = null $this->logProgress(Lang::getTxt('log_settings_file_save', ['setting_names' => Lang::sentenceList(array_keys($config_vars))], file: 'Maintenance'), true); } + if ($rebuild) { + // Remove all the existing comments to make the rebuild nice and clean. + Config::safeFileWrite( + file: SMF_SETTINGS_FILE, + data: Config::stripPhpComments(file_get_contents(SMF_SETTINGS_FILE)), + mtime: time(), + ); + } + if (!Config::updateSettingsFile($config_vars, $keep_quotes, $rebuild)) { $this->logProgress(Lang::getTxt('log_failed_with_error', ['error' => Lang::getTxt('settings_error', file: 'Maintenance')], file: 'Maintenance')); diff --git a/Sources/Maintenance/Tools/Upgrade.php b/Sources/Maintenance/Tools/Upgrade.php index 5af6b9bb82..ebb5f5d08c 100644 --- a/Sources/Maintenance/Tools/Upgrade.php +++ b/Sources/Maintenance/Tools/Upgrade.php @@ -86,7 +86,6 @@ class Upgrade extends ToolsBase implements ToolsInterface Migration\v2_1\FixDates::class, Migration\v2_1\CreateMemberLogins::class, Migration\v2_1\CollapsedCategories::class, - Migration\v2_1\BoardDescriptions::class, Migration\v2_1\LegacyAttachments::class, Migration\v2_1\AttachmentSizes::class, Migration\v2_1\AttachmentDirectory::class, @@ -154,6 +153,7 @@ class Upgrade extends ToolsBase implements ToolsInterface Migration\v2_1\IdxLogComments::class, Migration\v2_1\MysqlLegacyData::class, Migration\v2_1\Smileys::class, + Migration\v2_1\BoardDescriptions::class, Migration\v2_1\LogErrorsBacktrace::class, Migration\v2_1\BoardPermissionsView::class, Migration\v2_1\PostgreSqlSchemaDiff::class, @@ -193,7 +193,6 @@ class Upgrade extends ToolsBase implements ToolsInterface // Cleanup steps for 2.1 -> 3.0 'v3_0' => [ Cleanup\v3_0\TasksDirCase::class, - Cleanup\v3_0\OldFiles::class, ], ]; @@ -979,18 +978,15 @@ public function upgradeOptions(): bool // If they have a "host:port" setup for the host, split that into separate values // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry if (strpos(Config::$db_server, ':') !== false) { - list(Config::$db_server, Config::$db_port) = explode(':', Config::$db_server); + list(Config::$db_server, $db_port) = explode(':', Config::$db_server); + Config::$db_port = (int) $db_port; $file_settings['db_server'] = Config::$db_server; - - // Only set this if we're not using the default port - if (Config::$db_port != Db::$db->getDefaultPort()) { - $file_settings['db_port'] = (int) Config::$db_port; - } + $file_settings['db_port'] = Config::$db_port; } // If db_port is set and is the same as the default, set it to 0. - if (!empty(Config::$db_port) && Config::$db_port != Db::$db->getDefaultPort()) { + if (!empty(Config::$db_port) && Config::$db_port == Db::$db->getDefaultPort()) { $file_settings['db_port'] = 0; } @@ -1223,10 +1219,11 @@ public function finalize(): bool // Log what we've done. if (!isset(User::$me)) { - User::load(); + User::load(dataset: 'minimal'); } if (empty(User::$me->id) && !empty($this->user['id'])) { + User::load($this->user['id'], dataset: 'minimal'); User::setMe($this->user['id']); } @@ -1611,6 +1608,7 @@ private function performSubsteps(array $substeps): bool // Load up the current user safely. if (!isset(User::$me)) { + User::load($this->user['id'], dataset: 'minimal'); User::setMe($this->user['id']); if ($this->user['id'] === 0 && $this->user['name'] === 'Database Admin') { diff --git a/Sources/QueryString.php b/Sources/QueryString.php index c92a0a3ed5..554130c65c 100644 --- a/Sources/QueryString.php +++ b/Sources/QueryString.php @@ -639,6 +639,7 @@ protected static function sslRedirect(): void && !Sapi::httpsOn() && str_starts_with($_SERVER['REQUEST_URL'] ?? '', 'http://') && SMF != 'SSI' + && !\defined('SMF_INSTALLING') ) { if (isset($_GET['sslRedirect'])) { ErrorHandler::fatalLang('login_ssl_required', false); @@ -654,7 +655,7 @@ protected static function sslRedirect(): void */ protected static function wwwRedirect(): void { - if (SMF == 'SSI') { + if (SMF == 'SSI' || \defined('SMF_INSTALLING')) { return; } @@ -678,7 +679,7 @@ protected static function wwwRedirect(): void */ protected static function fixUrl(): void { - if (SMF == 'SSI') { + if (SMF == 'SSI' || \defined('SMF_INSTALLING')) { return; } diff --git a/Themes/default/Admin.template.php b/Themes/default/Admin.template.php index 2be9b2150e..bfc0c72d49 100644 --- a/Themes/default/Admin.template.php +++ b/Themes/default/Admin.template.php @@ -1557,7 +1557,7 @@ function template_repair_boards() if (!empty(Utils::$context['redirect_to_recount'])) { echo ' '; } } diff --git a/Themes/default/MaintenanceTemplate.php b/Themes/default/MaintenanceTemplate.php index e95ae46dbf..90f98f97f0 100644 --- a/Themes/default/MaintenanceTemplate.php +++ b/Themes/default/MaintenanceTemplate.php @@ -36,16 +36,17 @@ public static function header(): void