Skip to content

Commit bbef2b5

Browse files
authored
Merge branch 'phpbb-extensions:master' into master
2 parents 597a32a + dee419a commit bbef2b5

9 files changed

Lines changed: 186 additions & 52 deletions

File tree

.github/workflows/tests.yml

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@ on:
2121
jobs:
2222
# START Basic Checks Job (EPV, code sniffer, images check, etc.)
2323
basic-checks:
24-
runs-on: ubuntu-18.04
24+
runs-on: ubuntu-22.04
2525
strategy:
2626
matrix:
2727
include:
28-
- php: '7.1'
28+
- php: '7.2'
2929
db: "none"
3030
NOTESTS: 1
3131

3232
name: PHP ${{ matrix.php }} - ${{ matrix.db }}
3333

3434
steps:
3535
- name: Checkout phpBB
36-
uses: actions/checkout@v2
36+
uses: actions/checkout@v4
3737
with:
3838
repository: phpbb/phpbb
3939
ref: ${{ env.PHPBB_BRANCH }}
4040
path: phpBB3
4141

4242
- name: Checkout extension
43-
uses: actions/checkout@v2
43+
uses: actions/checkout@v4
4444
with:
4545
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}
4646

@@ -89,28 +89,26 @@ jobs:
8989

9090
# START MySQL and MariaDB Job
9191
mysql-tests:
92-
runs-on: ubuntu-18.04
92+
runs-on: ubuntu-22.04
9393
strategy:
9494
matrix:
9595
include:
96-
- php: '7.1'
96+
- php: '7.2'
9797
db: "mariadb:10.1"
98-
- php: '7.1'
98+
- php: '7.2'
9999
db: "mariadb:10.2"
100-
- php: '7.1'
100+
- php: '7.2'
101101
db: "mariadb:10.3"
102-
- php: '7.1'
102+
- php: '7.2'
103103
db: "mariadb:10.4"
104-
- php: '7.1'
104+
- php: '7.2'
105105
db: "mariadb:10.5"
106-
- php: '7.1'
106+
- php: '7.2'
107107
db: "mysql:5.6"
108108
db_alias: "MyISAM Tests"
109109
MYISAM: 1
110-
- php: '7.1'
110+
- php: '7.2'
111111
db: "mysql:5.6"
112-
- php: '7.1'
113-
db: "mysql:5.7"
114112
- php: '7.2'
115113
db: "mysql:5.7"
116114
- php: '7.3'
@@ -123,6 +121,12 @@ jobs:
123121
db: "mysql:5.7"
124122
- php: '8.1'
125123
db: "mysql:5.7"
124+
- php: '8.2'
125+
db: "mysql:5.7"
126+
- php: '8.3'
127+
db: "mysql:5.7"
128+
- php: '8.4'
129+
db: "mysql:5.7"
126130

127131
name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
128132

@@ -152,14 +156,14 @@ jobs:
152156

153157
steps:
154158
- name: Checkout phpBB
155-
uses: actions/checkout@v2
159+
uses: actions/checkout@v4
156160
with:
157161
repository: phpbb/phpbb
158162
ref: ${{ env.PHPBB_BRANCH }}
159163
path: phpBB3
160164

161165
- name: Checkout extension
162-
uses: actions/checkout@v2
166+
uses: actions/checkout@v4
163167
with:
164168
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}
165169

@@ -168,7 +172,7 @@ jobs:
168172
MATRIX_DB: ${{ matrix.db }}
169173
run: |
170174
db=$(echo "${MATRIX_DB%%:*}")
171-
echo "::set-output name=db::$db"
175+
echo "db=$db" >> $GITHUB_OUTPUT
172176
173177
- name: Setup PHP
174178
uses: shivammathur/setup-php@v2
@@ -205,22 +209,38 @@ jobs:
205209

