Last modified: 2012-06-13 19:34:12 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T26985, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 24985 - Clarify temp directory
Clarify temp directory
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Low enhancement (vote)
: ---
Assigned To: Mark A. Hershberger
:
: 27959 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-30 16:22 UTC by Chad H.
Modified: 2012-06-13 19:34 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Chad H. 2010-08-30 16:22:19 UTC
Currently we have two ways of getting a temporary directory.

$wgTmpDirectory - used by Math and diffing-related code.

wfTempDir() used by lots of other things, mostly with tempnam()

I tend to prefer the latter (less config is good). Should maybe look at merging the two.
Comment 1 Brion Vibber 2011-01-02 20:42:29 UTC
Hmm, taking a quick look...

$wgTmpDirectory is initialized to "$wgUploadDirectory/tmp", which gives it two important properties:
* it's in a writable place that's shared across requests
* nobody else is going to mess with those files
* it's probably on the same filesystem as our upload area
* it may be exposed to the web

wfTempDir() is an abstraction to find the system-specific temporary directory (traditionally /tmp on Unixy systems). This has a few other properties:
* files here might disappear when we're not looking (eg on reboot)
* there may be lots of other files not under our control, but other users probably can't mess with our files as long as names are unique
* less likely to be on same filesystem as our upload area

It looks like most code using $wgTmpDirectory doesn't actually need to keep the files around across requests or anything, though. (Math and URL uploading take advantage of being able to rename the output file atomically from the temp location to the final location, but it's probably not a performance-critical path and isn't guaranteed since the dir is renamable.)

Some things that it looks like *do* need/want to keep files across requests:
* DBABagOStuff (cache implementation; meant for dev use)
* .... I think that might be it.

Math and easytimeline also don't clean up their temp files very nicely, which is lazy.
Comment 2 Roan Kattouw 2011-01-02 21:17:34 UTC
(In reply to comment #1)
> It looks like most code using $wgTmpDirectory doesn't actually need to keep the
> files around across requests or anything, though. (Math and URL uploading take
> advantage of being able to rename the output file atomically from the temp
> location to the final location, but it's probably not a performance-critical
> path and isn't guaranteed since the dir is renamable.)
> 
UploadStash needs this (ability to keep temp files across requests and read them), although it uses the filerepo abstraction so I'm not sure if $wgTmpDirectory is used directly or if the repo uses $wgUploadDirectory/tmp regardless of what $wgTmpDirectory is. I think it's the latter, but it's been too long since I touched it.

> Math and easytimeline also don't clean up their temp files very nicely, which
> is lazy.
Neither does UploadStash, BTW. Maybe we should supply a cron job for this; we're gonna need it on the cluster for UploadStash anyway, once it's used more often.
Comment 3 Bryan Tong Minh 2011-03-09 14:23:15 UTC
*** Bug 27959 has been marked as a duplicate of this bug. ***
Comment 4 Antoine "hashar" Musso (WMF) 2012-06-12 15:36:54 UTC
See also https://gerrit.wikimedia.org/r/#/c/8996/
Comment 5 Antoine "hashar" Musso (WMF) 2012-06-12 15:37:25 UTC
Assigning bug to Mark since he is writing the patch :-D
Comment 6 Antoine "hashar" Musso (WMF) 2012-06-13 19:34:12 UTC
Merged in master (commit 99fdc6e )

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links