Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Installer and upgrader rewrite #8093

Draft
wants to merge 122 commits into
base: release-3.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
6dc4234
Creates SMF\Db\Schema and descendents
Sesquipedalian Jan 25, 2024
b21fbb1
Adds database schema definition for SMF 2.1 to ./other/Schema
Sesquipedalian Feb 8, 2024
3c6a5b9
Initial replacement of installer logic
jdarwood007 Feb 9, 2024
682dfc6
Update Column.php
Sesquipedalian Feb 9, 2024
6b21c03
Worked on some phpdoc
jdarwood007 Feb 9, 2024
17e47ec
Add more phpdocs
jdarwood007 Feb 9, 2024
425cf52
Rename index to indices to avoid conflicts with index
jdarwood007 Feb 10, 2024
1e52320
DId not mean to send that up, testing for fixing the bug with that.
jdarwood007 Feb 10, 2024
a8ef0db
Reverse some changes that shouldn't have been changed.
jdarwood007 Feb 13, 2024
2fd2007
Reverts some more changes that shouldn't have happened
Sesquipedalian Feb 14, 2024
b1f3c00
Update Sources/Db/Schema/Column.php
Sesquipedalian Feb 14, 2024
452cfad
Some cleanup in install.php
Sesquipedalian Feb 14, 2024
5009f22
Improves code for finding the right dir in Maintenance::getBaseDir()
Sesquipedalian Feb 14, 2024
ebe7161
Started wireframe for upgrades
jdarwood007 Feb 14, 2024
b06abd5
Fixes some accidental reversions of Lang::getTxt() usage
Sesquipedalian Feb 14, 2024
4177e54
More cleanup
Sesquipedalian Feb 14, 2024
1bbace1
Removes unnecessary code duplication
Sesquipedalian Feb 14, 2024
a24873f
Continue on writing wireframe for upgrader
jdarwood007 Feb 15, 2024
db000e9
Work on welcome page
jdarwood007 Feb 20, 2024
fd65aff
Merge branch 'release-3.0' into db_schema
jdarwood007 Feb 20, 2024
e0da08c
Welcome page loads
jdarwood007 Feb 20, 2024
9ad7c21
Get login working, get upgrade options page loading
jdarwood007 Feb 21, 2024
f9c2208
Merge branch 'release-3.0' into db_schema
Sesquipedalian Feb 21, 2024
443e5c4
Updates to fix a few github action issues with the changes.
jdarwood007 Feb 21, 2024
895a7ff
Merge branch 'db_schema' of github.com:Sesquipedalian/SMF into db_schema
jdarwood007 Feb 21, 2024
f864853
Merge branch 'release-3.0' into db_schema
jdarwood007 Feb 25, 2024
f4573f9
Backups work
jdarwood007 Feb 26, 2024
01430b9
Merge branch 'release-3.0' into db_schema
jdarwood007 Feb 26, 2024
632f23c
Merge branch 'release-3.0' into db_schema
Sesquipedalian Feb 29, 2024
d1427d3
Minor fixes in SMF\Maintenance\Tools\Install
Sesquipedalian Feb 29, 2024
120445f
Tidying and documentation in Install and Upgrade tools
Sesquipedalian Feb 29, 2024
4e56499
Typo fix
Sesquipedalian Feb 29, 2024
75d1a8e
Rename Index.php to index.php, part 1
Sesquipedalian Mar 1, 2024
9c524f0
Rename Index.php to index.php, part 2
Sesquipedalian Mar 1, 2024
c8e2ca3
A bit of tidying in upgrade.php
Sesquipedalian Mar 1, 2024
59aad48
Fixes various issues in installer (it works now)
Sesquipedalian Mar 1, 2024
501b9b5
Defines constants before using in upgrade.php
Sesquipedalian Mar 2, 2024
7672349
Decodes JSON data in SMF\Maintenance\Tools\Upgrade::getUpgradeData()
Sesquipedalian Mar 2, 2024
2ad0a99
Replaces getRequiredVersionForPHP() with a simple constant
Sesquipedalian Mar 2, 2024
eadf558
Compares settings to defaults in SMF\Maintenance::isInstalled()
Sesquipedalian Mar 2, 2024
be34eb6
More tidying and documentation
Sesquipedalian Mar 2, 2024
d4391f0
Fixes version checking in Upgrade
Sesquipedalian Mar 2, 2024
d56a9aa
Respect and use $use_old_hashing in Maintenance::loginAdmin()
Sesquipedalian Mar 2, 2024
8d7d87d
Whitespace fixes in Install
Sesquipedalian Mar 2, 2024
a84a4e5
Removes unnecessary Windows check
Sesquipedalian Mar 2, 2024
fd97a09
Removes $initial_columns property in SMF\Db\Schema\Table
Sesquipedalian Mar 2, 2024
c6e4966
Add some migration logic
jdarwood007 Mar 2, 2024
2418284
Minor documentation fixes
Sesquipedalian Mar 2, 2024
61cb192
Add a few more migration steps
jdarwood007 Mar 3, 2024
5f27462
Forgot PHP CS
jdarwood007 Mar 3, 2024
76148b7
Merge branch 'db_schema' of github.com:Sesquipedalian/SMF into db_schema
jdarwood007 Mar 3, 2024
b69ef7b
Add some more migration steps
jdarwood007 Mar 13, 2024
e94d8f0
Compares settings to defaults in Maintenance::isInstalled() (take 2)
Sesquipedalian Mar 17, 2024
270962c
Improves naming and organization consistency in SMF\Maintenance\*
Sesquipedalian Mar 26, 2024
6a30532
Use named and explicitly ordered migration substeps
Sesquipedalian Mar 26, 2024
36bca51
Maintenance language file tweaks
Sesquipedalian Mar 26, 2024
0db28f8
Merge branch 'release-3.0' into db_schema
Sesquipedalian Mar 26, 2024
1156540
Adds use statements that should have been in 6a30532
Sesquipedalian Mar 26, 2024
d2441c4
Add support for renaming columns
jdarwood007 Apr 6, 2024
6cca222
Add some more migrations
jdarwood007 Apr 6, 2024
ec3bce5
Custom Fields logic
jdarwood007 May 5, 2024
a7064e4
Merge branch 'release-3.0' into db_schema
jdarwood007 May 5, 2024
28a61b6
Few more migration steps
jdarwood007 May 5, 2024
4985444
Found a few missing index files
jdarwood007 May 5, 2024
476f0c2
Merge branch 'release-3.0' into db_schema
jdarwood007 Jun 16, 2024
323dc60
More 2.1 migration steps
jdarwood007 Jun 16, 2024
0f1e7f9
PHP-CS-Fixer cleanup
Sesquipedalian Jun 27, 2024
d7dc026
Merge branch 'release-3.0' into 3.0/db_schema
Sesquipedalian Jun 27, 2024
37481cf
Moves methods to add, alter, and drop columns and indices to Table
Sesquipedalian Jun 27, 2024
6be83f1
Renames SMF\Db\Schema\Indices to SMF\Db\Schema\DbIndex
Sesquipedalian Jun 27, 2024
8556a6c
Updates method calls for adding columns, etc.
Sesquipedalian Jun 27, 2024
fb4f62a
Remove ICQ
Sesquipedalian Jun 27, 2024
04ddbaa
Revert "Remove ICQ"
Sesquipedalian Jun 27, 2024
b8c8f9a
Tidying
Sesquipedalian Jun 27, 2024
a71377c
Updates schema and adds migration step for message version column
Sesquipedalian Jun 27, 2024
e91c916
Updates schema and adds migration steps for for calendar table
Sesquipedalian Jun 27, 2024
ad0f3a9
Adds migration step for spoof detector support
Sesquipedalian Jun 27, 2024
dd547a4
Adds migration step for spoof detector support (part 2)
Sesquipedalian Jun 27, 2024
307f1de
Check keys, not values
Sesquipedalian Jun 27, 2024
38ae58a
Avoid false positives when looking for calendar_holidays table
Sesquipedalian Jun 27, 2024
d1bba97
Fixes logic for checking column name in SessionIDs migration step
Sesquipedalian Jun 27, 2024
b76c4fa
Uses Table::getStructure method
Sesquipedalian Jun 27, 2024
57ea9f0
For clarity, renames Table::getStructure to Table::getCurrentStructure
Sesquipedalian Jun 27, 2024
9ac173c
Merge branch 'release-3.0' into db_schema
Sesquipedalian Jun 27, 2024
c88c05c
table::getCurrentStructure does not exist
jdarwood007 Jun 29, 2024
d131395
Added a few more conversions
jdarwood007 Jun 29, 2024
aac35cc
Revert "table::getCurrentStructure does not exist"
Sesquipedalian Jun 29, 2024
8c72dd7
Moves Maintenance out of Sources
Sesquipedalian Jun 29, 2024
67b2a51
Trailing slashes
Sesquipedalian Jun 29, 2024
6b60150
Added more steps
jdarwood007 Jun 30, 2024
c4d8e38
PHP-CS-Fixer fixes
Sesquipedalian Jun 30, 2024
7c9fd41
More code cleanup
Sesquipedalian Jun 30, 2024
90a9342
Added some more sections
jdarwood007 Jun 30, 2024
f23d3db
phpcs
jdarwood007 Jun 30, 2024
556d15b
Fix some schema errors caused by a bad merge
jdarwood007 Jun 30, 2024
08902c8
Typo
jdarwood007 Jun 30, 2024
ba92ea9
Fix 2.1 schema namespace
jdarwood007 Jun 30, 2024
4d1da2b
Migration steps for 2.1 should be using the 2.1 schema
jdarwood007 Jun 30, 2024
80e6ab4
Merge branch 'release-3.0' into db_schema
jdarwood007 Jul 1, 2024
7b410af
Merge branch 'release-3.0' into 3.0/db_schema
Sesquipedalian Jul 1, 2024
1604f24
Move sections converted
jdarwood007 Jul 1, 2024
27eda7d
Merge branch 'release-3.0' into 3.0/db_schema
Sesquipedalian Jul 2, 2024
e877a3b
Convert more sections
jdarwood007 Jul 2, 2024
78ae9c1
Merge branch 'db_schema' of github.com:Sesquipedalian/SMF into db_schema
jdarwood007 Jul 2, 2024
b542f85
Merge branch 'release-3.0' into 3.0/db_schema
Sesquipedalian Jul 3, 2024
b0895c7
Adds PackageVersion to migration steps for 3.0
Sesquipedalian Jul 3, 2024
c65f227
Finish 2.1 upgrade steps
jdarwood007 Jul 3, 2024
c80d5ba
Merge branch 'db_schema' of github.com:Sesquipedalian/SMF into db_schema
jdarwood007 Jul 3, 2024
80cbc33
Deletes files that were accidentally added during merge
Sesquipedalian Jul 4, 2024
68232e7
Merge branch 'release-3.0' into db_schema
jdarwood007 Aug 5, 2024
ac39ae1
Ensure we are outputting debugging information for errors
jdarwood007 Aug 5, 2024
3c63240
Fix some issues preventing the migration steps from progressing
jdarwood007 Aug 5, 2024
05050c6
Some fixes
jdarwood007 Aug 5, 2024
d1f67a0
Some issues preventing the upgrader logic from running, need to reset…
jdarwood007 Aug 6, 2024
b1773a7
Fix errors preventing queries from altering tables, columns and indexes
jdarwood007 Aug 6, 2024
2ad4d70
Some more migration testing
jdarwood007 Aug 6, 2024
eb20a18
PHP cs fixes
jdarwood007 Aug 6, 2024
1b24ba4
More upgrade testing
jdarwood007 Aug 7, 2024
83c228d
More fixes for upgrader
jdarwood007 Aug 7, 2024
5e001bb
How did you get by me.
jdarwood007 Aug 7, 2024
b9d804f
Typo
jdarwood007 Aug 7, 2024
0c09f73
Merge branch 'release-3.0' into db_schema
jdarwood007 Oct 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
!/Languages/en_US/
/Languages/en_US/agreement.txt
Settings.php
!Sources/Db/Schema/*/Settings.php
Settings_bak.php
Settings_org.php
db_last_error.php
Expand Down
424 changes: 254 additions & 170 deletions Languages/en_US/Install.php → Languages/en_US/Maintenance.php

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions Maintenance/Cleanup/CleanupBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines https://www.simplemachines.org
* @copyright 2024 Simple Machines and individual contributors
* @license https://www.simplemachines.org/about/smf/license.php BSD
*
* @version 3.0 Alpha 2
*/

