Skip to content

Commit 20a96b1

Browse files
authored
Merge pull request #146 from iMattPro/updates
A handful of minor updates
2 parents 2864f30 + 6927c85 commit 20a96b1

32 files changed

Lines changed: 635 additions & 95 deletions

.github/codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fixes:
2+
- "/phpBB3/phpBB/ext/phpbb/ideas/::"

.github/workflows/tests.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ jobs:
113113
db: "mysql:5.7"
114114
- php: '7.2'
115115
db: "mysql:5.7"
116+
COVERAGE: 1
117+
db_alias: "mysql:5.7 with Coverage"
116118
- php: '7.3'
117119
db: "mysql:5.7"
118120
- php: '7.4'
@@ -173,12 +175,21 @@ jobs:
173175
echo "db=$db" >> $GITHUB_OUTPUT
174176
175177
- name: Setup PHP
178+
if: ${{ matrix.COVERAGE != 1 }}
176179
uses: shivammathur/setup-php@v2
177180
with:
178181
php-version: ${{ matrix.php }}
179182
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap
180183
coverage: none
181184

185+
- name: Setup PHP with Coverage
186+
if: ${{ matrix.COVERAGE == 1 }}
187+
uses: shivammathur/setup-php@v2
188+
with:
189+
php-version: ${{ matrix.php }}
190+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap
191+
coverage: xdebug
192+
182193
- name: Setup environment for phpBB
183194
env:
184195
DB: ${{steps.database-type.outputs.db}}
@@ -195,14 +206,36 @@ jobs:
195206
working-directory: ./phpBB3
196207

197208
- name: Setup PHPUnit files
198-
run: mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_
209+
env:
210+
DB: ${{steps.database-type.outputs.db}}
211+
COVERAGE: ${{ matrix.COVERAGE != 1 && '0' || '1' }}
212+
run: |
213+
if [ $COVERAGE == '1' ]
214+
then
215+
sed -n '1h;1!H;${;g;s/<\/php>/<\/php>\n\t<filter>\n\t\t<whitelist>\n\t\t\t<directory>..\/<\/directory>\n\t\t\t<exclude>\n\t\t\t\t<directory>..\/tests\/<\/directory>\n\t\t\t\t<directory>..\/language\/<\/directory>\n\t\t\t\t<directory>..\/migrations\/<\/directory>\n\t\t\t<\/exclude>\n\t\t<\/whitelist>\n\t<\/filter>/g;p;}' .github/phpunit-$DB-github.xml &> phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml
216+
else
217+
mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_
218+
fi
199219
working-directory: ./phpBB3
200220

201221
- name: Run unit tests
202222
env:
203223
DB: ${{steps.database-type.outputs.db}}
204-
run: phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php
224+
COVERAGE: ${{ matrix.COVERAGE != 1 && '0' || '1' }}
225+
run: |
226+
if [ $COVERAGE == '1' ]
227+
then
228+
phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php --coverage-clover build/logs/clover.xml
229+
else
230+
phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php
231+
fi
205232
working-directory: ./phpBB3
233+
234+
- name: Send code coverage
235+
if: ${{ matrix.COVERAGE == 1 }}
236+
uses: codecov/codecov-action@v3
237+
with:
238+
files: ./phpBB3/build/logs/clover.xml
206239
# END MySQL and MariaDB Job
207240

208241
# START PostgreSQL Job

acp/ideas_module.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function main()
4141
$request = $phpbb_container->get('request');
4242

4343
// Get an instance of the admin controller
44+
/** @var \phpbb\ideas\controller\admin_controller $admin_controller */
4445
$admin_controller = $phpbb_container->get('phpbb.ideas.admin.controller');
4546

4647
// Add the phpBB Ideas ACP lang file
@@ -58,7 +59,7 @@ public function main()
5859
$admin_controller->set_config_options();
5960
}
6061

61-
// Set Ideas forum options and registered usergroup forum permissions
62+
// Set Ideas forum options and registered user group forum permissions
6263
if ($request->is_set_post('ideas_forum_setup'))
6364
{
6465
$admin_controller->set_ideas_forum_options();

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{
2020
"name": "Callum Macrae",
2121
"email": "callum@phpbb.com",
22-
"homepage": "http://macr.ae/",
22+
"homepage": "https://macr.ae/",
2323
"role": "Original author"
2424
},
2525
{
@@ -29,18 +29,18 @@
2929
},
3030
{
3131
"name": "Ruslan Uzdenov",
32-
"homepage": "http://www.phpbbguru.net",
32+
"homepage": "https://www.phpbbguru.net",
3333
"role": "Extensions Development Team"
3434
}
3535
],
3636
"require": {
37-
"php": ">=5.4",
37+
"php": ">=7.1.3",
3838
"composer/installers": "~1.0"
3939
},
4040
"extra": {
4141
"display-name": "phpBB Ideas",
4242
"soft-require": {
43-
"phpbb/phpbb": ">=3.2.3"
43+
"phpbb/phpbb": ">=3.3.0"
4444
}
4545
}
4646
}

