mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/10824] Use json_sanitzer::decode and improve migrations from pre 3.2
PHPBB3-10824
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
|
||||
namespace phpbb\db\migration\data\v310;
|
||||
|
||||
use phpbb\json_sanitizer;
|
||||
|
||||
class style_update_p1 extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
@@ -69,14 +71,26 @@ class style_update_p1 extends \phpbb\db\migration\migration
|
||||
$skip_dirs = array('.', '..', 'prosilver');
|
||||
foreach ($iterator as $fileinfo)
|
||||
{
|
||||
if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/composer.json'))
|
||||
if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs))
|
||||
{
|
||||
$json = file_get_contents($fileinfo->getPathname() . '/composer.json');
|
||||
$style_data = json_decode($json, true);
|
||||
if (isset($style_data['extra']['phpbb-version']) && version_compare($style_data['extra']['phpbb-version'], '3.1.0-dev', '>='))
|
||||
if (file_exists($fileinfo->getPathname() . '/style.cfg'))
|
||||
{
|
||||
// 3.1 style
|
||||
$available_styles[] = $fileinfo->getFilename();
|
||||
$style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg');
|
||||
if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>='))
|
||||
{
|
||||
// 3.1 & 3.2 style
|
||||
$available_styles[] = $fileinfo->getFilename();
|
||||
}
|
||||
}
|
||||
else if (file_exists($fileinfo->getPathname() . '/composer.json'))
|
||||
{
|
||||
$json = file_get_contents($fileinfo->getPathname() . '/composer.json');
|
||||
$style_data = json_sanitizer::decode($json);
|
||||
if (isset($style_data['extra']['phpbb-version']) && version_compare($style_data['extra']['phpbb-version'], '3.3.0-dev', '>='))
|
||||
{
|
||||
// 3.3 style
|
||||
$available_styles[] = $fileinfo->getFilename();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -49,8 +49,11 @@ class style_update extends \phpbb\db\migration\migration
|
||||
// Install prosilver if no style is available and prosilver can be installed
|
||||
if (empty($style_paths) && in_array('prosilver', $styles))
|
||||
{
|
||||
// Stop running this if prosilver composer.json file can't be read
|
||||
if (file_exists($this->phpbb_root_path . 'styles/prosilver/composer.json'))
|
||||
// Try to parse config file
|
||||
$cfg = parse_cfg_file($this->phpbb_root_path . 'styles/prosilver/style.cfg');
|
||||
|
||||
// Stop running this if both prosilver cfg file and composer.json file can't be read
|
||||
if (empty($cfg) && !file_exists($this->phpbb_root_path . 'styles/prosilver/composer.json'))
|
||||
{
|
||||
throw new \RuntimeException('No styles available and could not fall back to prosilver.');
|
||||
}
|
||||
@@ -120,7 +123,7 @@ class style_update extends \phpbb\db\migration\migration
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file_exists("{$dir}/composer.json"))
|
||||
if (file_exists("{$dir}/composer.json") || file_exists("{$dir}/style.cfg"))
|
||||
{
|
||||
$styles[] = $file;
|
||||
}
|
||||
|
Reference in New Issue
Block a user