declare(strict_types=1);

namespace SMF\Maintenance\Cleanup;

/**
* Base class for cleanup tasks.
*/
abstract class CleanupBase
{
/*******************
* Public properties
*******************/

/**
* @var string
*
* Name of the cleanup task.
*/
public string $name;

/****************
* Public methods
****************/

/**
* Cleanup task we will execute.
*
* @return bool True if successful (or skipped), false otherwise.
*/
public function execute(): bool
{
return true;
}
}

?>
35 changes: 35 additions & 0 deletions Maintenance/Cleanup/CleanupInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines https://www.simplemachines.org
* @copyright 2024 Simple Machines and individual contributors
* @license https://www.simplemachines.org/about/smf/license.php BSD
*
* @version 3.0 Alpha 2
*/

declare(strict_types=1);

namespace SMF\Maintenance\Cleanup;

/**
* Cleanup Interface, all tools have these methods.
*/
interface CleanupInterface
{
/****************
* Public methods
****************/

/**
* Cleanup task we will execute.
*
* @return bool True if successful (or skipped), false otherwise.
*/
public function execute(): bool;
}

?>
141 changes: 141 additions & 0 deletions Maintenance/Cleanup/CleanupOldFiles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php

/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines https://www.simplemachines.org
* @copyright 2024 Simple Machines and individual contributors
* @license https://www.simplemachines.org/about/smf/license.php BSD
*
* @version 3.0 Alpha 2
*/

declare(strict_types=1);

namespace SMF\Maintenance\Cleanup;

use SMF\Config;

class CleanupOldFiles extends CleanupBase
{
/*******************
* Public properties
*******************/

/**
* {@inheritDoc}
*/
public string $name = 'Cleanup old files';

/*********************
* Internal properties
*********************/

/**
* @var array
*
* List of source files removed in SMF 2.1.
*/
private array $smf21SourceFiles = [
'DumpDatabase.php',
'LockTopic.php',
];

/**
* @var array
*
* List of source files removed in SMF 2.0.
*/
private array $smf20SourceFiles = [
'ModSettings.php',
];

/**
* @var array
*
* List of theme files removed in SMF 1.1.
*/
private array $smf11ThemeFiles = [
'Combat.template.php',
'Modlog.template.php',
'fader.js',
'script.js',
'spellcheck.js',
'xml_board.js',
'xml_topic.js',
];

/****************
* Public methods
****************/

public function execute(): bool
{
$success = true;

foreach ($this->smf11ThemeFiles as $file) {
// This is hard coded, but was originally wrote this way.
if (!$this->deleteFile(basename(SMF_SETTINGS_FILE) . '/Themes/default/' . $file)) {
$success = false;
}
}

foreach ($this->smf20SourceFiles as $file) {
// This is hard coded, but was originally wrote this way.
if (!$this->deleteFile(Config::$sourcedir . '/' . $file)) {
$success = false;
}
}

foreach ($this->smf21SourceFiles as $file) {
// This is hard coded, but was originally wrote this way.
if (!$this->deleteFile(Config::$sourcedir . '/' . $file)) {
$success = false;
}
}

return $success;
}

/******************
* Internal methods
******************/

/**
* Delete a file. Check permissions first, just in case.
*
* @param string $file
*/
private function deleteFile(string $file): bool
{
if (!file_exists($file)) {
return true;
}

// NOW do the writable check...
if (!is_writable($file)) {
@chmod($file, 0755);
}

if (!is_writable($file)) {
// Try 755 and 775 first since 777 doesn't always work and could be a risk...
$chmod_values = [0755, 0775, 0777];

foreach ($chmod_values as $val) {
@chmod($file, $val);

// If it's writable, break out of the loop
if (is_writable($file)) {
break;
}
}

@unlink($file);
}

return !file_exists($file);
}
}

