-
Notifications
You must be signed in to change notification settings - Fork 264
[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
base: release-3.0
Are you sure you want to change the base?
Conversation
This introduces a file system handler for package manager, bringing in FTPS and SFTP support to our package manager operations. FTPS is handled with PHP ftp library and SFTP is handled with Phpseclib (MIT License). This simplifies and centralizes the logic for determining how to perform file system operations by using the root as a substitution for the boarddir. The test page has been changed from xml supported to json and most of the logic moved into admin.js. The settings page now operates as config vars. Not sure why it wasn't ever this way. The legacy FtpConnection was moved to basically be a wrapper for the new file system caller. I didn't want to remove it as it needs to remain backwards compatible. The code for Maintenance was updated, but since none of our tools yet use it, the logic is only in theory based on matching changes. Additionally, I had no luck getting FTP stuff to work before hand. I made changes until things started to operate. I also tried to support using ssl:// like we did before, but this never worked for me, so I forced the use of the dedicated FTPS logic. If anyone is able to get it to work, we can better identify the file system handlings. Finally, I know there is leagues's file system (MIT License) handler that does FTP(s), SFTP, Webdav and a few others. I thought about using it, but the only additional library I see useful for SMF to support would be webdav. If we want to redirect to using it, then we can.
|
|
||
| // 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']); |
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.
| * @param string $ftp_file The file to CHMOD | ||
| * @return bool Whether or not the operation was successful | ||
| */ | ||
| public function changePermissions(string $filename, string $chmod): bool |
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.
docblock mismatch
Remove debug code.
# Conflicts: # Sources/Maintenance/Tools/ToolsBase.php # Sources/PackageManager/FtpConnection.php # Sources/PackageManager/PackageUtils.php
This introduces a file system handler for package manager, bringing in FTPS and SFTP support to our package manager operations.
FTPS is handled with PHP ftp library and SFTP is handled with Phpseclib (MIT License). This simplifies and centralizes the logic for determining how to perform file system operations by using the root as a substitution for the boarddir.
The test page has been changed from xml supported to json and most of the logic moved into admin.js.
The settings page now operates as config vars. Not sure why it wasn't ever this way.
The legacy FtpConnection was moved to basically be a wrapper for the new file system caller. I didn't want to remove it as it needs to remain backwards compatible.
The code for Maintenance was updated, but since none of our tools yet use it, the logic is only in theory based on matching changes.
Additionally, I had no luck getting FTP stuff to work before hand. I made changes until things started to operate. I also tried to support using ssl:// like we did before, but this never worked for me, so I forced the use of the dedicated FTPS logic. If anyone is able to get it to work, we can better identify the file system handlings.
Finally, I know there is leagues's file system (MIT License) handler that does FTP(s), SFTP, Webdav and a few others. I thought about using it, but the only additional library I see useful for SMF to support would be webdav. If we want to redirect to using it, then we can.
Fixes #5316