Skip to content

Commit 0cc25d9

Browse files
boneliferclaude
andauthored
Require phpBB 3.3.19 (#8)
Refuse to enable on phpBB older than 3.3.19 or below the extension's minimum PHP version, showing a clear reason instead of a generic error. phpBB 3.3.17 through 3.3.19 fixed a series of security issues, so older boards should update phpBB first. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent de6d51e commit 0cc25d9

2 files changed

Lines changed: 74 additions & 1 deletion

File tree

‎ext.php‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,23 @@ class ext extends \phpbb\extension\base
3333
const NEW_NAMESPACE = '\\phpbbmodders\\editedpostsunread\\';
3434

3535
/**
36+
* Refuse to enable below the minimum phpBB and PHP versions.
37+
*
3638
* Refuse to enable while the old copy is still enabled; both would run
3739
* at once and the old one's data can't be moved while it's in use.
3840
*
39-
* @return bool|array True if enableable, otherwise an array of reasons
41+
* @return bool|string|array True if enableable, otherwise a reason string or array of reasons
4042
*/
4143
public function is_enableable()
4244
{
45+
if (!$this->check_phpbb_version() || !$this->check_php_version())
46+
{
47+
$language = $this->container->get('language');
48+
$language->add_lang('install_editedpostsunread', 'phpbbmodders/editedpostsunread');
49+
50+
return $language->lang('EDITEDPOSTSUNREAD_NOT_ENABLEABLE');
51+
}
52+
4353
if ($this->container->get('ext.manager')->is_enabled(self::OLD_EXT_NAME))
4454
{
4555
return ['Disable the old "' . self::OLD_EXT_NAME . '" extension first (keep its data, do not delete it).'];
@@ -48,6 +58,26 @@ public function is_enableable()
4858
return true;
4959
}
5060

61+
/**
62+
* Require phpBB 3.3.19
63+
*
64+
* @return bool
65+
*/
66+
public function check_phpbb_version()
67+
{
68+
return phpbb_version_compare(PHPBB_VERSION, '3.3.19', '>=');
69+
}
70+
71+
/**
72+
* Require PHP 7.4
73+
*
74+
* @return bool
75+
*/
76+
public function check_php_version()
77+
{
78+
return PHP_VERSION_ID >= 70400;
79+
}
80+
5181
/**
5282
* Move an old install's data to the new name, then enable as usual.
5383
*
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
*
4+
* Mark Edited Posts Unread extension for the phpBB Forum Software package
5+
*
6+
* @copyright (c) 2015 RMcGirr83
7+
* @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/
8+
* @license GNU General Public License, version 2 (GPL-2.0)
9+
*
10+
*/
11+
12+
/**
13+
* DO NOT CHANGE
14+
*/
15+
if (!defined('IN_PHPBB'))
16+
{
17+
exit;
18+
}
19+
20+
if (empty($lang) || !is_array($lang))
21+
{
22+
$lang = [];
23+
}
24+
25+
// DEVELOPERS PLEASE NOTE
26+
//
27+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
28+
//
29+
// Placeholders can now contain order information, e.g. instead of
30+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
31+
// translators to re-order the output of data while ensuring it remains correct
32+
//
33+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
34+
// equally where a string contains only two placeholders which are used to wrap text
35+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
36+
//
37+
// Some characters you may want to copy&paste:
38+
// ’ » “ ” …
39+
//
40+
41+
$lang = array_merge($lang, [
42+
'EDITEDPOSTSUNREAD_NOT_ENABLEABLE' => 'Mark Edited Posts Unread could not be enabled. The minimum requirements of phpBB 3.3.19 and/or PHP 7.4.0 were not satisfied.',
43+
]);

0 commit comments

Comments
 (0)