WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

According to the Wordpress Codes FS_METHOD = 'direct' is chosen when appropriate.

(Primary Preference) "direct" forces it to use Direct File I/O requests from within PHP, this is fraught with opening up security issues on poorly configured hosts, This is chosen automatically when appropriate.


What is the criteria to be appropriate?

share|improve this question
up vote 5 down vote accepted

Here's the code from wp-admin/includes/file.php:

if ( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
    if ( !$context )
        $context = WP_CONTENT_DIR;

    // If the directory doesn't exist (wp-content/languages) then use the parent directory
    // as we'll create it.
    if ( WP_LANG_DIR == $context && ! is_dir( $context ) )
        $context = dirname( $context );

    $context = trailingslashit($context);
    $temp_file_name = $context . 'temp-write-test-' . time();
    $temp_handle = @fopen($temp_file_name, 'w');
    if ( $temp_handle ) {
        if ( getmyuid() == @fileowner($temp_file_name) )
            $method = 'direct';

The test appears to be

  1. Can we create a temporary file in the wp-content or wp-content/languages directory?
  2. Does that file belong to the current Unix user, i.e. there's no setuid on wp-content?

It only executes this check if we didn't specify an FS_METHOD ourselves, and if the necessary filesystem calls to check #2 are available. The temporary file is cleaned up afterwards.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.