GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 53c71b...87c8b3 )
by James
15:15 queued 05:54
created

app/Http/Controllers/Admin/UpdateController.php (2 issues)

1
<?php
2
/**
3
 * UpdateController.php
4
 * Copyright (c) 2017 [email protected]
5
 *
6
 * This file is part of Firefly III.
7
 *
8
 * Firefly III is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * Firefly III is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
/** @noinspection PhpMethodParametersCountMismatchInspection */
22
declare(strict_types=1);
23
24
namespace FireflyIII\Http\Controllers\Admin;
25
26
use FireflyConfig;
27
use FireflyIII\Helpers\Update\UpdateTrait;
28
use FireflyIII\Http\Controllers\Controller;
29
use FireflyIII\Http\Middleware\IsDemoUser;
30
use FireflyIII\Http\Middleware\IsSandStormUser;
31
use Illuminate\Http\Request;
32
33
/**
34
 * Class HomeController.
35
 */
36
class UpdateController extends Controller
37
{
38
    use UpdateTrait;
39
40
    /**
41
     * ConfigurationController constructor.
42
     */
43
    public function __construct()
44
    {
45
        parent::__construct();
46
        $this->middleware(
47
            function ($request, $next) {
48
                app('view')->share('title', (string)trans('firefly.administration'));
49
                app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
50
51
                return $next($request);
52
            }
53
        );
54
        $this->middleware(IsDemoUser::class)->except(['index']);
55
        $this->middleware(IsSandStormUser::class)->except(['index']);
56
    }
57
58
    /**
59
     * Show page with update options.
60
     *
61
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
62
     * @throws \Psr\Container\NotFoundExceptionInterface
63
     * @throws \Psr\Container\ContainerExceptionInterface
64
     */
65
    public function index()
66
    {
67
        $subTitle     = (string)trans('firefly.update_check_title');
68
        $subTitleIcon = 'fa-star';
69
        $permission   = app('fireflyconfig')->get('permission_update_check', -1);
70
        $selected     = $permission->data;
71
        $options      = [
72
            -1 => (string)trans('firefly.updates_ask_me_later'),
73
            0  => (string)trans('firefly.updates_do_not_check'),
74
            1  => (string)trans('firefly.updates_enable_check'),
75
        ];
76
77
        return view('admin.update.index', compact('subTitle', 'subTitleIcon', 'selected', 'options'));
78
    }
79
80
    /**
81
     * Post new settings.
82
     *
83
     * @param Request $request
84
     *
85
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
86
     */
87
    public function post(Request $request)
88
    {
89
        $checkForUpdates = (int)$request->get('check_for_updates');
90
        FireflyConfig::set('permission_update_check', $checkForUpdates);
0 ignored issues
show
Bug Best Practice introduced by
The method FireflyIII\Support\Facades\FireflyConfig::set() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

90
        FireflyConfig::/** @scrutinizer ignore-call */ 
91
                       set('permission_update_check', $checkForUpdates);
Loading history...
91
        FireflyConfig::set('last_update_check', time());
92
        session()->flash('success', (string)trans('firefly.configuration_updated'));
93
94
        return redirect(route('admin.update-check'));
95
    }
96
97
    /**
98
     * Does a manual update check.
99
     */
100
    public function updateCheck()
101
    {
102
        $latestRelease = $this->getLatestRelease();
103
        $versionCheck  = $this->versionCheck($latestRelease);
104
        $resultString  = $this->parseResult($versionCheck, $latestRelease);
105
106
        if (0 !== $versionCheck && '' !== $resultString) {
107
            // flash info
108
            session()->flash('info', $resultString);
109
        }
110
        FireflyConfig::set('last_update_check', time());
0 ignored issues
show
Bug Best Practice introduced by
The method FireflyIII\Support\Facades\FireflyConfig::set() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

110
        FireflyConfig::/** @scrutinizer ignore-call */ 
111
                       set('last_update_check', time());
Loading history...
111
112
        return response()->json(['result' => $resultString]);
113
    }
114
}
115