update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -8,12 +8,10 @@
|
|||
*/
|
||||
namespace Piwik;
|
||||
|
||||
use Exception;
|
||||
use Piwik\Plugins\SitesManager\API;
|
||||
use Piwik\Container\StaticContainer;
|
||||
|
||||
/**
|
||||
* Class to check if a newer version of Piwik is available
|
||||
*
|
||||
*/
|
||||
class UpdateCheck
|
||||
{
|
||||
|
|
@ -36,7 +34,7 @@ class UpdateCheck
|
|||
*/
|
||||
public static function check($force = false, $interval = null)
|
||||
{
|
||||
if(!self::isAutoUpdateEnabled()) {
|
||||
if (!self::isAutoUpdateEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -51,36 +49,38 @@ class UpdateCheck
|
|||
) {
|
||||
// set the time checked first, so that parallel Piwik requests don't all trigger the http requests
|
||||
Option::set(self::LAST_TIME_CHECKED, time(), $autoLoad = 1);
|
||||
$parameters = array(
|
||||
'piwik_version' => Version::VERSION,
|
||||
'php_version' => PHP_VERSION,
|
||||
'url' => Url::getCurrentUrlWithoutQueryString(),
|
||||
'trigger' => Common::getRequestVar('module', '', 'string'),
|
||||
'timezone' => API::getInstance()->getDefaultTimezone(),
|
||||
);
|
||||
|
||||
$url = Config::getInstance()->General['api_service_url']
|
||||
. '/1.0/getLatestVersion/'
|
||||
. '?' . http_build_query($parameters, '', '&');
|
||||
$timeout = self::SOCKET_TIMEOUT;
|
||||
|
||||
if (@Config::getInstance()->Debug['allow_upgrades_to_beta']) {
|
||||
$url = 'http://builds.piwik.org/LATEST_BETA';
|
||||
}
|
||||
|
||||
try {
|
||||
$latestVersion = Http::sendHttpRequest($url, $timeout);
|
||||
if (!preg_match('~^[0-9][0-9a-zA-Z_.-]*$~D', $latestVersion)) {
|
||||
$latestVersion = '';
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// e.g., disable_functions = fsockopen; allow_url_open = Off
|
||||
$latestVersion = self::getLatestAvailableVersionNumber();
|
||||
$latestVersion = trim((string) $latestVersion);
|
||||
if (!preg_match('~^[0-9][0-9a-zA-Z_.-]*$~D', $latestVersion)) {
|
||||
$latestVersion = '';
|
||||
}
|
||||
|
||||
Option::set(self::LATEST_VERSION, $latestVersion);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest available version number for the currently active release channel. Eg '2.15.0-b4' or '2.15.0'.
|
||||
* Should return a semantic version number in format MAJOR.MINOR.PATCH (http://semver.org/).
|
||||
* Returns an empty string in case one cannot connect to the remote server.
|
||||
* @return string
|
||||
*/
|
||||
private static function getLatestAvailableVersionNumber()
|
||||
{
|
||||
$channel = StaticContainer::get('\Piwik\Plugin\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 = '';
|
||||
}
|
||||
|
||||
return $latestVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest available version number. Does not perform a check whether a later version is available.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue