WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/31/2009 09:08:03 PM (11 years ago)
Author:
azaozz
Message:

Test writability of ABSPATH when upgrading core or WP_PLUGIN_DIR when installing/updating themes and plugins, fixes #9936

File:
1 edited

Legend:

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

    r11495 r11499  
    584584 * @return unknown
    585585 */
    586 function WP_Filesystem( $args = false ) {
     586function WP_Filesystem( $args = false, $context = false ) {
    587587    global $wp_filesystem;
    588588
    589589    require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
    590590
    591     $method = get_filesystem_method($args);
     591    $method = get_filesystem_method($args, $context);
    592592
    593593    if ( ! $method )
     
    626626 *
    627627 * @param unknown_type $args
    628  * @return unknown
    629  */
    630 function get_filesystem_method($args = array()) {
     628 * @param string $context Full path to the directory that is tested for being writable.
     629 * @return unknown
     630 */
     631function get_filesystem_method($args = array(), $context = false) {
    631632    $method = defined('FS_METHOD') ? FS_METHOD : false; //Please ensure that this is either 'direct', 'ssh', 'ftpext' or 'ftpsockets'
    632633
    633634    if( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
    634         $temp_file_name = ABSPATH . '.' . time();
     635        if ( !$context )
     636            $context = WP_CONTENT_DIR;
     637        $context = trailingslashit($context);
     638        $temp_file_name = $context . '.write-test-' . time();
    635639        $temp_handle = @fopen($temp_file_name, 'w');
    636640        if ( $temp_handle ) {
     
    658662 * @return unknown
    659663 */
    660 function request_filesystem_credentials($form_post, $type = '', $error = false) {
    661     $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error);
     664function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false) {
     665    $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error, $context);
    662666    if ( '' !== $req_cred )
    663667        return $req_cred;
    664668
    665669    if ( empty($type) )
    666         $type = get_filesystem_method();
     670        $type = get_filesystem_method(array(), $context);
    667671
    668672    if ( 'direct' == $type )
Note: See TracChangeset for help on using the changeset viewer.