Ticket #5984 (closed defect: fixed)

Opened 7 months ago

Last modified 6 months ago

WordPress should not depend on access to /tmp/

Reported by: hangy Assigned to: ryan
Priority: normal Milestone: 2.5
Component: Administration Version: 2.5
Severity: normal Keywords: has-patch
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

5984.wp-content_tmp.diff (0.6 kB) - added by hansengel on 02/24/08 22:59:17.
Uses wp-content/tmp as a temporary directory
5984.userConfiguredTempDir.diff (1.1 kB) - added by hansengel on 02/24/08 23:03:37.
Allows user to set value of const WPTEMPDIR in wp-config.php
5984.diff (1.2 kB) - added by DD32 on 02/24/08 23:55:23.
get_temp_dir.diff (1.0 kB) - added by ryan on 02/27/08 00:12:18.
get_temp_dir()

Change History

02/24/08 22:59:17 changed by hansengel

  • attachment 5984.wp-content_tmp.diff added.

Uses wp-content/tmp as a temporary directory

02/24/08 23:03:37 changed by hansengel

  • attachment 5984.userConfiguredTempDir.diff added.

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

02/24/08 23:05:57 changed by hansengel

  • keywords set to has-patch.
  • owner changed from anonymous to hansengel.
  • status changed from new to assigned.

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

02/24/08 23:44:14 changed by DD32

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.

02/24/08 23:55:23 changed by DD32

  • attachment 5984.diff added.

02/25/08 18:30:49 changed by hangy

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?)

02/25/08 19:41:35 changed by lloydbudd

  • milestone changed from 2.6 to 2.5.

02/26/08 08:38:33 changed by ryan

  • owner changed from hansengel to ryan.
  • status changed from assigned to new.

02/27/08 00:12:18 changed by ryan

  • attachment get_temp_dir.diff added.

get_temp_dir()

02/27/08 00:12:41 changed by ryan

How about a get_temp_dir() function? See patch.

02/27/08 00:28:21 changed by technosailor

+++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.

02/27/08 00:47:16 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

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