|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69292 Download links are not wget compatible
Submitted: 2015-03-24 20:33 UTC Modified: 2018-03-15 14:16 UTC
Avg. Score:3.2 ± 0.4
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: scott at perturb dot org Assigned:
Status: Wont fix Package: Website problem
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-03-24 20:33 UTC] scott at perturb dot org
I download the PHP release .tar.bz2 files from the all the time to do testing. 99% of the time I navigate to the download page on my local machine, and copy and paste the URL in to a terminal on the server I want to compile on. The download URLs look like this: which I then feed to wget:

    $ wget

    --2015-03-24 08:58:06--
    Resolving (
    ** [snipped] **
    HTTP request sent, awaiting response... 200 OK
    Length: 11396771 (11M) [application/octet-stream]
    Saving to: ‘mirror’

    mirror                100%[========================>]  10.87M  1.22MB/s   in 11s    

    2015-03-24 08:58:17 (1006 KB/s) - ‘mirror’ saved [11396771/11396771]

Note that the file that gets written to disk is "mirror" and not php-5.3.29.tar.bz2. It's a minor annoyance, but it seems really easily fixed.

Test script:

Expected result:
When I wget a URL from a server, it should have the right file name. 

Actual result:
Wget uses the part of the URL after the last "/" as the output filename. Arguably this is a bug in Wget, but it's also something we can easily work around on the php-web side.

Someone already thought of this, because there is mention of wget style download links in the code:

If we remap the filename in the download URL to be at the END, it should solve this problem.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-24 23:29 UTC]
In my opinion that is not a bug, but rather something that might be
improved, if at all -- what's wrong with something like:

    mv mirror $FILE
 [2015-03-24 23:48 UTC] scott at perturb dot org
It's more of an annoyance than a bug. I've worked around it in the past, using the method you describe. Or even more simply:

wget -o /tmp/php.tar.bz2

But I *always* forget the first time, and have to repeat it with the work around. It would be nice if it "just worked (tm)". Someone had the idea of making the download links wget compatible, because of the comment in the file:

If we just re-ordered the elements in the download link, it would be wget compatible with minimal changes.
 [2015-03-25 00:01 UTC] scott at perturb dot org
Looking at the code in, we're not doing anything before we send the status_header(302) and then give them the real URL. I assumed we were logging the hit or something like that, thus the download needed to hit PHP.

Since ALL we're doing is a redirect to the tar file, is there a reason the download links can't be directly to the file on the file system, and not be handled by PHP?
 [2015-03-25 14:34 UTC]
scott: The location of the binary is "implementation detail", which is why we have php in front of it to verify.

Reordering the components in the url would break boatload of scripts out there, so thats hardly a realistic option.

Does wget *always* use the last component of the url for its filename, or can that be fixed somehow?
 [2015-03-25 15:23 UTC]
> Does wget *always* use the last component of the url for its
> filename, or can that be fixed somehow?

wget has an --output-document option[1], which should be usable in
this case.

[1] <>
 [2015-03-25 22:32 UTC] scott at perturb dot org
I went ahead and setup my own mirror, and checked out web-php from Github to try tackling this myself. I think I got it working, and created a pull-request here:
 [2018-03-15 14:16 UTC]
-Status: Open +Status: Wont fix
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 09 01:01:27 2023 UTC