controller/admin_controller.php

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,13 @@ class admin_controller
4242
/** @var string */
4343
protected $php_ext;
4444

45-
/** @var array */
46-
protected $cfg_array = array();
47-
4845
/** @var string */
4946
public $u_action;
5047

5148
/**
5249
* Constructor
5350
*
54-
* @param \phpbb\config\config $config Config object
51+
* @param \phpbb\config\config $config Config object
5552
* @param \phpbb\db\driver\driver_interface $db Database object
5653
* @param \phpbb\language\language $language Language object
5754
* @param \phpbb\log\log $log Log object
@@ -101,11 +98,6 @@ public function set_config_options()
10198
{
10299
$errors = array();
103100

104-
// This method is called on submit, so set flag to true initially
105-
$submit = true;
106-
107-
$this->cfg_array = $this->request->variable('config', array('' => ''), true);
108-
109101
// Check the form for validity
110102
if (!check_form_key('acp_phpbb_ideas_settings'))
111103
{
@@ -115,36 +107,34 @@ public function set_config_options()
115107
// Don't save settings if errors have occurred
116108
if (count($errors))
117109
{
118-
$submit = false;
119-
120110
$this->template->assign_vars(array(
121111
'S_ERROR' => true,
122112
'ERROR_MSG' => implode('<br />', $errors),
123113
));
114+
115+
return;
124116
}
125117

126-
if ($submit)
127-
{
128-
// Configuration options to list through
129-
$display_vars = array(
130-
'ideas_forum_id',
131-
'ideas_forum_setup',
132-
);
133-
134-
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to
135-
foreach ($display_vars as $config_name)
136-
{
137-
if (!isset($this->cfg_array[$config_name]))
138-
{
139-
continue;
140-
}
118+
$cfg_array = $this->request->variable('config', array('' => ''));
141119

142-
$this->config->set($config_name, $this->cfg_array[$config_name]);
120+
// Configuration options to list through
121+
$display_vars = array(
122+
'ideas_forum_id',
123+
);
143124

125+
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to
126+
foreach ($display_vars as $config_name)
127+
{
128+
if (!isset($cfg_array[$config_name]))
129+
{
130+
continue;
144131
}
145-
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_PHPBB_IDEAS_SETTINGS_LOG');
146-
trigger_error($this->language->lang('ACP_IDEAS_SETTINGS_UPDATED') . adm_back_link($this->u_action));
132+
133+
$this->config->set($config_name, $cfg_array[$config_name]);
147134
}
135+
136+
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_PHPBB_IDEAS_SETTINGS_LOG');
137+
trigger_error($this->language->lang('ACP_IDEAS_SETTINGS_UPDATED') . adm_back_link($this->u_action));
148138
}
149139

150140
/**
@@ -156,7 +146,7 @@ public function set_config_options()
156146
public function set_ideas_forum_options()
157147
{
158148
// Check if Ideas forum is selected and apply relevant settings if it is
159-
// But display the confirm box first
149+
// But display the confirmation box first
160150
if (confirm_box(true))
161151
{
162152
if (empty($this->config['ideas_forum_id']))

controller/base.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function get_entity($entity)
103103
* Check if Ideas is properly configured after installation
104104
* Ideas is available only after forum settings have been set in ACP
105105
*
106-
* @return bool Depending on whether or not the extension is properly configured
106+
* @return bool Depending on whether the extension is properly configured
107107
*/
108108
public function is_available()
109109
{
@@ -135,7 +135,7 @@ protected function assign_template_block_vars($block, $rows)
135135
'POINTS' => $row['idea_votes_up'] - $row['idea_votes_down'], // (not currently implemented)
136136
'STATUS' => $row['idea_status'], // for status icons (not currently implemented)
137137
'LOCKED' => $row['topic_status'] == ITEM_LOCKED,
138-
'U_UNAPPROVED_IDEA' => (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $this->auth->acl_get('m_approve', $this->config['ideas_forum_id'])) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=queue&amp;mode=approve_details&amp;t=' . $row['topic_id'], true, $this->user->session_id) : '',
138+
'U_UNAPPROVED_IDEA' => (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $this->auth->acl_get('m_approve', $this->config['ideas_forum_id'])) ? append_sid("{$this->root_path}mcp.$this->php_ext", 'i=queue&amp;mode=approve_details&amp;t=' . $row['topic_id'], true, $this->user->session_id) : '',
139139
));
140140
}
141141
}
@@ -148,8 +148,8 @@ protected function assign_template_block_vars($block, $rows)
148148
protected function display_common_vars()
149149
{
150150
$this->template->assign_vars([
151-
'S_DISPLAY_SEARCHBOX' => (bool) $this->auth->acl_get('u_search') && $this->auth->acl_get('f_search', $this->config['ideas_forum_id']) && $this->config['load_search'],
152-
'S_SEARCHBOX_ACTION' => append_sid("{$this->root_path}search.{$this->php_ext}"),
151+
'S_DISPLAY_SEARCHBOX' => $this->auth->acl_get('u_search') && $this->auth->acl_get('f_search', $this->config['ideas_forum_id']) && $this->config['load_search'],
152+
'S_SEARCHBOX_ACTION' => append_sid("{$this->root_path}search.$this->php_ext"),
153153
'S_SEARCH_IDEAS_HIDDEN_FIELDS' => build_hidden_fields(['fid' => [$this->config['ideas_forum_id']]]),
154154

155155
'U_SEARCH_MY_IDEAS' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_MYIDEAS, 'status' => '-1']),

controller/idea_controller.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function idea($idea_id)
6161
$params = array_merge($params, array('view' => 'unread'));
6262
}
6363

