]> git.mxchange.org Git - friendica.git/blob - src/Worker/CheckVersion.php
Now there are four more ...
[friendica.git] / src / Worker / CheckVersion.php
1 <?php
2
3 /**
4  * @file src/Worker/CheckVersion.php
5  *
6  * @brief save Friendica upstream version to the DB
7  **/
8 namespace Friendica\Worker;
9
10 use Friendica\Core\Config;
11
12 /**
13  * @brief check the git repository VERSION file and save the version to the DB
14  *
15  * Checking the upstream version is optional (opt-in) and can be done to either
16  * the master or the develop branch in the repository.
17  */
18 class CheckVersion {
19         public static function execute() {
20                 global $a;
21
22                 logger('checkversion: start');
23
24                 $checkurl = Config::get('system', 'check_new_version_url', 'none');
25
26                 switch ($checkurl) {
27                         case 'master':
28                                 $checked_url = 'https://raw.githubusercontent.com/friendica/friendica/master/VERSION';
29                                 break;
30                         case 'develop':
31                                 $checked_url = 'https://raw.githubusercontent.com/friendica/friendica/develop/VERSION';
32                                 break;
33                         default:
34                                 // don't check
35                                 return;
36                 }
37                 logger("Checking VERSION from: ".$checked_url, LOGGER_DEBUG);
38
39                 // fetch the VERSION file
40                 $gitversion = dbesc(trim(fetch_url($checked_url)));
41                 logger("Upstream VERSION is: ".$gitversion, LOGGER_DEBUG);
42
43                 Config::set('system', 'git_friendica_version', $gitversion);
44
45                 logger('checkversion: end');
46
47                 return;
48         }
49 }