Advertisement
vartik

class-wp-filesystem-ftpext.php

Oct 17th, 2024
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.91 KB | None | 0 0
  1. --- /var/www/xxx/wp-admin/includes/class-wp-filesystem-ftpext.php.bak       2024-04-22 12:52:45.137057835 +0200
  2. +++ /var/www/xxx/wp-admin/includes/class-wp-filesystem-ftpext.php   2024-10-17 16:31:32.583056600 +0200
  3. @@ -135,6 +135,7 @@
  4.          *                      or if the file couldn't be retrieved.
  5.          */
  6.         public function get_contents( $file ) {
  7. +               if ( ! $this->link ) { return false; } // PHP 8.1 fix
  8.                 $tempfile   = wp_tempnam( $file );
  9.                 $temphandle = fopen( $tempfile, 'w+' );
  10.  
  11. @@ -227,6 +228,7 @@
  12.          * @return string|false The current working directory on success, false on failure.
  13.          */
  14.         public function cwd() {
  15. +               if ( ! $this->link ) { return false; } // PHP 8.1 fix
  16.                 $cwd = ftp_pwd( $this->link );
  17.  
  18.                 if ( $cwd ) {
  19. @@ -425,6 +427,7 @@
  20.          * @return bool Whether $path exists or not.
  21.          */
  22.         public function exists( $path ) {
  23. +               if ( ! $this->link ) { return false; } // PHP 8.1 fix
  24.                 /*
  25.                  * Check for empty path. If ftp_nlist() receives an empty path,
  26.                  * it checks the current working directory and may return true.
  27. @@ -465,6 +468,7 @@
  28.          * @return bool Whether $path is a directory.
  29.          */
  30.         public function is_dir( $path ) {
  31. +               if ( ! $this->link ) { return false; } // PHP 8.1 fix
  32.                 $cwd    = $this->cwd();
  33.                 $result = @ftp_chdir( $this->link, trailingslashit( $path ) );
  34.  
  35. @@ -754,6 +758,7 @@
  36.          * }
  37.          */
  38.         public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
  39. +               if ( ! $this->link ) { return false; } // PHP 8.1 fix
  40.                 if ( $this->is_file( $path ) ) {
  41.                         $limit_file = basename( $path );
  42.                         $path       = dirname( $path ) . '/';
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement