r68956 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68955‎ | r68956 | r68957 >
Date:17:57, 3 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Work on porting WP filesystem abstraction classes
Modified paths:
  • /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
@@ -162,7 +162,7 @@
163163 * @see Filesystem::chown
164164 */
165165 public function chown( $file, $owner, $recursive = false ) {
166 -
 166+ return false;
167167 }
168168
169169 /**
Index: trunk/extensions/Deployment/includes/filesystems/DirectFilesystem.php
@@ -99,14 +99,62 @@
100100 * @see Filesystem::chown
101101 */
102102 public function chown( $file, $owner, $recursive = false ) {
 103+ if ( !$this->exists( $file ) ) {
 104+ return false;
 105+ }
103106
 107+ // Not recursive, so just use chown.
 108+ if ( !$recursive || !$this->isDir( $file ) ) {
 109+ return (bool)@chown( $file, $owner );
 110+ }
 111+
 112+ // Recursive approach required.
 113+ $file = rtrim( $file, '/' ) . '/';
 114+ $files = $this->listDir( $file );
 115+
 116+ foreach ( $files as $fileName ) {
 117+ $this->chown( $file . $fileName, $owner, $recursive );
 118+ }
 119+
 120+ return true;
104121 }
105122
106123 /**
107124 * @see Filesystem::delete
108125 */
109126 public function delete( $path, $recursive = false ) {
 127+ if ( empty( $path ) ) {
 128+ return false;
 129+ }
 130+
 131+ // For win32, occasional problems deleteing files otherwise.
 132+ $path = str_replace( '\\', '/', $path );
 133+
 134+ if ( $this->isFile( $path ) ) {
 135+ return (bool)@unlink( $path );
 136+ }
 137+
 138+ if ( !$recursive && $this->isDir( $path ) ) {
 139+ return (bool)@rmdir( $path );
 140+ }
 141+
 142+ // Recursive approach required.
 143+ $path = rtrim( $path, '/' ) . '/';
 144+ $files = $this->listDir( $path );
110145
 146+ $success = true;
 147+
 148+ foreach ( $files as $fileName ) {
 149+ if ( !$this->delete( $path . $fileName, $owner, $recursive ) ) {
 150+ $success = false;
 151+ }
 152+ }
 153+
 154+ if ( $success && file_exists( $path ) && !@rmdir( $path ) ) {
 155+ $success = false;
 156+ }
 157+
 158+ return $success;
111159 }
112160
113161 /**

Status & tagging log