diff options
author | Marc Alexander <admin@m-a-styles.de> | 2014-11-01 23:40:21 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2014-11-01 23:53:58 +0100 |
commit | 74615364598115a584d01503a5dfcc234d8a42b0 (patch) | |
tree | fdd41ca0997ddfff6337b428d038f4b40aac5854 /phpBB/phpbb/db/migration | |
parent | d1f85f0de3dd958050df39ea79d2e7cd14147b07 (diff) | |
download | forums-74615364598115a584d01503a5dfcc234d8a42b0.tar forums-74615364598115a584d01503a5dfcc234d8a42b0.tar.gz forums-74615364598115a584d01503a5dfcc234d8a42b0.tar.bz2 forums-74615364598115a584d01503a5dfcc234d8a42b0.tar.xz forums-74615364598115a584d01503a5dfcc234d8a42b0.zip |
[ticket/13263] Make sure default style exists and clean up code
PHPBB3-13263
Diffstat (limited to 'phpBB/phpbb/db/migration')
-rw-r--r-- | phpBB/phpbb/db/migration/data/v31x/style_update.php | 59 |
1 files changed, 12 insertions, 47 deletions
diff --git a/phpBB/phpbb/db/migration/data/v31x/style_update.php b/phpBB/phpbb/db/migration/data/v31x/style_update.php index 9f01514ff6..bb030bbe6d 100644 --- a/phpBB/phpbb/db/migration/data/v31x/style_update.php +++ b/phpBB/phpbb/db/migration/data/v31x/style_update.php @@ -52,24 +52,18 @@ class style_update extends \phpbb\db\migration\migration // Try to parse config file $cfg = parse_cfg_file($this->phpbb_root_path . 'styles/prosilver/style.cfg'); - // Stop running this if prosilver doesn't exist + // Stop running this if prosilver cfg file can't be read if (empty($cfg)) { throw new \RuntimeException('No styles available and could not fall back to prosilver.'); } - // Check data - if (!isset($cfg['template_bitfield'])) - { - $cfg['template_bitfield'] = $this->default_bitfield(); - } - $style = array( 'style_name' => 'prosilver', 'style_copyright' => '© phpBB Limited', 'style_active' => 1, 'style_path' => 'prosilver', - 'bbcode_bitfield' => $cfg['template_bitfield'], + 'bbcode_bitfield' => 'kNg=', 'style_parent_id' => 0, 'style_parent_tree' => '', ); @@ -81,62 +75,33 @@ class style_update extends \phpbb\db\migration\migration ' . $this->db->sql_build_array('INSERT', $style); $this->db->sql_query($sql); - $row = array('style_id' => $this->db->sql_nextid()); + $style_id = $this->db->sql_nextid(); + $style_ids[] = $style_id; $this->db->sql_transaction('commit'); // Set prosilver to default style - $this->config->set('default_style', $row['style_id']); + $this->config->set('default_style', $style_id); } else if (empty($styles) && empty($available_styles)) { throw new \RuntimeException('No valid styles available'); } + // Make sure default style is available + if (!in_array($this->config['default_style'], $style_ids)) + { + $this->config->set('default_style', array_pop($style_ids)); + } + // Reset users to default style if their user_style is nonexistent $sql = 'UPDATE ' . $this->table_prefix . "users SET user_style = {$this->config['default_style']} - WHERE " . $this->db->sql_in_set('user_style', $style_ids, true); + WHERE " . $this->db->sql_in_set('user_style', $style_ids, true, true); $this->db->sql_query($sql); } /** - * Generates default bitfield - * Copied from acp_styles - * - * This bitfield decides which bbcodes are defined in a template. - * - * @return string Bitfield - */ - protected function default_bitfield() - { - static $value; - if (isset($value)) - { - return $value; - } - - if (!class_exists('bitfield')) - { - include($this->phpbb_root_path . 'includes/functions_content.' . $this->php_ext); - } - - // Hardcoded template bitfield to add for new templates - $bitfield = new \bitfield(); - $bitfield->set(0); - $bitfield->set(1); - $bitfield->set(2); - $bitfield->set(3); - $bitfield->set(4); - $bitfield->set(8); - $bitfield->set(9); - $bitfield->set(11); - $bitfield->set(12); - $value = $bitfield->get_base64(); - return $value; - } - - /** * Find all directories that have styles * Copied from acp_styles * |