Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
update_helper | |
0.00% |
0 / 20 |
|
0.00% |
0 / 5 |
72 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
get_path_to_new_update_files | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_path_to_old_update_files | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
include_file | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
phpbb_version_compare | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\install\helper; |
15 | |
16 | /** |
17 | * General helper functionality for the updater |
18 | */ |
19 | class update_helper |
20 | { |
21 | /** |
22 | * @var string |
23 | */ |
24 | protected $path_to_new_files; |
25 | |
26 | /** |
27 | * @var string |
28 | */ |
29 | protected $path_to_old_files; |
30 | |
31 | /** |
32 | * @var string |
33 | */ |
34 | protected $phpbb_root_path; |
35 | |
36 | /** |
37 | * Constructor |
38 | * |
39 | * @param string $phpbb_root_path |
40 | */ |
41 | public function __construct($phpbb_root_path) |
42 | { |
43 | $this->phpbb_root_path = $phpbb_root_path; |
44 | $this->path_to_new_files = $phpbb_root_path . 'install/update/new/'; |
45 | $this->path_to_old_files = $phpbb_root_path . 'install/update/old/'; |
46 | } |
47 | |
48 | /** |
49 | * Returns path to new update files |
50 | * |
51 | * @return string |
52 | */ |
53 | public function get_path_to_new_update_files() |
54 | { |
55 | return $this->path_to_new_files; |
56 | } |
57 | |
58 | /** |
59 | * Returns path to new update files |
60 | * |
61 | * @return string |
62 | */ |
63 | public function get_path_to_old_update_files() |
64 | { |
65 | return $this->path_to_old_files; |
66 | } |
67 | |
68 | /** |
69 | * Includes the updated file if available |
70 | * |
71 | * @param string $filename Path to the file relative to phpBB root path |
72 | */ |
73 | public function include_file($filename) |
74 | { |
75 | if (is_file($this->path_to_new_files . $filename)) |
76 | { |
77 | include_once($this->path_to_new_files . $filename); |
78 | } |
79 | else if (is_file($this->phpbb_root_path . $filename)) |
80 | { |
81 | include_once($this->phpbb_root_path . $filename); |
82 | } |
83 | } |
84 | |
85 | /** |
86 | * Customized version_compare() |
87 | * |
88 | * @param string $version_number1 |
89 | * @param string $version_number2 |
90 | * @param string|null $operator |
91 | * @return int|bool The returned value is identical to the PHP build-in function version_compare() |
92 | * @psalm-suppress InvalidNullableReturnType, NullableReturnStatement |
93 | */ |
94 | public function phpbb_version_compare($version_number1, $version_number2, $operator = null) |
95 | { |
96 | if ($operator === null) |
97 | { |
98 | $result = version_compare( |
99 | str_replace('rc', 'RC', strtolower($version_number1)), |
100 | str_replace('rc', 'RC', strtolower($version_number2)) |
101 | ); |
102 | } |
103 | else |
104 | { |
105 | $result = version_compare( |
106 | str_replace('rc', 'RC', strtolower($version_number1)), |
107 | str_replace('rc', 'RC', strtolower($version_number2)), |
108 | $operator |
109 | ); |
110 | } |
111 | |
112 | return $result; |
113 | } |
114 | } |