Page MenuHomePhabricator

Parsertests: Temp dir creation fails on Windows
Closed, ResolvedPublic

Description

Author: Michael.Keppler

Description:
The temporary directory in the parsertests is named so that it can only be
created on Unix Systems, but fails on Windows. Attached patch creates a
temporary directory on Windows only using the TMPDIR environment variable.


Version: 1.5.x
Severity: minor
Platform: PC

Details

Reference
bz2178

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:30 PM
bzimport set Reference to bz2178.
bzimport added a subscriber: Unknown Object (MLST).

Michael.Keppler wrote:

patch for CVS HEAD

Attached:

Perhaps it would be cleaner to use TMPDIR if it's set, otherwise default to /tmp.
Is there any particular reason to specially try to detect Windows?

Michael.Keppler wrote:

Uuum. I reinvestigated the problem and saw the root cause is completely
different. mkdir() does not create recursive directories. On Windows the /tmp
directory does not exist and therefor the creation of /tmp/mwParser... fails. So
my patch worked with pure luck because on my system the TMPDIR variable is empty.
A better solution might be to simply create the /tmp directory, if it does not
exist. On Windows that will create a sub directory /tmp in the mediawiki
installation directory, if no TMPDIR is set. On my system this solution worked fine.

Michael.Keppler wrote:

Err. Another typo. :/
I meant to suggest creating the "tmp" directory, not the "/tmp" directory, e.g.
running "mkdir('tmp')".

In general I'd prefer that the parser tests not mess with the file structure inside the wiki's own area.

My XP box has TMP and TEMP environment variables set, but not TMPDIR. TMPDIR seems to be the thing on *nix, though; a
quick check through each? A wfTmpDir() might be in order to encapsulate this... I would have used tmpnam() but that
creates the file, and we want a directory so it's a bit silly.

Added wfTempDir() to check those environment vars; that should do it. Please confirm it actually works on Windows. :)

Michael.Keppler wrote:

I can confirm that it works on Windows now. And the group table issue is also
gone. Thanks.

zigger wrote:

Re-opening, as there is a typo in wfTmpDir() in HEAD, which causes the same
problem to occur if TMPDIR is not set. Patch to follow.

zigger wrote:

HEAD patch for GlobalFunctions.php

Attached: