]> git.mxchange.org Git - friendica.git/blob - src/Worker/CheckVersion.php
wrapping up 2019.12
[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 use Friendica\Core\Logger;
12 use Friendica\Database\DBA;
13 use Friendica\Util\Network;
14
15 /**
16  * @brief check the git repository VERSION file and save the version to the DB
17  *
18  * Checking the upstream version is optional (opt-in) and can be done to either
19  * the master or the develop branch in the repository.
20  */
21 class CheckVersion
22 {
23         public static function execute()
24         {
25                 Logger::log('checkversion: start');
26
27                 $checkurl = Config::get('system', 'check_new_version_url', 'none');
28
29                 switch ($checkurl) {
30                         case 'master':
31                                 $checked_url = 'https://raw.githubusercontent.com/friendica/friendica/master/VERSION';
32                                 break;
33                         case 'develop':
34                                 $checked_url = 'https://raw.githubusercontent.com/friendica/friendica/develop/VERSION';
35                                 break;
36                         default:
37                                 // don't check
38                                 return;
39                 }
40                 Logger::log("Checking VERSION from: ".$checked_url, Logger::DEBUG);
41
42                 // fetch the VERSION file
43                 $gitversion = DBA::escape(trim(Network::fetchUrl($checked_url)));
44                 Logger::log("Upstream VERSION is: ".$gitversion, Logger::DEBUG);
45
46                 Config::set('system', 'git_friendica_version', $gitversion);
47
48                 Logger::log('checkversion: end');
49
50                 return;
51         }
52 }