Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 38 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
download_updated_files | |
0.00% |
0 / 38 |
|
0.00% |
0 / 5 |
132 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
check_requirements | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
run | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
42 | |||
get_step_count | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_task_lang_name | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
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\module\update_filesystem\task; |
15 | |
16 | use phpbb\filesystem\filesystem; |
17 | use phpbb\install\exception\jump_to_restart_point_exception; |
18 | use phpbb\install\exception\user_interaction_required_exception; |
19 | use phpbb\install\helper\config; |
20 | use phpbb\install\helper\iohandler\iohandler_interface; |
21 | use phpbb\install\task_base; |
22 | |
23 | class download_updated_files extends task_base |
24 | { |
25 | /** |
26 | * @var config |
27 | */ |
28 | protected $installer_config; |
29 | |
30 | /** |
31 | * @var filesystem |
32 | */ |
33 | protected $filesystem; |
34 | |
35 | /** |
36 | * @var iohandler_interface |
37 | */ |
38 | protected $iohandler; |
39 | |
40 | /** |
41 | * Constructor |
42 | * |
43 | * @param config $config |
44 | * @param iohandler_interface $iohandler |
45 | * @param filesystem $filesystem |
46 | */ |
47 | public function __construct(config $config, iohandler_interface $iohandler, filesystem $filesystem) |
48 | { |
49 | $this->installer_config = $config; |
50 | $this->iohandler = $iohandler; |
51 | $this->filesystem = $filesystem; |
52 | |
53 | parent::__construct(false); |
54 | } |
55 | |
56 | /** |
57 | * {@inheritdoc} |
58 | */ |
59 | public function check_requirements() |
60 | { |
61 | return $this->installer_config->get('do_update_files', false) |
62 | && $this->installer_config->get('file_update_method', '') === 'compression'; |
63 | } |
64 | |
65 | /** |
66 | * {@inheritdoc} |
67 | */ |
68 | public function run() |
69 | { |
70 | if ($this->iohandler->get_input('database_update_submit', false)) |
71 | { |
72 | // Remove archive |
73 | $this->filesystem->remove( |
74 | $this->installer_config->get('update_file_archive', null) |
75 | ); |
76 | |
77 | $this->installer_config->set('update_file_archive', null); |
78 | } |
79 | else if ($this->iohandler->get_input('update_recheck_files_submit', false)) |
80 | { |
81 | $this->installer_config->set('file_updater_elem_progress', ''); |
82 | $this->installer_config->set('update_files', array()); |
83 | throw new jump_to_restart_point_exception('check_update_files'); |
84 | } |
85 | else |
86 | { |
87 | $file_update_info = $this->installer_config->get('update_files', array()); |
88 | |
89 | // Display download box only if the archive won't be empty |
90 | $display_download_link = !empty($file_update_info) && !(isset($file_update_info['delete']) && count($file_update_info) == 1); |
91 | if ($display_download_link) |
92 | { |
93 | // Render download box |
94 | $this->iohandler->add_download_link( |
95 | 'phpbb_installer_update_file_download', |
96 | 'DOWNLOAD_UPDATE_METHOD', |
97 | 'DOWNLOAD_UPDATE_METHOD_EXPLAIN' |
98 | ); |
99 | } |
100 | |
101 | // Add form to continue update |
102 | $this->iohandler->add_user_form_group('UPDATE_CONTINUE_UPDATE_PROCESS', array( |
103 | 'update_recheck_files_submit' => array( |
104 | 'label' => 'UPDATE_RECHECK_UPDATE_FILES', |
105 | 'type' => 'submit', |
106 | 'is_secondary' => empty($file_update_info), |
107 | ), |
108 | 'database_update_submit' => array( |
109 | 'label' => 'UPDATE_CONTINUE_UPDATE_PROCESS', |
110 | 'type' => 'submit', |
111 | 'disabled' => $display_download_link, |
112 | ), |
113 | )); |
114 | |
115 | throw new user_interaction_required_exception(); |
116 | } |
117 | } |
118 | |
119 | /** |
120 | * {@inheritdoc} |
121 | */ |
122 | public static function get_step_count() |
123 | { |
124 | return 0; |
125 | } |
126 | |
127 | /** |
128 | * {@inheritdoc} |
129 | */ |
130 | public function get_task_lang_name() |
131 | { |
132 | return ''; |
133 | } |
134 | } |