Auto-Update not working


#1

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

(Lukas Winkler) #2

Hi,

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


(Fabian Dellwing) #3

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


#4

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 ||

(Lukas Winkler) #5

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);     


#6

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)

(Lukas Winkler) #7

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.


#8

hm, strange, that works

string(6) "3.5.1 " int(200)

(Fabian Dellwing) #9

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


#10

How can I check that? :smiley:


(Fabian Dellwing) #11

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


(Lukas Winkler) #12

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


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

#14

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

PS: using gentoo-linux