64-
$url = append_sid(generate_board_url() . "/viewtopic.{$this->php_ext}", $params, false) . ($unread ? '#unread' : '');
64+
$url = append_sid(generate_board_url() . "/viewtopic.$this->php_ext", $params, false) . ($unread ? '#unread' : '');
6565

6666
return new RedirectResponse($url);
6767
}
@@ -131,7 +131,7 @@ public function duplicate()
131131
/**
132132
* Remove vote action (remove a user's vote from an idea)
133133
*
134-
* @return mixed Array of vote data, an error message, or false if failed
134+
* @return array|false|string Array of vote data, an error message, or false if failed
135135
* @access public
136136
*/
137137
public function removevote()
@@ -226,7 +226,7 @@ public function implemented()
226226
/**
227227
* Vote action (sets an idea's vote)
228228
*
229-
* @return mixed Array of vote data, an error message, or false if failed
229+
* @return array|false|string Array of vote data, an error message, or false if failed
230230
* @access public
231231
*/
232232
public function vote()

controller/index_controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function index()
4848
'U_VIEW_LATEST' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_NEW]),
4949
'U_VIEW_IMPLEMENTED'=> $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_DATE, 'status' => ext::$statuses['IMPLEMENTED']]),
5050
'U_POST_ACTION' => $this->helper->route('phpbb_ideas_post_controller'),
51-
'U_MCP' => ($this->auth->acl_get('m_', $this->config['ideas_forum_id'])) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", "f={$this->config['ideas_forum_id']}&amp;i=main&amp;mode=forum_view", true, $this->user->session_id) : '',
51+
'U_MCP' => ($this->auth->acl_get('m_', $this->config['ideas_forum_id'])) ? append_sid("{$this->root_path}mcp.$this->php_ext", "f={$this->config['ideas_forum_id']}&amp;i=main&amp;mode=forum_view", true, $this->user->session_id) : '',
5252

5353
));
5454

controller/list_controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function ideas_list($sort)
3434

3535
// Overwrite the $sort parameter if the url contains a sort query.
3636
// This is needed with the sort by options form at the footer of the list.
37-
$sort = $this->request->is_set('sort') ? $this->request->variable('sort', ext::SORT_NEW) : $sort;
37+
$sort = $this->request->is_set('sort') ? (string) $this->request->variable('sort', ext::SORT_NEW) : $sort;
3838

3939
// Get additional query values the url may contain
4040
$sort_direction = $this->request->variable('sd', 'd');
@@ -82,7 +82,7 @@ public function ideas_list($sort)
8282
'SORT_ARY' => array(ext::SORT_AUTHOR, ext::SORT_DATE, ext::SORT_SCORE, ext::SORT_TITLE, ext::SORT_TOP, ext::SORT_VOTES),
8383
'SORT' => $sort,
8484
'SORT_DIRECTION' => $sort_direction,
85-
'U_MCP' => ($this->auth->acl_get('m_', $this->config['ideas_forum_id'])) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", "f={$this->config['ideas_forum_id']}&amp;i=main&amp;mode=forum_view", true, $this->user->session_id) : '',
85+
'U_MCP' => ($this->auth->acl_get('m_', $this->config['ideas_forum_id'])) ? append_sid("{$this->root_path}mcp.$this->php_ext", "f={$this->config['ideas_forum_id']}&amp;i=main&amp;mode=forum_view", true, $this->user->session_id) : '',
8686

8787
));
8888

controller/post_controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function post()
3939
'f' => $this->config['ideas_forum_id'],
4040
];
4141

42-
$url = append_sid(generate_board_url() . "/posting.{$this->php_ext}", $params, false);
42+
$url = append_sid(generate_board_url() . "/posting.$this->php_ext", $params, false);
4343

4444
return new RedirectResponse($url);
4545
}

0 commit comments

Comments
 (0)