mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-24 03:49:10 -04:00
ALPHA 3.0.2a
This commit is contained in:
@@ -24,7 +24,7 @@ class GitHubChecker implements Checker
|
||||
*/
|
||||
public function isLatest()
|
||||
{
|
||||
return version_compare(Shell::VERSION, $this->getLatest(), '>=');
|
||||
return \version_compare(Shell::VERSION, $this->getLatest(), '>=');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,22 +68,22 @@ class GitHubChecker implements Checker
|
||||
*/
|
||||
public function fetchLatestRelease()
|
||||
{
|
||||
$context = stream_context_create([
|
||||
$context = \stream_context_create([
|
||||
'http' => [
|
||||
'user_agent' => 'PsySH/' . Shell::VERSION,
|
||||
'timeout' => 3,
|
||||
],
|
||||
]);
|
||||
|
||||
set_error_handler(function () {
|
||||
\set_error_handler(function () {
|
||||
// Just ignore all errors with this. The checker will throw an exception
|
||||
// if it doesn't work :)
|
||||
});
|
||||
|
||||
$result = @file_get_contents(self::URL, false, $context);
|
||||
$result = @\file_get_contents(self::URL, false, $context);
|
||||
|
||||
restore_error_handler();
|
||||
\restore_error_handler();
|
||||
|
||||
return json_decode($result);
|
||||
return \json_decode($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
|
||||
namespace Psy\VersionUpdater;
|
||||
|
||||
use Psy\Shell;
|
||||
|
||||
class IntervalChecker extends GitHubChecker
|
||||
{
|
||||
private $cacheFile;
|
||||
@@ -27,7 +25,7 @@ class IntervalChecker extends GitHubChecker
|
||||
public function fetchLatestRelease()
|
||||
{
|
||||
// Read the cached file
|
||||
$cached = json_decode(@file_get_contents($this->cacheFile, false));
|
||||
$cached = \json_decode(@\file_get_contents($this->cacheFile, false));
|
||||
if ($cached && isset($cached->last_check) && isset($cached->release)) {
|
||||
$now = new \DateTime();
|
||||
$lastCheck = new \DateTime($cached->last_check);
|
||||
@@ -60,10 +58,10 @@ class IntervalChecker extends GitHubChecker
|
||||
private function updateCache($release)
|
||||
{
|
||||
$data = [
|
||||
'last_check' => date(DATE_ATOM),
|
||||
'last_check' => \date(DATE_ATOM),
|
||||
'release' => $release,
|
||||
];
|
||||
|
||||
file_put_contents($this->cacheFile, json_encode($data));
|
||||
\file_put_contents($this->cacheFile, \json_encode($data));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user