WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#5984 closed defect (bug) (fixed)

WordPress should not depend on access to /tmp/

Reported by: hangy Owned by: ryan
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.5
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

In some restricted hosting environments, the user might not be able to write to /tmp/.

As wp-admin/includes/file.php uses that directory directly in download_url() and get_filesystem_method(), some functions like for example automatic updating of plugins do not work under those circumstances.

Alternatives could be to use a temporary directory under wp-content as default or have an option in wp-config.php to change this to another directory.

Attachments (4)

5984.wp-content_tmp.diff (621 bytes) - added by hansengel 6 years ago.
Uses wp-content/tmp as a temporary directory
5984.userConfiguredTempDir.diff (1.1 KB) - added by hansengel 6 years ago.
Allows user to set value of const WPTEMPDIR in wp-config.php
5984.diff (1.2 KB) - added by DD32 6 years ago.
get_temp_dir.diff (1.0 KB) - added by ryan 6 years ago.
get_temp_dir()

Download all attachments as: .zip

Change History (12)

hansengel6 years ago

Uses wp-content/tmp as a temporary directory

hansengel6 years ago

Allows user to set value of const WPTEMPDIR in wp-config.php

comment:1 hansengel6 years ago

  • Keywords has-patch added
  • Owner changed from anonymous to hansengel
  • Status changed from new to assigned

I made a patch for each of the two methods you suggested.

comment:2 DD326 years ago

the user might not be able to write to /tmp/.

Just an extra note on this, The user should allways be able to write to PHP's temporary directory, But, Some server setups are going to be half-arsed anwyay.

If PHP cant write to the specified directory, It'll try to create it in the systems Temp. directory.

DD326 years ago

comment:3 hangy6 years ago

It is true that there will always be weird server setups and also assuming that one can write to sys_get_temp_dir() should be right in most cases. However, WordPress is probably used in the most awkward hosting environments one can think of, thus working around such problems as good as possible sounds pretty important to me. :)

I guess my "vote" would go to DD32's solution with the define renamed to hansengel's WPTEMPDIR. ;) My guess is that it is most likely that some dir in wp-content is writable (installer could check this?) than /tmp/ for all those server setups mentioned above.

While one obviously ditches the features of using a system-managed temporary directory using this approach as the default, it could be the most reliable one, cross-platform thinking. (Any idea how PHP on a Windows server reacts to a "/tmp/" path?)

comment:4 lloydbudd6 years ago

  • Milestone changed from 2.6 to 2.5

comment:5 ryan6 years ago

  • Owner changed from hansengel to ryan
  • Status changed from assigned to new

ryan6 years ago

get_temp_dir()

comment:6 ryan6 years ago

How about a get_temp_dir() function? See patch.

comment:7 technosailor6 years ago

+++1 :)

Get it in. It will help me out on another patch I'm working on - and I encountered this issue today as a result.

comment:8 ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [7058]) get_temp_dir(). fixes #5984

Note: See TracTickets for help on using tickets.