206210
# START PostgreSQL Job
207211
postgres-tests:
208-
runs-on: ubuntu-18.04
212+
runs-on: ubuntu-22.04
209213
strategy:
210214
matrix:
211215
include:
212-
- php: '7.1'
216+
- php: '7.2'
213217
db: "postgres:9.5"
214-
- php: '7.1'
218+
- php: '7.2'
215219
db: "postgres:9.6"
216-
- php: '7.1'
220+
- php: '7.2'
217221
db: "postgres:10"
218-
- php: '7.1'
222+
- php: '7.2'
219223
db: "postgres:11"
220-
- php: '7.1'
224+
- php: '7.2'
225+
db: "postgres:12"
226+
- php: '7.2'
227+
db: "postgres:13"
228+
- php: '7.3'
229+
db: "postgres:13"
230+
- php: '7.4'
231+
db: "postgres:13"
232+
- php: '8.0'
221233
db: "postgres:12"
222-
- php: '7.1'
234+
- php: '8.0'
223235
db: "postgres:13"
236+
- php: '8.1'
237+
db: "postgres:14"
238+
- php: '8.2'
239+
db: "postgres:14"
240+
- php: '8.3'
241+
db: "postgres:14"
242+
- php: '8.4'
243+
db: "postgres:14"
224244

225245
name: PHP ${{ matrix.php }} - ${{ matrix.db }}
226246

@@ -252,14 +272,14 @@ jobs:
252272

253273
steps:
254274
- name: Checkout phpBB
255-
uses: actions/checkout@v2
275+
uses: actions/checkout@v4
256276
with:
257277
repository: phpbb/phpbb
258278
ref: ${{ env.PHPBB_BRANCH }}
259279
path: phpBB3
260280

261281
- name: Checkout extension
262-
uses: actions/checkout@v2
282+
uses: actions/checkout@v4
263283
with:
264284
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}
265285

@@ -268,7 +288,7 @@ jobs:
268288
MATRIX_DB: ${{ matrix.db }}
269289
run: |
270290
db=$(echo "${MATRIX_DB%%:*}")
271-
echo "::set-output name=db::$db"
291+
echo "db=$db" >> $GITHUB_OUTPUT
272292
273293
- name: Setup PHP
274294
uses: shivammathur/setup-php@v2
@@ -305,11 +325,11 @@ jobs:
305325

306326
# START Other Tests Job (SQLite 3 and mssql)
307327
other-tests:
308-
runs-on: ubuntu-18.04
328+
runs-on: ubuntu-22.04
309329
strategy:
310330
matrix:
311331
include:
312-
- php: '7.1'
332+
- php: '7.2'
313333
db: "sqlite3"
314334
- php: '7.2'
315335
db: "mcr.microsoft.com/mssql/server:2017-latest"
@@ -347,14 +367,14 @@ jobs:
347367

348368
steps:
349369
- name: Checkout phpBB
350-
uses: actions/checkout@v2
370+
uses: actions/checkout@v4
351371
with:
352372
repository: phpbb/phpbb
353373
ref: ${{ env.PHPBB_BRANCH }}
354374
path: phpBB3
355375

356376
- name: Checkout extension
357-
uses: actions/checkout@v2
377+
uses: actions/checkout@v4
358378
with:
359379
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}
360380

@@ -368,7 +388,7 @@ jobs:
368388
else
369389
db=$(echo "${MATRIX_DB%%:*}")
370390
fi
371-
echo "::set-output name=db::$db"
391+
echo "db=$db" >> $GITHUB_OUTPUT
372392
373393
- name: Setup PHP
374394
uses: shivammathur/setup-php@v2

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ This extension adds passive security features to phpBB that allow the board's fo
1616
Note: This extension is currently under development and is not ready to install on any live forum.
1717

