Skip to content

Commit 406e5b5

Browse files
authored
Merge pull request #190 from iMattPro/develop
Improve PHP and phpBB compatibility checks
2 parents c1bb7b5 + 0540a29 commit 406e5b5

5 files changed

Lines changed: 51 additions & 11 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ QuickInstall is a tool we built to support the community of phpBB extension deve
1515
4. Point your web browser to the QuickInstall directory (`http://localhost/quickinstall` for instance) and follow the setup instructions.
1616

1717
> **Alternate phpBB Profiles:**<br>
18-
> You can store additional versions of phpBB and boards with alternate styles or language packs in `sources/phpBB3_alt/` . You can name these alternate phpBB folders whatever you want, e.g.: `sources/phpBB3_alt/phpBB-3.0.12`, `sources/phpBB3_alt/phpBB-sv`, etc. They will then be available as alternative phpBB3 boards you can choose to install or save as Profiles.
18+
> You can store additional versions of phpBB and boards with alternate styles or language packs in `sources/phpBB3_alt/` . You can name these alternate phpBB folders whatever you want, e.g.: `sources/phpBB3_alt/phpBB-3.0.12`, `sources/phpBB3_alt/phpBB-sv`, etc. They will then be available as alternative phpBB3 boards you can choose to install or save as Profiles. [Past releases of phpBB can be downloaded here](https://download.phpbb.com/pub/release/).
1919
2020
> **Adding phpBB Extras**:<br>
2121
> If you want additional files/folders, such as extensions, to be copied to your boards when they are created, you can put them in the `sources/extra/` directory. By using the same directory structure in `sources/extra/` as phpBB, the files/folders should be mapped to the correct locations in your boards. For example: `sources/extra/ext/phpbb/pages`.

includes/qi.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,4 +866,39 @@ public static function phpbb_version_compare($version1, $version2, $operator = n
866866
}
867867
return version_compare($version1, $version2, $operator);
868868
}
869+
870+
/**
871+
* Check phpBB compatibility with the PHP environment
872+
*
873+
* phpBB 3.1.x is not compat with PHP >= 7 (700000)
874+
* phpBB 3.2.0-3.2.1 is not compat with PHP >= 7.2 (702000)
875+
* phpBB 3.2.x is not compat with PHP >= 7.3 (703000)
876+
* phpBB 3.3.x is not compat with PHP < 7.1.3 (70103)
877+
* phpBB 4.0.x is not compat with PHP < 7.3 (703000)
878+
*
879+
* @param string $phpbb_version Check a given phpBB version. If none given, will check QI's loaded phpBB.
880+
*
881+
* @return bool
882+
*/
883+
public static function php_phpbb_incompatible($phpbb_version = '')
884+
{
885+
if ($phpbb_version)
886+
{
887+
return
888+
(PHP_VERSION_ID >= 70000 && self::phpbb_version_compare($phpbb_version, '3.2', '<')) ||
889+
(PHP_VERSION_ID >= 70200 && self::phpbb_version_compare($phpbb_version, '3.2.2', '<')) ||
890+
(PHP_VERSION_ID >= 70300 && self::phpbb_version_compare($phpbb_version, '3.3', '<')) ||
891+
(PHP_VERSION_ID < 70103 && self::phpbb_version_compare($phpbb_version, '3.3', '>=')) ||
892+
(PHP_VERSION_ID < 70300 && self::phpbb_version_compare($phpbb_version, '4.0', '>='))
893+
;
894+
}
895+
896+
return
897+
(PHP_VERSION_ID >= 70000 && !defined('PHPBB_32')) ||
898+
(PHP_VERSION_ID >= 70200 && self::phpbb_version_compare(PHPBB_VERSION, '3.2.2', '<')) ||
899+
(PHP_VERSION_ID >= 70300 && !defined('PHPBB_33')) ||
900+
(PHP_VERSION_ID < 70103 && defined('PHPBB_33')) ||
901+
(PHP_VERSION_ID < 70300 && defined('PHPBB_40'))
902+
;
903+
}
869904
}

includes/settings.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ public function validate()
166166
$validation_errors[] = ['BOARDS_DIR_MISSING', $this->get_boards_dir()];
167167
}
168168

169+
// Validate alt environment board's compatibility with current PHP environment
170+
if ($this->settings['alt_env'])
171+
{
172+
$phpbb_version = get_phpbb_version($this->qi_path . 'sources/phpBB3_alt/' . $this->settings['alt_env']);
173+
if (qi::php_phpbb_incompatible($phpbb_version))
174+
{
175+
$validation_errors[] = ['PHP_INCOMPATIBLE', $phpbb_version, PHP_VERSION];
176+
}
177+
}
178+
169179
// Adjust boards URL path
170180
qi_file::append_slash($this->settings['boards_url']);
171181

language/en/qi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
'PHPBB_QI_FULLLINK' => '<a href="https://www.phpbb.com/customise/db/official_tool/phpbb3_quickinstall/">phpBB<small><sup>&reg;</sup></small> QuickInstall</a> %s for phpBB 3.0 - 4.0',
231231
'PHPBB_QI_TITLE' => 'phpBB&reg; QuickInstall',
232232

233-
'PHP7_INCOMPATIBLE' => 'The board you are trying to install, phpBB %1$s, is not compatible with PHP %2$s.',
233+
'PHP_INCOMPATIBLE' => 'The board you are trying to use, phpBB %1$s, is not compatible with PHP %2$s. Refer to the Documentation for our compatibility grid.',
234234
'PHPINFO' => 'PHP info',
235235
'PHPINFO_TITLE' => 'PHP information',
236236
'PHPINFO_EXPLAIN' => 'This page lists information on the version of PHP installed on this server. It includes details of loaded modules, available variables and default settings. This information may be useful when diagnosing problems.<br /><br />Please be aware that some hosting companies will limit what information is displayed here for security reasons.<br /><br />You are advised to only give out details on this page on a need to know basis.',

modules/qi_create.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,10 @@ public function run()
2222
// postgres uses remove_comments function which is defined in functions_admin
2323
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
2424

25-
// phpBB 3.1.x is not compat with PHP 7 (700000)
26-
// phpBB 3.2.0-3.2.1 is not compat with PHP 7.2 (702000)
27-
// phpBB 3.2.x is not compat with PHP 7.3 (703000)
28-
if ((PHP_VERSION_ID >= 70000 && !defined('PHPBB_32')) ||
29-
(PHP_VERSION_ID >= 70200 && qi::phpbb_version_compare(PHPBB_VERSION, '3.2.2', '<')) ||
30-
(PHP_VERSION_ID >= 70300 && !defined('PHPBB_33'))
31-
)
32-
{
33-
trigger_error(qi::lang('PHP7_INCOMPATIBLE', PHPBB_VERSION, PHP_VERSION));
25+
// Validate board's compatibility with current PHP environment
26+
if (qi::php_phpbb_incompatible())
27+
{
28+
trigger_error(qi::lang('PHP_INCOMPATIBLE', PHPBB_VERSION, PHP_VERSION));
3429
}
3530

3631
if (defined('PHPBB_31'))

0 commit comments

Comments
 (0)