wp/wp-admin/includes/class-wp-filesystem-base.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
--- a/wp/wp-admin/includes/class-wp-filesystem-base.php	Tue Jun 09 11:14:17 2015 +0000
+++ b/wp/wp-admin/includes/class-wp-filesystem-base.php	Mon Oct 14 17:39:30 2019 +0200
@@ -15,7 +15,6 @@
 	/**
 	 * Whether to display debug data for the connection.
 	 *
-	 * @access public
 	 * @since 2.5.0
 	 * @var bool
 	 */
@@ -32,20 +31,23 @@
 	/**
 	 * The Access method of the current connection, Set automatically.
 	 *
-	 * @access public
 	 * @since 2.5.0
 	 * @var string
 	 */
 	public $method = '';
 
+	/**
+	 * @var WP_Error
+	 */
 	public $errors = null;
 
+	/**
+	 */
 	public $options = array();
 
 	/**
 	 * Return the path on the remote filesystem of ABSPATH.
 	 *
-	 * @access public
 	 * @since 2.7.0
 	 *
 	 * @return string The location of the remote path.
@@ -61,7 +63,6 @@
 	/**
 	 * Return the path on the remote filesystem of WP_CONTENT_DIR.
 	 *
-	 * @access public
 	 * @since 2.7.0
 	 *
 	 * @return string The location of the remote path.
@@ -73,7 +74,6 @@
 	/**
 	 * Return the path on the remote filesystem of WP_PLUGIN_DIR.
 	 *
-	 * @access public
 	 * @since 2.7.0
 	 *
 	 * @return string The location of the remote path.
@@ -85,7 +85,6 @@
 	/**
 	 * Return the path on the remote filesystem of the Themes Directory.
 	 *
-	 * @access public
 	 * @since 2.7.0
 	 *
 	 * @param string $theme The Theme stylesheet or template for the directory.
@@ -104,7 +103,6 @@
 	/**
 	 * Return the path on the remote filesystem of WP_LANG_DIR.
 	 *
-	 * @access public
 	 * @since 3.2.0
 	 *
 	 * @return string The location of the remote path.
@@ -116,7 +114,6 @@
 	/**
 	 * Locate a folder on the remote filesystem.
 	 *
-	 * @access public
 	 * @since 2.5.0
 	 * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() instead.
 	 * @see WP_Filesystem::abspath()
@@ -131,7 +128,7 @@
 	 * @return string The location of the remote path.
 	 */
 	public function find_base_dir( $base = '.', $echo = false ) {
-		_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
+		_deprecated_function(__FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
 		$this->verbose = $echo;
 		return $this->abspath();
 	}
@@ -139,7 +136,6 @@
 	/**
 	 * Locate a folder on the remote filesystem.
 	 *
-	 * @access public
 	 * @since 2.5.0
 	 * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
 	 * @see WP_Filesystem::abspath()
@@ -153,7 +149,7 @@
 	 * @return string The location of the remote path.
 	 */
 	public function get_base_dir( $base = '.', $echo = false ) {
-		_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
+		_deprecated_function(__FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
 		$this->verbose = $echo;
 		return $this->abspath();
 	}
@@ -164,14 +160,12 @@
 	 * Assumes that on Windows systems, Stripping off the Drive
 	 * letter is OK Sanitizes \\ to / in windows filepaths.
 	 *
-	 * @access public
 	 * @since 2.7.0
 	 *
 	 * @param string $folder the folder to locate.
 	 * @return string|false The location of the remote path, false on failure.
 	 */
 	public function find_folder( $folder ) {
-
 		if ( isset( $this->cache[ $folder ] ) )
 			return $this->cache[ $folder ];
 
@@ -244,8 +238,10 @@
 
 		$folder = untrailingslashit($folder);
 
-		if ( $this->verbose )
-			printf( "\n" . __('Looking for %1$s in %2$s') . "<br/>\n", $folder, $base );
+		if ( $this->verbose ) {
+			/* translators: 1: folder to locate, 2: folder to start searching from */
+			printf( "\n" . __( 'Looking for %1$s in %2$s' ) . "<br/>\n", $folder, $base );
+		}
 
 		$folder_parts = explode('/', $folder);
 		$folder_part_keys = array_keys( $folder_parts );
@@ -269,8 +265,10 @@
 
 				// Let's try that folder:
 				$newdir = trailingslashit(path_join($base, $key));
-				if ( $this->verbose )
-					printf( "\n" . __('Changing to %s') . "<br/>\n", $newdir );
+				if ( $this->verbose ) {
+					/* translators: %s: directory name */
+					printf( "\n" . __( 'Changing to %s' ) . "<br/>\n", $newdir );
+				}
 
 				// Only search for the remaining path tokens in the directory, not the full path again.
 				$newfolder = implode( '/', array_slice( $folder_parts, $index + 1 ) );
@@ -279,10 +277,13 @@
 			}
 		}
 
-		// Only check this as a last resort, to prevent locating the incorrect install. All above procedures will fail quickly if this is the right branch to take.
+		// Only check this as a last resort, to prevent locating the incorrect install.
+		// All above procedures will fail quickly if this is the right branch to take.
 		if (isset( $files[ $last_path ] ) ) {
-			if ( $this->verbose )
-				printf( "\n" . __('Found %s') . "<br/>\n",  $base . $last_path );
+			if ( $this->verbose ) {
+				/* translators: %s: directory name */
+				printf( "\n" . __( 'Found %s' ) . "<br/>\n",  $base . $last_path );
+			}
 			return trailingslashit($base . $last_path);
 		}
 
@@ -302,16 +303,15 @@
 	 *
 	 * From the PHP documentation page for fileperms().
 	 *
-	 * @link http://docs.php.net/fileperms
+	 * @link https://secure.php.net/manual/en/function.fileperms.php
 	 *
-	 * @access public
 	 * @since 2.5.0
 	 *
 	 * @param string $file String filename.
 	 * @return string The *nix-style representation of permissions.
 	 */
 	public function gethchmod( $file ){
-		$perms = $this->getchmod($file);
+		$perms = intval( $this->getchmod( $file ), 8 );
 		if (($perms & 0xC000) == 0xC000) // Socket
 			$info = 's';
 		elseif (($perms & 0xA000) == 0xA000) // Symbolic Link
@@ -353,14 +353,24 @@
 	}
 
 	/**
+	 * Gets the permissions of the specified file or filepath in their octal format
+	 *
+	 * @since 2.5.0
+	 * @param string $file
+	 * @return string the last 3 characters of the octal number
+	 */
+	public function getchmod( $file ) {
+		return '777';
+	}
+
+	/**
 	 * Convert *nix-style file permissions to a octal number.
 	 *
 	 * Converts '-rw-r--r--' to 0644
 	 * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
  	 *
-	 * @link http://docs.php.net/manual/en/function.chmod.php#49614
+	 * @link https://secure.php.net/manual/en/function.chmod.php#49614
 	 *
-	 * @access public
 	 * @since 2.5.0
 	 *
 	 * @param string $mode string The *nix-style file permission.
@@ -421,6 +431,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @return bool True on success or false on failure (always true for WP_Filesystem_Direct).
 	 */
 	public function connect() {
@@ -432,6 +443,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file Name of the file to read.
 	 * @return mixed|bool Returns the read data or false on failure.
 	 */
@@ -444,6 +456,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file Path to the file.
 	 * @return array|bool the file contents in an array or false on failure.
 	 */
@@ -456,6 +469,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file     Remote path to the file where to write the data.
 	 * @param string $contents The data to write.
 	 * @param int    $mode     Optional. The file permissions as octal number, usually 0644.
@@ -470,6 +484,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @return string|bool The current working directory on success, or false on failure.
 	 */
 	public function cwd() {
@@ -481,8 +496,9 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $dir The new current directory.
-	 * @return bool Returns true on success or false on failure.
+	 * @return bool|string
 	 */
 	public function chdir( $dir ) {
 		return false;
@@ -493,10 +509,11 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file      Path to the file.
 	 * @param mixed  $group     A group name or number.
 	 * @param bool   $recursive Optional. If set True changes file group recursively. Defaults to False.
-	 * @return bool Returns true on success or false on failure.
+	 * @return bool|string
 	 */
 	public function chgrp( $file, $group, $recursive = false ) {
 		return false;
@@ -507,10 +524,11 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file      Path to the file.
 	 * @param int    $mode      Optional. The permissions as octal number, usually 0644 for files, 0755 for dirs.
 	 * @param bool   $recursive Optional. If set True changes file group recursively. Defaults to False.
-	 * @return bool Returns true on success or false on failure.
+	 * @return bool|string
 	 */
 	public function chmod( $file, $mode = false, $recursive = false ) {
 		return false;
@@ -521,6 +539,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 * 
 	 * @param string $file Path to the file.
 	 * @return string|bool Username of the user or false on error.
 	 */
@@ -533,6 +552,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file Path to the file.
 	 * @return string|bool The group or false on error.
 	 */
@@ -545,6 +565,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $source      Path to the source file.
 	 * @param string $destination Path to the destination file.
 	 * @param bool   $overwrite   Optional. Whether to overwrite the destination file if it exists.
@@ -562,6 +583,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $source      Path to the source file.
 	 * @param string $destination Path to the destination file.
 	 * @param bool   $overwrite   Optional. Whether to overwrite the destination file if it exists.
@@ -577,6 +599,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file      Path to the file.
 	 * @param bool   $recursive Optional. If set True changes file group recursively. Defaults to False.
 	 *                          Default false.
@@ -593,6 +616,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file Path to file/directory.
 	 * @return bool Whether $file exists or not.
 	 */
@@ -605,6 +629,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file File path.
 	 * @return bool Whether $file is a file.
 	 */
@@ -617,6 +642,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $path Directory path.
 	 * @return bool Whether $path is a directory.
 	 */
@@ -629,6 +655,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file Path to file.
 	 * @return bool Whether $file is readable.
 	 */
@@ -641,6 +668,8 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
+	 * @param string $file Path to file.
 	 * @return bool Whether $file is writable.
 	 */
 	public function is_writable( $file ) {
@@ -652,6 +681,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file Path to file.
 	 * @return int|bool Unix timestamp representing last access time.
 	 */
@@ -664,6 +694,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file Path to file.
 	 * @return int|bool Unix timestamp representing modification time.
 	 */
@@ -676,6 +707,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file Path to file.
 	 * @return int|bool Size of the file in bytes.
 	 */
@@ -690,6 +722,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $file  Path to file.
 	 * @param int    $time  Optional. Modified time to set for file.
 	 *                      Default 0.
@@ -706,6 +739,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $path  Path for new directory.
 	 * @param mixed  $chmod Optional. The permissions as octal number, (or False to skip chmod)
 	 *                      Default false.
@@ -724,6 +758,7 @@
 	 *
 	 * @since 2.5.0
 	 * @abstract
+	 *
 	 * @param string $path      Path to directory.
 	 * @param bool   $recursive Optional. Whether to recursively remove files/directories.
 	 *                          Default false.