-
Notifications
You must be signed in to change notification settings - Fork 265
[3.0] Implement File System handler #8801
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
Open
jdarwood007
wants to merge
7
commits into
SimpleMachines:release-3.0
Choose a base branch
from
jdarwood007:fileSystem
base: release-3.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
711ec5d
[3.0] Implement File System handler
jdarwood007 f03747f
Cleanup on upgrade
jdarwood007 58c451e
Some index files
jdarwood007 efb245f
Fix the docblock for changePermissions
jdarwood007 914bf29
Wrong variable
jdarwood007 3c25886
Update admin.js
jdarwood007 b6186ee
Merge branch 'release-3.0' into fileSystem
jdarwood007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <?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 3 | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace SMF\Maintenance\Migration\v3_0; | ||
|
|
||
| use SMF\Config; | ||
| use SMF\Maintenance\Migration\MigrationBase; | ||
|
|
||
| class FileSystemHandler extends MigrationBase | ||
| { | ||
| /******************* | ||
| * Public properties | ||
| *******************/ | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| public string $name = 'Updating settings for File System Handler'; | ||
|
|
||
| /********************* | ||
| * Internal properties | ||
| *********************/ | ||
|
|
||
| private array $renames = [ | ||
| 'package_server' => 'filesystem_server', | ||
| 'package_port' => 'filesystem_port', | ||
| 'package_username' => 'filesystem_username', | ||
| 'package_path' => 'filesystem_path', | ||
| ]; | ||
|
|
||
| /**************** | ||
| * Public methods | ||
| ****************/ | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| public function isCandidate(): bool | ||
| { | ||
| return !empty(Config::$modSettings['package_server']); | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| public function execute(): bool | ||
| { | ||
| $newSettings = []; | ||
|
|
||
| foreach ($this->renames as $oldKey => $newKey) { | ||
| if (!isset(Config::$modSettings[$oldKey])) { | ||
| continue; | ||
| } | ||
|
|
||
| $newSettings[$newKey] = Config::$modSettings[$oldKey]; | ||
| $newSettings[$oldKey] = null; | ||
| } | ||
|
|
||
| // Hold on, do we have a 'ssl://' or 'ftps://' in the server name? | ||
| if (str_starts_with(Config::$modSettings['package_server'], 'ssl://') || str_starts_with(Config::$modSettings['package_server'], 'ftps://')) { | ||
| $server_addr = preg_replace('~^((ft|htt)ps?|ssl)?://~i', '', Config::$modSettings['package_server']); | ||
| $server_addr = strtr($server_addr, ['/' => '', ':' => '', '@' => '']); | ||
|
|
||
| $newSettings['filesystem_server'] = $server_addr; | ||
| $newSettings['filesystem_type'] = 'FtpSSL'; | ||
| } | ||
|
|
||
| Config::updateModSettings($newSettings); | ||
|
|
||
| return true; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regex also matches
://. Is this intentional?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't intended, but I am also now wondering, would it be harmful? Ideally, we strip out any schema from the provided server address.