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