Auto-Update not working

Hi, I have Matomo version 3.3.0 installed on my OVH Server.

But Matomo tells me I have the current version installed.

I edited the UpdateCheck.php like this:

private static function getLatestAvailableVersionNumber()
    {
        $releaseChannels = StaticContainer::get('\Piwik\Plugin\ReleaseChannels');
        $channel = $releaseChannels->getActiveReleaseChannel();
        $url = $channel->getUrlToCheckForLatestAvailableVersion();

        try {
            $latestVersion = Http::sendHttpRequest($url, self::SOCKET_TIMEOUT);
        } catch (\Exception $e) {
            // e.g., disable_functions = fsockopen; allow_url_open = Off
            $latestVersion = '';
        }
echo 'TEST: Latest Version |' . $latestVersion . '|';
        return $latestVersion;
    }

And it returns an empty string :confused:

I can ping api.matomo.org and curl returns:

curl "http://api.matomo.org/1.0/getLatestVersion/?piwik_version=3.3.0&php_version=7.1.16&mysql_version=5.5.5&release_channel=latest_stable&url=https%3A%2F%2Fstats.domain.com%2Findex.php&trigger=CoreHome&timezone=Europe%2FBerlin"
3.5.0

Hi,

Can you try echoing $url (or using var_dump($url);)?

This sounds a lot like: Matomo should throw an error if the request to api.matomo.org fails · Issue #12724 · matomo-org/matomo · GitHub

1 Like

var_dump($url); returns:

string(226) "http://api.matomo.org/1.0/getLatestVersion/?piwik_version=3.3.0&php_version=7.1.16&mysql_version=5.5.5&release_channel=latest_stable&url=https%3A%2F%2Fstats.somedomain.com%2Findex.php&trigger=CoreHome&timezone=Europe%2FBerlin"

echo 'TEST: Latest Version |' . $latestVersion . '|'; returns:

TEST: Latest Version ||

Hi,

That’s weird. And a cli curl is also working?

Can you try making the HTTP request in PHP like this and check what you get?

<?php
// create curl resource
$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, "example.com");

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
var_dump(curl_exec($ch));

var_dump(curl_getinfo($ch, CURLINFO_HTTP_CODE));

// close curl resource to free up system resources
curl_close($ch);     

returned 500 internal server error…

"PHP message: PHP Parse error:  syntax error, unexpected ';', expecting ',' or ')' in /var/www/localhost/htdocs/piwik/core/Updatecurltest.php on line 14"

So, I removed one ;

<?php
// create curl resource
$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, "api.matomo.org");

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
var_dump(curl_exec($ch));

var_dump(curl_getinfo($ch, CURLINFO_HTTP_CODE));

// close curl resource to free up system resources
curl_close($ch);

this returns:

string(0) "" int(200)

Hi,

Indeed, there was a ; too much.

Sorry, but I meant using the full http://api.matomo.org/1.0/getLatestVersion/?piwik_version=3.3.0&php_version=7.1.16&mysql_version=5.5.5&release_channel=latest_stable&url=https%3A%2F%2Fstats.somedomain.com%2Findex.php&trigger=CoreHome&timezone=Europe%2FBerlin URL.

hm, strange, that works

string(6) "3.5.1 " int(200)

Could you check if he goes into the catch? That would explain why it is empty.

1 Like

How can I check that? :smiley:

Add an error_log($e->getMessage()) to the catch and look into the PHP log.

1 Like

Or add var_dump($e->getMessage()); and check the browser.

"curl_exec: Resolving timed out after 2000 milliseconds. Hostname requested was: api.matomo.org"

rofl… I did perl-cleaner --reallyall and restarted nginx + php-fpm and now it works …

PS: using gentoo-linux