@mattab opened this Issue on January 11th 2011 Member

On a fresh trunk import on Windows (and also on my old trunk working copy) the test serveStaticFile.test.php fails with the following errors:

serveStaticFile.test.php
Fail: Test_Piwik_serveStaticFile -> test_deflateCompression -> at [D:\piwik\svn\piwik-trunk\tests\core\Piwik\serveStaticFile.test.php line 300]
Fail: Test_Piwik_serveStaticFile -> test_deflateCompression -> Equal expectation fails as [Boolean: false] does not match [String: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ultricies tempor vulputate. Donec justo enim, cursus sit amet commodo non, egestas nec metus. Ut accumsan enim purus. Vivamus sodales su...] at [D:\piwik\svn\piwik-trunk\tests\core\Piwik\serveStaticFile.test.php line 303]
Exception: Test_Piwik_serveStaticFile -> test_deflateCompression -> Unexpected PHP error [file_get_contents(D:\piwik\svn\piwik-trunk/tmp/assets/lipsum.txt.deflate) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory] severity [E_WARNING] in [D:\piwik\svn\piwik-trunk\tests\core\Piwik\serveStaticFile.test.php line 303]
Fail: Test_Piwik_serveStaticFile -> test_gzipCompression -> at [D:\piwik\svn\piwik-trunk\tests\core\Piwik\serveStaticFile.test.php line 333]
Exception: Test_Piwik_serveStaticFile -> test_compressionCache -> Unexpected PHP error [filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for D:\piwik\svn\piwik-trunk/tmp/assets/lipsum.txt.deflate] severity [E_WARNING] in [D:\piwik\svn\piwik-trunk\tests\core\Piwik\serveStaticFile.test.php line 359]
Exception: Test_Piwik_serveStaticFile -> test_compressionCache -> Unexpected PHP error [filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for D:\piwik\svn\piwik-trunk/tmp/assets/lipsum.txt.deflate] severity [E_WARNING] in [D:\piwik\svn\piwik-trunk\tests\core\Piwik\serveStaticFile.test.php line 373]
Fail: Test_Piwik_serveStaticFile -> test_compressionCacheInvalidation -> Not equal expectation fails [Boolean: false] matches at [D:\piwik\svn\piwik-trunk\tests\core\Piwik\serveStaticFile.test.php line 416]
Exception: Test_Piwik_serveStaticFile -> test_compressionCacheInvalidation -> Unexpected PHP error [filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for D:\piwik\svn\piwik-trunk/tmp/assets/lipsum.txt.deflate] severity [E_WARNING] in [D:\piwik\svn\piwik-trunk\tests\core\Piwik\serveStaticFile.test.php line 400]
Exception: Test_Piwik_serveStaticFile -> test_compressionCacheInvalidation -> Unexpected PHP error [filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for D:\piwik\svn\piwik-trunk/tmp/assets/lipsum.txt.deflate] severity [E_WARNING] in [D:\piwik\svn\piwik-trunk\tests\core\Piwik\serveStaticFile.test.php line 416]
1/1 test cases complete: 16 passes, 4 fails and 5 exceptions.
Time elapsed: 2.153s - Current date: 2011-01-11 05:27:23 - Memory delta: 256.2 K

Maybe this is a bug, or maybe just a test bug.

@mattab commented on January 11th 2011 Member

Attachment: output of the test on windows php 5.2.6
serveStaticFile.test.php.png

@julienmoumne commented on January 11th 2011 Member

I've set up two php versions via CGI : 5.1.3 and 5.3.5.

The error is only reproducible on 5.1.3.

The error occurs while using CURL and gzdeflate().

In both PHP version I had a look at response headers set by CURL using :

$fullResponse = curl_exec($curlHandle);
$responseInfo = curl_getinfo($curlHandle);
print_r($responseInfo);

In PHP 5.1.3 I get :

Array ( 
    [url] => http://piwik-trunk/tests/core/Piwik/serveStaticFile.test.php?fileMode=staticServerMode&serverMode=testFile 
    [content_type] => text/plain 
    [http_code] => 200 
    [header_size] => 367 
    [request_size] => 163 
    [filetime] => -1 
    [ssl_verify_result] => 0 
    [redirect_count] => 0 
    [total_time] => 0.044 
    [namelookup_time] => 0 
    [connect_time] => 0 
    [pretransfer_time] => 0 
    [size_upload] => 0 
    [size_download] => 3816 
    [speed_download] => 86727 
    [speed_upload] => 0 
    [download_content_length] => 4886 
    [upload_content_length] => 0 
    [starttransfer_time] => 0.044 
    [redirect_time] => 0
)

In PHP 5.3.5 I get

Array ( 
    [url] => http://piwik-trunk/tests/core/Piwik/serveStaticFile.test.php?fileMode=staticServerMode&serverMode=testFile 
    [content_type] => text/plain 
    [http_code] => 200 
    [header_size] => 367 
    [request_size] => 163 
    [filetime] => -1 
    [ssl_verify_result] => 0 
    [redirect_count] => 0 
    [total_time] => 2.558 
    [namelookup_time] => 0 
    [connect_time] => 0 
    [pretransfer_time] => 0 
    [size_upload] => 0 
    [size_download] => 4886 
    [speed_download] => 1910 
    [speed_upload] => 0 
    [download_content_length] => 4886 
    [upload_content_length] => 0 
    [starttransfer_time] => 2.558 
    [redirect_time] => 0 
    [certinfo] => Array ( )
) 

As you can see, in 5.1.3 [and download_content_length do not match. It means the response has not been correctly decoded and "" is returned by CURL when requesting for the payload.

Using gzcompress instead of gzdeflate resolves the issue.

However, gzdeflate as been used for IE compatibility.

Not sure what to do next..

@robocoder commented on January 12th 2011 Contributor

Interesting. On 5.1.3 and 5.3.5, I get the same result returned by both.

This is my config.nice for 5.1.3:

#! /bin/sh
#
# Created by configure

CFLAGS='-DCURLOPT_FTPASCII=CURLOPT_TRANSFERTEXT -DCURLOPT_PASSWDFUNCTION=0 -DCUR
LOPT_PASSWDDATA=0 -Dgptr=char*' \
'./configure' \
'--with-mysqli' \
'--with-pdo-mysql' \
'--with-zlib' \
'--with-gd' \
'--with-curl' \
'--enable-memory-limit' \
'--enable-mbstring' \
"$@"
@julienmoumne commented on January 13th 2011 Member

I tried setting for 5.1.3

curl_setopt($curlHandle,CURLOPT_FTPASCII,CURLOPT_TRANSFERTEXT);
curl_setopt($curlHandle,CURLOPT_PASSWDFUNCTION,0);

to match your config.

no change in behavior.

@robocoder commented on January 13th 2011 Contributor

Well, all_tests.php on trunk r3724 works for me on Windows Vista, IIS with php 5.2.14 (installed via IIS WebPI).

I don't think we should be surprised if some of the unit tests break with older php5 versions on Windows. For example, the changelog for 5.3.0 says:

  • Added Windows support for stat(), touch(), filemtime(), filesize() and related functions.
@mattab commented on January 13th 2011 Member

if you guys cant find a fix and can confirm it works on newer versions of php, shall we 'wontfix' ?

@mattab commented on January 20th 2011 Member

Julien, on 5.3.5 on apache tests pass for you?

If there is indeed a bug on windows in some php versions, what are the consequences on the asset manager logic? what will fail to work? My box with the test failing seems to deal well with merged assets.

Please confirm and/or mark as wontfix

@julienmoumne commented on January 21st 2011 Member

As far as I understood, it's only the unit test that will fail in very specific box configurations. The serveStaticFile method logic should not be affected by this. Marking as wontfix.

This Issue was closed on January 21st 2011
Powered by GitHub Issue Mirror