Ticket #37942: class-wp-filesystem-ssh2.php.patch
File class-wp-filesystem-ssh2.php.patch, 3.0 KB (added by , 8 years ago) |
---|
-
class-wp-filesystem-ssh2.php
old new 162 162 ); 163 163 return false; 164 164 } 165 166 165 return true; 167 166 } 168 167 … … 183 182 */ 184 183 public function sftp_path( $path ) { 185 184 if ( '/' === $path ) { 186 $path = ' /./';185 $path = '.'; 187 186 } 188 187 return 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $path, '/' ); 189 188 } 190 189 191 190 /** 191 * Gets the ssh2.sftp file status 192 * 192 193 * @access public 193 * 194 * 195 * The stream wrapper is no reliably returning status data. ssh2_sftp_stat 196 * reliably returns a status structure. This contains most of the status 197 * data we are checking. It may be worthwhile to cache the stats for a 198 * path as it is common to ask for multiple stats for the same path. 199 * 200 * @since 4.6.0 201 * 202 * @param string $path The File/Directory path on the remote server to stat 203 * @return stat structure for the file or directory 204 */ 205 public function sftp_stat( $path ) { 206 return ssh2_sftp_stat( $this->sftp_link, $path ); 207 } 208 209 /** 210 * @access public 211 * 194 212 * @param string $command 195 213 * @param bool $returnbool 196 214 * @return bool|string … … 350 368 * @return string|false 351 369 */ 352 370 public function owner($file) { 353 $owneruid = @fileowner( $this->sftp_path( $file ) );371 $owneruid = $this->sftp_stat( $file )['uid']; 354 372 if ( ! $owneruid ) 355 373 return false; 356 374 if ( ! function_exists('posix_getpwuid') ) … … 366 384 * @return string 367 385 */ 368 386 public function getchmod($file) { 369 return substr( decoct( @fileperms( $this->sftp_path( $file ) )), -3 );387 return substr( decoct( $this->sftp_stat( $file )['mode'] ), -3 ); 370 388 } 371 389 372 390 /** … … 376 394 * @return string|false 377 395 */ 378 396 public function group($file) { 379 $gid = @filegroup( $this->sftp_path( $file ) );397 $gid = $this->sftp_stat( $file )['gid']; 380 398 if ( ! $gid ) 381 399 return false; 382 400 if ( ! function_exists('posix_getgrgid') ) … … 444 462 * @return bool 445 463 */ 446 464 public function exists($file) { 447 return file_exists( $this->sftp_path( $file ));465 return = $this->sftp_stat( $file ); 448 466 } 449 467 450 468 /** … … 454 472 * @return bool 455 473 */ 456 474 public function is_file($file) { 457 return is_file( $this->sftp_path( $file ) );475 return substr( decoct( $this->sftp_stat( $file )['mode'] ), 0, 1 ) == 1; 458 476 } 459 477 460 478 /** … … 464 482 * @return bool 465 483 */ 466 484 public function is_dir($path) { 467 return is_dir( $this->sftp_path( $path ) );485 return substr( decoct( $this->sftp_stat( $path )['mode'] ), 0, 1 ) == 4; 468 486 } 469 487 470 488 /** … … 495 513 * @return int 496 514 */ 497 515 public function atime($file) { 498 return fileatime( $this->sftp_path( $file ) );516 return $this->sftp_stat( $file )['atime']; 499 517 } 500 518 501 519 /** … … 505 523 * @return int 506 524 */ 507 525 public function mtime($file) { 508 return filemtime( $this->sftp_path( $file ) );526 return $this->sftp_stat( $file )['mtime']; 509 527 } 510 528 511 529 /** … … 515 533 * @return int 516 534 */ 517 535 public function size($file) { 518 return filesize( $this->sftp_path( $file ) );536 return $this->sftp_stat( $file )['size']; 519 537 } 520 538 521 539 /**