[wp-trac] [WordPress Trac] #31616: Splitting request_filesystem_credentials into separate functions

WordPress Trac noreply at wordpress.org
Fri Mar 13 20:30:56 UTC 2015


#31616: Splitting request_filesystem_credentials into separate functions
---------------------------------------+------------------
 Reporter:  jipmoors                   |       Owner:
     Type:  enhancement                |      Status:  new
 Priority:  normal                     |   Milestone:  4.2
Component:  Filesystem API             |     Version:
 Severity:  normal                     |  Resolution:
 Keywords:  shiny-updates needs-patch  |     Focuses:
---------------------------------------+------------------

Comment (by jipmoors):

 '''Use case'''

 To check what we have and what might be needed:

 {{{
 $type = get_filesystem_method();
 $credentials = get_filesystem_credentials( $some_url, $type );

 // check if the credentials are sufficient for specified type:
 if ( ! usable_filesystem_credentials( $credentials, $type ) ) {
   // more input is needed
   request_filesystem_credentials_form( $some_url, $credentials, $type,
 $error );
 } else {
   // use $credentials in any way you like; spit it out to javascript or
 modify files
 }
 }}}

 |||| $some_url is needed to keep legacy code running, the filter that
 allows for credential-injection by plugins might need this value for
 checking ||||

 * Type: 'direct'
 `$credentials` : true
 `usable_filesystem_credentials( true, 'direct' )`: true

 * Type: 'ssh':
 `$credentials` : holds private/public key if set via DEFINE or `$_POST`
 `usable_filesystem_credentials( $credentials, 'ssh' )` : true if both
 private & public keys are present

 * Type: other:
 `$credentials` : holds username, hostname, port
 `usable_filesystem_credentials( $credentials, 'ftp' )` : false without
 password

 The original code had these types for checking valid credentials, I could
 not think of any methods that would need something other than username,
 password and hostname but if these exist they are easily added inside the
 `usable_filesystem_credentials` function.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31616#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list