• Resolved cfoster

    (@cfoster)


    Hi,

    We had to change PHP’s upload_tmp_dir to get around an issue we were having. But this also seems to disable our ability to update WordPress’s core, plugins, etc. because the update routines look for the downloaded files in /tmp. The fix was easy enough:

    define( 'WP_TEMP_DIR', ini_get( 'upload_tmp_dir' ) );

    But this seems like it should be WordPress’s default behaviour (to try to load the update files from PHP’s specified upload directory, not expect they’ll always be in /tmp).

    Hope this helps,
    Colin

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Actually, WordPress uses the temp directory given to it from sys_get_temp_dir() by default. See https://secure.php.net/manual/en/function.sys-get-temp-dir.php.

    If that is not writable, then it does indeed use the value from the upload_tmp_dir in the php.ini file.

    If that is also not writable, then it tries to use the wp-content directory.

    If even that is not writable then it defaults to /tmp/.

    See the get_temp_dir() function in wp-includes/functions.php.

    Thread Starter cfoster

    (@cfoster)

    Thanks Samuel,

    Sorry, I should have walked through get_temp_dir() before posting. (I expected it to be harder to work how these values are set in WordPress’s internals than it was. ?? )

    I’m not sure why I’m seeing a different behaviour at our web host. It seems like defining WP_TEMP_DIR the way we have should have no effect at all, yet we can’t update without it. I’ll put in some logging to figure out what’s going on (and report back if there’s anything interesting).

    -Colin

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Check and see what your sys_temp_dir setting is in the php.ini file. It’s probably /tmp.

    Thread Starter cfoster

    (@cfoster)

    I’m not sure if the web host made a change after my support request but I can now take out our WP_TEMP_DIR setting and updates work fine without it. I guess we’ll see if the problem returns.

    I can see that get_temp_dir() does use the sys_get_temp_dir() (/tmp) even if upload_tmp_dir has been set. Maybe there was a weird setting like /tmp was writable by us, but not readable? Or perhaps the update files were being downloaded to the directory specified by upload_tmp_dir but trying to be read from sys_get_temp_dir()?

    I guess we won’t know for sure unless the “can’t find file” problem problem returns.

    Thanks,
    -Colin

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Suggestion: “Update” should use PHP’s specified upload_tmp_dir, not assume /tmp’ is closed to new replies.