1818
## License
19-
[GNU General Public License v2](http://opensource.org/licenses/GPL-2.0)
19+
[GNU General Public License v2](https://opensource.org/licenses/GPL-2.0)

acp/teamsecurity_module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function __construct()
7575
public function main()
7676
{
7777
$this->tpl_name = 'acp_teamsecurity';
78-
$this->page_title = $this->language->lang('ACP_TEAM_SECURITY_SETTINGS');
78+
$this->page_title = 'ACP_TEAM_SECURITY_SETTINGS';
7979

8080
// Only allow founders to view/manage these settings
8181
if ($this->user->data['user_type'] != USER_FOUNDER)

ext.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class ext extends \phpbb\extension\base
1717
{
1818
/**
19-
* Check whether or not the extension can be enabled.
19+
* Check whether the extension can be enabled.
2020
* The current phpBB version should meet or exceed
2121
* the minimum version required by this extension:
2222
*
@@ -27,8 +27,7 @@ class ext extends \phpbb\extension\base
2727
*/
2828
public function is_enableable()
2929
{
30-
$config = $this->container->get('config');
31-
return phpbb_version_compare($config['version'], '3.2.0', '>=');
30+
return phpbb_version_compare(PHPBB_VERSION, '3.2.0', '>=');
3231
}
3332

3433
/**
@@ -40,7 +39,6 @@ public function is_enableable()
4039
*/
4140
public function disable_step($old_state)
4241
{
43-
// Use hardcoded language here since the $user is not available
44-
trigger_error('Please remove ext.php from the filesystem, purge the board cache, and try again.', E_USER_WARNING);
42+
trigger_error('TEAM_SECURITY_DISABLE_MESSAGE', E_USER_WARNING);
4543
}
4644
}

language/en/info_acp_teamsecurity.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@
3636

3737
// EMAIL
3838
'ACP_CONTACT_ADMIN' => 'the board administrator or webmaster',
39+
40+
// EXT
41+
'TEAM_SECURITY_DISABLE_MESSAGE' => 'Please remove “ext.php” from the filesystem, purge the board cache, and try again.',
3942
));

migrations/m4_serialize_to_json.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ public function update_data()
3333
*/
3434
public function serialize_to_json($cfg)
3535
{
36+
// This check is needed to prevent errors when uninstalling this migration/extension
37+
json_decode($this->config[$cfg], false);
38+
if (json_last_error() === JSON_ERROR_NONE)
39+
{
40+
return '';
41+
}
42+
3643
$data = unserialize(trim($this->config[$cfg]), ['allowed_classes' => false]);
3744

3845
return $data ? json_encode($data) : '';

tests/event/delete_log_security_test.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,41 @@ class delete_log_security_test extends listener_base
1919
*/
2020
public function delete_logs_security_data()
2121
{
22-
return array(
23-
array('admin', true, false),
24-
array('mod', true, false),
25-
array('user', true, false),
26-
array('users', true, false),
27-
array('', true, true),
28-
array('', false, false),
29-
);
22+
return [
23+
['admin', LOG_ADMIN, [], false],
24+
['admin', LOG_ADMIN, ['keywords' => ['test']], false],
25+
['admin', LOG_ADMIN, ['log_id' => ['IN' => []]], false],
26+
['mod', LOG_MOD, [], false],
27+
['user', LOG_USER, [], false],
28+
['users', LOG_USERS, [], false],
29+
['', LOG_CRITICAL, [], true],
30+
['', false, [], false],
31+
];
3032
}
3133

3234
/**
3335
* Test the delete logs security event
3436
*
3537
* @dataProvider delete_logs_security_data
3638
*/
37-
public function test_delete_logs_security($mode, $log_type, $expected_log_type)
39+
public function test_delete_logs_security($mode, $log_type, $conditions, $expected_log_type)
3840
{
3941
// Set some user DateTime options
4042
$this->user->timezone = new \DateTimeZone('UTC');
41-
$this->lang->lang('datetime', array());
43+
$this->lang->lang('datetime', []);
4244

4345
$this->set_listener();
4446

47+
$this->listener->expects(self::exactly(count($conditions)))
48+
->method('send_message');
49+
4550
$dispatcher = new \phpbb\event\dispatcher();
46-
$dispatcher->addListener('core.delete_log', array($this->listener, 'delete_logs_security'));
51+
$dispatcher->addListener('core.delete_log', [$this->listener, 'delete_logs_security']);
4752

48-
$event_data = array('mode', 'log_type');
53+
$event_data = ['mode', 'log_type', 'conditions'];
4954
$event_data_after = $dispatcher->trigger_event('core.delete_log', compact($event_data));
5055
extract($event_data_after, EXTR_OVERWRITE);
5156

52-
self::assertSame($expected_log_type, $log_type);
57+
self::assertEquals($expected_log_type, $log_type);
5358
}
5459
}

0 commit comments

Comments
 (0)