From 0391b48d7e95aca38be7c7ce7f1cbbba6c9fc5ab Mon Sep 17 00:00:00 2001
From: rxu <rxu@mail.ru>
Date: Mon, 8 Jan 2018 23:21:17 +0700
Subject: [PATCH] [ticket/15502] Fix migrations

PHPBB3-15502
---
 phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php      | 6 +++++-
 .../db/migration/data/v32x/merge_duplicate_bbcodes.php      | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php b/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php
index 282c6bef2f..16fbdbc77b 100644
--- a/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php
+++ b/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php
@@ -33,13 +33,17 @@ class fix_user_styles extends \phpbb\db\migration\migration
 	public function styles_fix()
 	{
 		$default_style = (int) $this->config['default_style'];
+		$enabled_styles = array();
 
 		// Get enabled styles
 		$sql = 'SELECT style_id
 			FROM ' . STYLES_TABLE . '
 			WHERE style_active = 1';
 		$result = $this->db->sql_query($sql);
-		$enabled_styles = $result->fetch_array();
+		while ($row = $this->db->sql_fetchrow($result))
+		{
+			$enabled_styles[] = (int) $row['style_id'];
+		}
 		$this->db->sql_freeresult($result);
 
 		// Set the default style to users who have an invalid style
diff --git a/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php b/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php
index 3bf442bab5..08609b571b 100644
--- a/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php
+++ b/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php
@@ -13,7 +13,7 @@
 
 namespace phpbb\db\migration\data\v32x;
 
-class merge_duplicate_bbcodes extends \phpbb\db\migration\migration
+class merge_duplicate_bbcodes extends \phpbb\db\migration\container_aware_migration
 {
 	public function update_data()
 	{
@@ -30,7 +30,7 @@ class merge_duplicate_bbcodes extends \phpbb\db\migration\migration
 		while ($row = $this->db->sql_fetchrow($result))
 		{
 			$variant = (substr($row['bbcode_tag'], -1) === '=') ? 'with': 'without';
-			$bbcode_name = rtrim($row['bbcode_tag'], '=');
+			$bbcode_name = strtolower(rtrim($row['bbcode_tag'], '='));
 			$bbcodes[$bbcode_name][$variant] = $row;
 		}
 		$this->db->sql_freeresult($result);