r68955 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68954‎ | r68955 | r68956 >
Date:17:44, 3 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Work on porting WP filesystem abstraction classes
Modified paths:
  • /trunk/extensions/Deployment/includes/Filesystem.php (modified) (history)
  • /trunk/extensions/Deployment/includes/filesystems/DirectFilesystem.php (modified) (history)
  • /trunk/extensions/Deployment/includes/filesystems/FtpFilesystem.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Deployment/includes/filesystems/FtpFilesystem.php
@@ -110,7 +110,7 @@
111111 * @see Filesystem::changeDir
112112 */
113113 public function changeDir( $dir ) {
114 - return @ftp_chdir( $this->connection, $dir );
 114+ return (bool)@ftp_chdir( $this->connection, $dir );
115115 }
116116
117117 /**
@@ -124,7 +124,38 @@
125125 * @see Filesystem::chmod
126126 */
127127 public function chmod( $file, $mode = false, $recursive = false ) {
 128+ // TODO: refactor up?
 129+ if ( !$mode ) {
 130+ if ( $this->isFile( $file ) ) {
 131+ $mode = FS_CHMOD_FILE;
 132+ }
 133+ elseif ( $this->isDir( $file ) ) {
 134+ $mode = FS_CHMOD_DIR;
 135+ }
 136+ else {
 137+ return false;
 138+ }
 139+ }
 140+
 141+ // Not recursive, so just use chmod.
 142+ if ( !$recursive || !$this->isDir( $file ) ) {
 143+ if ( !function_exists( 'ftp_chmod' ) ) {
 144+ return (bool)@ftp_site( $this->connection, sprintf( 'CHMOD %o %s', $mode, $file ) );
 145+ }
 146+ else {
 147+ return (bool)@ftp_chmod( $this->connection, $mode, $file );
 148+ }
 149+ }
 150+
 151+ // Recursive approach required.
 152+ $file = rtrim( $file, '/' ) . '/';
 153+ $files = $this->listDir( $file );
128154
 155+ foreach ( $files as $fileName ) {
 156+ $this->chmod( $file . $fileName, $mode, $recursive );
 157+ }
 158+
 159+ return true;
129160 }
130161
131162 /**
Index: trunk/extensions/Deployment/includes/filesystems/DirectFilesystem.php
@@ -35,7 +35,7 @@
3636 * @see Filesystem::changeDir
3737 */
3838 public function changeDir( $dir ) {
39 - return @chdir( $dir );
 39+ return (bool)@chdir( $dir );
4040 }
4141
4242 /**
@@ -47,7 +47,7 @@
4848 }
4949
5050 // Not recursive, so just use chgrp.
51 - if ( !$recursive || !$this->is_dir($file) ) {
 51+ if ( !$recursive || !$this->isDir( $file ) ) {
5252 return @chgrp( $file, $group );
5353 }
5454
@@ -66,7 +66,33 @@
6767 * @see Filesystem::chmod
6868 */
6969 public function chmod( $file, $mode = false, $recursive = false ) {
 70+ // TODO: refactor up?
 71+ if ( !$mode ) {
 72+ if ( $this->isFile( $file ) ) {
 73+ $mode = FS_CHMOD_FILE;
 74+ }
 75+ elseif ( $this->isDir( $file ) ) {
 76+ $mode = FS_CHMOD_DIR;
 77+ }
 78+ else {
 79+ return false;
 80+ }
 81+ }
 82+
 83+ // Not recursive, so just use chmod.
 84+ if ( !$recursive || !$this->isDir( $file ) ) {
 85+ return (bool)@chmod( $file, $mode );
 86+ }
 87+
 88+ // Recursive approach required.
 89+ $file = rtrim( $file, '/' ) . '/';
 90+ $files = $this->listDir( $file );
7091
 92+ foreach ( $files as $fileName ) {
 93+ $this->chmod( $file . $fileName, $mode, $recursive );
 94+ }
 95+
 96+ return true;
7197 }
7298
7399 /**
Index: trunk/extensions/Deployment/includes/Filesystem.php
@@ -17,6 +17,9 @@
1818 * @defgroup Filesystem Filesystem
1919 */
2020
 21+define('FS_CHMOD_DIR', 0755 );
 22+define('FS_CHMOD_FILE', 0644 );
 23+
2124 /**
2225 * Base class providing a way to access filesystems.
2326 *

Status & tagging log