I ran the Upload user picture test locally when debugging another issue, and it failed consistently with a fatal error.

Asked in #drupal-contribute, both Heine and swentel ran the test. Heine's failed (on 5.3), swentel's passed (on 5.2). So this looks like a failure specific to PHP 5.3.

Haven't tried to debug why it's failing yet.

Comments

Damien Tournoud’s picture

Priority: Critical » Major

Our test bots run PHP 5.3, so I doubt this is PHP 5.3 specific.

Damien Tournoud’s picture

Test bot results on PHP 5.3:

Upload user picture (UserPictureTestCase) [User]	89	0	0
catch’s picture

Title: Upload user picture test fails on PHP 5.3 » Upload user picture test fails on some installs

Hmm, maybe the sample was too small.

This is the error both me and Heine got (except I'm not on windows):

" Fatal error: Call to a member function getDirectoryPath() on a non-object in C:\www\core7\modules\image\image.module on line 808"

This is because NULL is getting passed into image_style_url() from user.test itself.

catch’s picture

Grrr, so i had a clean install except for settings.php, which is months old by now, and guess which variable was hardcoded in there:

$conf['user_pictures'] = 0;

Yet another reason to use drush vset. Sorry for the false alarm.

However, unless Heine has the same variable set, that doesn't at all explain why this test failed on his machine, so we should keep this open a bit longer.

Damien Tournoud’s picture

This test works on my Windows test environments too. Not sure what happens here.

Heine’s picture

Title: Upload user picture test fails on some installs » Upload user pictures
Priority: Major » Normal

This is related to the use of C:\Windows\Temp as upload_tmp_dir. IIS_USR doesn't have sufficient rights statting files causing the drupal_realpath->realpath() call in image_gd_get_info's getimagesize() to return FALSE.

In the case of a test, this also prevents building the stream URL, thus later causing the message on getDirectoryPath().

I don't think this is a bug. Leaving open for eyeballs.

Heine’s picture

Title: Upload user pictures » Upload user pictures fails on (IIS) installs with c:\windows\temp as upload_tmp_dir.
Heine’s picture

This might be a PHP issue/bug: http://bugs.php.net/bug.php?id=54110

droplet’s picture

Heine’s picture

No, #1019470: file_directory_temp() fails to set valid temporary directory on Windows is about setting the Drupal temporary directory for tmp://, this issue is about upload_tmp_dir in PHP where uploaded files are stored before they are handled by Drupal and on which realpath causes issues.

KarlShea’s picture

IUSR and IIS_IUSRS both need read/write access to that folder.

teddyboar’s picture

Still the same issues after adding IUSR and IIS_IUSRS with full control. Same even after adding Everyone with full control. Cannot upload any user picture at all atm even if I put upload_tmp_dir inside or outside the www root, or disabling upload_tmp_dir in php.ini, or giving any permission anywhere.
One strange thing; if I try to upload a picture via image fields to a basic page for example, it works. So in general, permissions should be ok, picture formats should be ok (tried a self created png and a heavily customized jpg).
This is what I get at the user pic upload:

Warning: getimagesize(): Filename cannot be empty in image_gd_get_info() (line 349 of C:\inetpub\wwwroot\somesite.hu\modules\system\image.gd.inc).
Warning: getimagesize(): Filename cannot be empty in image_gd_get_info() (line 349 of C:\inetpub\wwwroot\somesite.hu\modules\system\image.gd.inc).
The specified file somepic.jpg could not be uploaded. Only JPEG, PNG and GIF images are allowed.

I have everything on localhost, so feel free to ask me to do any testing (if any needed).
Specs: Drupal7.2, Windows 7 x64 SP1, IIS7.5, PHP5.3.6

marco68’s picture

I also have exactly the same issue of teddyboar, and also exactly the same specs.

teddyboar’s picture

Ok now I have some weird results after done some testing:


-Under Debian with php5.3 the very same picture is working out of box, so non-php-bug confirmed and also no problem with the picture.


-Under IIS I set php.ini's upload_temp_dir to C:\tmp2, but the function realpath(sys_get_temp_dir()) pops up C:\Windows\Temp. Maybe something else configures back to that? No idea atm.
Update: Stupid Web Platform Installer (WebPI) tampered this back, so beware and check for it! Anyway, realpath(sys_get_temp_dir()) still shows C:\Windows\Temp, but the error messages disappeared! Kind of confusion..


-In function image_gd_get_info(), right at getimagesize(drupal_realpath($image->source)) the value of image->source is C:\Windows\Temp\phpxyz.tmp, but drupal_realpath($image->source) shows empty. That's why the error message tells about empty filename it seems.


-variable_get('file_temporary_path') shows C:\tmp what i set before in filesystem configuration. How is that then now?

Heine’s picture

See #10 - this is a PHP setting where files go before they are handled by Drupal.
See #6 for realpath, which return FALSE.

Heine’s picture

Status: Active » Closed (won't fix)

Here's a procmon trace (only where access is denied) for those interested:

9:02:45.3204042	php-cgi.exe	3624	CreateFile	C:\Windows\Temp	ACCESS DENIED	Desired Access: Read Data/List Directory, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, Impersonating: NT AUTHORITY\IUSR
9:02:45.3214656	php-cgi.exe	3624	CreateFile	C:\Windows\Temp	ACCESS DENIED	Desired Access: Read Data/List Directory, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, Impersonating: NT AUTHORITY\IUSR
9:02:45.3571673	php-cgi.exe	3624	CreateFile	C:\Windows\Temp\php1504.tmp	ACCESS DENIED	Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:02:45.3572505	php-cgi.exe	3624	CreateFile	C:\Windows\Temp\php1504.tmp	ACCESS DENIED	Desired Access: Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

This is clearly a server configuration issue hence a won't fix.

Some quick options for local dev sites:

  • Specify another upload_tmp_dir in PHP.ini
  • Setup impersonation
  • Grant at least the List folder contents on temp (translated from another language, not sure what the actual value is) to the IIS user (o r groep).

Better option (for production): get to know more about best practices and reach out to MS on http://groups.drupal.org/drupal-windows.

tomlichaj’s picture

Try adding IIS_WPG with read/write access to the temp folder.

I had a similar permission issue with uploads on IIS 7 and my temp directory on the test server was C:\windows\temp, after adding IIS_WPG to it with those permissions everything worked as expected.