Skip to content

Version compare fails due to forced gzip #600

@boppy

Description

@boppy

In

apcu/apc.php

Lines 1111 to 1113 in d720b62

$rss = @file_get_contents("https://pecl.php.net/feeds/pkg_apcu.rss", false, $ctxt);
} else {
$rss = @file_get_contents("https://pecl.php.net/feeds/pkg_apcu.rss");

There is a "simple" file_get_contents, but https://pecl.php.net/ forces gzip-encoding in its answers now.

Verification with curl

curl -svo /dev/null 'https://pecl.php.net/feeds/pkg_apcu.rss'

You'll see that just about 2800 Bytes are received.

Answer (reduced)

> GET /feeds/pkg_apcu.rss HTTP/2
> Host: pecl.php.net
> user-agent: curl/7.76.1
> accept: */*

< HTTP/2 200
< server: myracloud
< date: Mon, 10 Nov 2025 13:37:42 GMT
< content-type: text/xml; charset=utf-8
< content-length: 2826
< set-cookie: PHPSESSID=boppy1gnores5essions; path=/
< expires: Thu, 19 Nov 1981 08:52:00 GMT
< cache-control: no-store, no-cache, must-revalidate
< pragma: no-cache
< vary: accept-encoding
< content-encoding: gzip

Sadly, I cannot get the httpd to just give me the uncompressed source. This doesn't work:

curl -H 'Accept: text/plain' -H 'Accept-Encoding: identity' 'https://pecl.php.net/feeds/pkg_apcu.rss'

Using the --compressed switch on curl does work (curl --compressed 'https://pecl.php.net/feeds/pkg_apcu.rss'), but that's just unzipping the answer...

Possible fix

Just check the returned data for XML. You can make that as deep as you want, but this would work:

            if(!str_starts_with($rss, '<')){
                $rss = gzdecode($rss);
            }

I placed it just between those lines:

apcu/apc.php

Lines 1117 to 1118 in d720b62

} else {
$apcversion = phpversion('apcu');

Possible fix 2

The Works on my machine! 🫣 way would be to always assume the server to answer with compressed content. If that could be assumed, the fix would be easier this way:

$rss = @file_get_contents("compress.zlib://https://pecl.php.net/feeds/pkg_apcu.rss");

After deciding which way to go, I can provide a PR if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions