Skip to content

Commit

Permalink
Code Modernization: Remove conditional use of stream_get_contents()
Browse files Browse the repository at this point in the history
… PHP function.

The function was introduced in PHP 5.0.0. Now that the minimum version of PHP required by WordPress is 5.6.20, these conditions are no longer needed.

Props jrf.
Fixes #48091.
Built from https://develop.svn.wordpress.org/trunk@47584


git-svn-id: http://core.svn.wordpress.org/trunk@47359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
SergeyBiryukov committed Apr 15, 2020
1 parent bb2c019 commit 4e13efa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
15 changes: 2 additions & 13 deletions wp-admin/includes/class-wp-filesystem-ssh2.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @contrib http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/ - Installation Notes
*
* Complie libssh2 (Note: Only 0.14 is officaly working with PHP 5.2.6+ right now, But many users have found the latest versions work)
* Compile libssh2 (Note: Only 0.14 is officaly working with PHP 5.2.6+ right now, But many users have found the latest versions work)
*
* cd /usr/src
* wget https://www.libssh2.org/download/libssh2-0.14.tar.gz
Expand All @@ -26,7 +26,7 @@
* Restart Apache!
* Check phpinfo() streams to confirm that: ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp exist.
*
* Note: as of WordPress 2.8, This utilises the PHP5+ function 'stream_get_contents'
* Note: As of WordPress 2.8, this utilises the PHP5+ function `stream_get_contents()`.
*
* @since 2.7.0
*
Expand Down Expand Up @@ -69,17 +69,6 @@ public function __construct( $opt = '' ) {
$this->errors->add( 'no_ssh2_ext', __( 'The ssh2 PHP extension is not available' ) );
return;
}
if ( ! function_exists( 'stream_get_contents' ) ) {
$this->errors->add(
'ssh2_php_requirement',
sprintf(
/* translators: %s: stream_get_contents() */
__( 'The ssh2 PHP extension is available, however, we require the PHP5 function %s' ),
'<code>stream_get_contents()</code>'
)
);
return;
}

// Set defaults:
if ( empty( $opt['port'] ) ) {
Expand Down
4 changes: 2 additions & 2 deletions wp-admin/includes/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_f
}
}

if ( ! $method && isset( $args['connection_type'] ) && 'ssh' == $args['connection_type'] && extension_loaded( 'ssh2' ) && function_exists( 'stream_get_contents' ) ) {
if ( ! $method && isset( $args['connection_type'] ) && 'ssh' == $args['connection_type'] && extension_loaded( 'ssh2' ) ) {
$method = 'ssh2';
}
if ( ! $method && extension_loaded( 'ftp' ) ) {
Expand Down Expand Up @@ -2108,7 +2108,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
if ( extension_loaded( 'ftp' ) ) { // Only this supports FTPS.
$types['ftps'] = __( 'FTPS (SSL)' );
}
if ( extension_loaded( 'ssh2' ) && function_exists( 'stream_get_contents' ) ) {
if ( extension_loaded( 'ssh2' ) ) {
$types['ssh'] = __( 'SSH2' );
}

Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-47583';
$wp_version = '5.5-alpha-47584';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit 4e13efa

Please sign in to comment.