?>
9 changes: 9 additions & 0 deletions Maintenance/Cleanup/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

// Try to handle it with the upper level index.php. (it should know what to do.)
if (file_exists(dirname(__DIR__) . '/index.php'))
include (dirname(__DIR__) . '/index.php');
else
exit;

?>
148 changes: 148 additions & 0 deletions Maintenance/Database/DatabaseInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?php

/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines https://www.simplemachines.org
* @copyright 2024 Simple Machines and individual contributors
* @license https://www.simplemachines.org/about/smf/license.php BSD
*
* @version 3.0 Alpha 2
*/

declare(strict_types=1);

namespace SMF\Maintenance\Database;

/**
* Database Maintenance interface. Additional database logic is performed and set here.
*/
interface DatabaseInterface
{
/****************
* Public methods
****************/

/**
* Fetch the database title.
* @return string
*/
public function getTitle(): string;

/**
* The minimum version that SMF supports for the database.
* @return string
*/
public function getMinimumVersion(): string;

/**
* Get the server version from the server, we must have Config:$db_* defined.
*
* @return string
* When false, the server connection failed or an error occurred.
* Otherwise a string is returned containing the server version.
*/
public function getServerVersion(): bool|string;

/**
* Is this database supported.
*
* @return bool True if we can use this database, false otherwise.
*/
public function isSupported(): bool;

/**
* Skip issuing a select database command.
*
* @return bool When true, we do not select a database.
*/
public function skipSelectDatabase(): bool;

/**
* Default username for a database connection.
*
* @return string
*/
public function getDefaultUser(): string;

/**
* Default password for a database connection.
*
* @return string
*/
public function getDefaultPassword(): string;

/**
* Default host for a database connection.
*
* @return string
*/
public function getDefaultHost(): string;

/**
* Default port for a database connection.
*
* @return int
*/
public function getDefaultPort(): int;

/**
* Default database name for a database connection.
*
* @return string
*/
public function getDefaultName(): string;

/**
* Performs checks to ensure the server is in a sane configuration.
*
* @return bool
*/
public function checkConfiguration(): bool;

/**
* Performs checks to ensure we have proper permissions to the database in order to perform operations.
*
* @return bool
*/
public function hasPermissions(): bool;

/**
* Validate a database prefix.
* When an error occurs, use throw new exception, this will be captured.
*
* @return bool
*/
public function validatePrefix(&$string): bool;

/**
* Checks that the server has the proper support for UTF-8 content.
* When an error occurs, use throw new exception, this will be captured.
*
* @return bool
*/
public function utf8Configured(): bool;

/**
* Perform additional changes to our SQL connection in order to perform commands that are not strict SQL.
*
* @param string $mode The SQL mode we wish to be in, either 'default' or 'strict'.
* @return bool
*/
public function setSqlMode(string $mode = 'default'): bool;

/**
* When an error occurs with a query ran through a wrapper, we send errors here.
*
* @param string $error_msg as returend by the database interfaces call.
* @param string $query Query we ran
* @return mixed
* False if we should not do anything,
* True if we should stop for error.
* Result from a query can also be returned, if we are able to correct the query.
*/
public function processError(string $error_msg, string $query): mixed;
}

?>
Loading