Make WordPress Core


Ignore:
Timestamp:
12/04/2008 09:58:46 PM (18 years ago)
Author:
ryan
Message:

Allow override of default file permissions with FS_CHMOD_DIR and FS_CHMOD_FILE. Props DD32. see #8478

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/file.php

    r10048 r10050  
    499499                        for ( $i = $i + 1; $i <= count($path); $i++ ) {
    500500                                $tmppath = implode('/', array_slice($path, 0, $i) );
    501                                 if ( ! $fs->mkdir($tmppath, 0755) )
     501                                if ( ! $fs->mkdir($tmppath, FS_CHMOD_DIR) )
    502502                                        return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath);
    503503                        }
     
    517517                                for ( $i = $i + 1; $i <= count($path); $i++ ) { //< count() no file component please.
    518518                                        $tmppath = $to . implode('/', array_slice($path, 0, $i) );
    519                                         if ( ! $fs->is_dir($tmppath) && ! $fs->mkdir($tmppath, 0755) )
     519                                        if ( ! $fs->is_dir($tmppath) && ! $fs->mkdir($tmppath, FS_CHMOD_DIR) )
    520520                                                return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath);
    521521                                }
     
    528528                        if ( !$fs->put_contents( $to . $file['filename'], $file['content']) )
    529529                                return new WP_Error('copy_failed', __('Could not copy file'), $to . $file['filename']);
    530                         $fs->chmod($to . $file['filename'], 0644);
     530                        $fs->chmod($to . $file['filename'], FS_CHMOD_FILE);
    531531                }
    532532        }
     
    559559                                        return new WP_Error('copy_failed', __('Could not copy file'), $to . $filename);
    560560                        }
    561                         $wp_filesystem->chmod($to . $filename, 0644);
     561                        $wp_filesystem->chmod($to . $filename, FS_CHMOD_FILE);
    562562                } elseif ( 'd' == $fileinfo['type'] ) {
    563563                        if ( !$wp_filesystem->is_dir($to . $filename) ) {
    564                                 if ( !$wp_filesystem->mkdir($to . $filename, 0755) )
     564                                if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
    565565                                        return new WP_Error('mkdir_failed', __('Could not create directory'), $to . $filename);
    566566                        }
     
    604604        if ( !$wp_filesystem->connect() )
    605605                return false; //There was an erorr connecting to the server.
     606
     607        // Set the permission constants if not already set.
     608        if ( ! defined('FS_CHMOD_DIR') )
     609                define('FS_CHMOD_DIR', 0755 );
     610        if ( ! defined('FS_CHMOD_FILE') )
     611                define('FS_CHMOD_FILE', 0644 );
    606612
    607613        return true;
Note: See TracChangeset for help on using the changeset viewer.