[wp-trac] [WordPress Trac] #58541: WP_Filesystem_SSH2:put_contents (and others) does not check for $sftp_link to be up
WordPress Trac
noreply at wordpress.org
Tue Jun 20 03:03:30 UTC 2023
#58541: WP_Filesystem_SSH2:put_contents (and others) does not check for $sftp_link
to be up
--------------------------------------+-----------------------------
Reporter: jobst | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Filesystem API | Version:
Severity: major | Resolution:
Keywords: needs-patch dev-feedback | Focuses:
--------------------------------------+-----------------------------
Comment (by jobst):
I will make a patch file based on the code below for all the required
parameters to be placed INTO the constructor of the class
'WP_Filesystem_SSH2', so it will actually function when NO parameter (or
too few) are passed when calling 'WP_Filesystem();'.
This code will make sure that ANY parameters passed WILL survive, and only
iff a parameters was NOT passed I'll fetch them from
'request_filesystem_credentials'.
{{{
// go and get what we can find in DB and/or wp-config.php
// this will set any KEY not found to '', so we can test for that
$ajaxURL = admin_url('admin-ajax.php');
$credentials = request_filesystem_credentials($ajaxURL, 'ssh', false,
ABSPATH )
// now fill ALL the credentials with the data required for a proper
connection
// I am just giving ONE example
if ( empty( $opt['hostname'] ) ) {
if ( $credentials['hostname'] == '' ) {
// by all means create/raise an error here, that's fine
$this->errors->add( 'empty_hostname', __( 'SSH2 credentials
(hostname) are required!' ) );
} else {
// assign what has been found in the DB and/or wp-config.php
$this->options['hostname'] = $credentials['hostname'];
}
} else {
$this->options['hostname'] = $opt['hostname'];
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58541#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list