Passed
Push — develop ( 07e082...75d3b1 )
by Портнов
12:59
created

UpdateConfigsUpToVer20220140::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/*
3
 * MikoPBX - free phone system for small business
4
 * Copyright (C) 2017-2020 Alexey Portnov and Nikolay Beketov
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with this program.
17
 * If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
namespace MikoPBX\Core\System\Upgrade\Releases;
21
22
use MikoPBX\Core\System\Upgrade\UpgradeSystemConfigInterface;
23
use MikoPBX\Core\System\Util;
24
use Phalcon\Di\Injectable;
25
use Phalcon\Config as ConfigAlias;
26
27
class UpdateConfigsUpToVer20220140 extends Injectable implements UpgradeSystemConfigInterface
28
{
29
  	public const PBX_VERSION = '2022.1.40';
30
31
	private ConfigAlias $config;
32
    private bool $isLiveCD;
33
34
	/**
35
     * Class constructor.
36
     */
37
    public function __construct()
38
    {
39
        $this->config = $this->getDI()->getShared('config');
40
        $this->isLiveCD      = file_exists('/offload/livecd');
41
    }
42
43
    /**
44
     * https://github.com/mikopbx/Core/issues/269
45
     */
46
    public function processUpdate():void
47
    {
48
        if ($this->isLiveCD) {
49
            return;
50
        }
51
        $dbFilename = $this->config->path('eventsLogDatabase.dbfile');
52
        if(file_exists($dbFilename)) {
53
            shell_exec(Util::which('rm')." -rf '$dbFilename'");
54
        }
55
    }
56
}