diff options
Diffstat (limited to 'phpBB/phpbb/db')
18 files changed, 572 insertions, 24 deletions
| diff --git a/phpBB/phpbb/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php index 9639bfa988..a7f93c8feb 100644 --- a/phpBB/phpbb/db/driver/mssqlnative.php +++ b/phpBB/phpbb/db/driver/mssqlnative.php @@ -319,10 +319,10 @@ class mssqlnative extends \phpbb\db\driver\mssql_base  			{  				foreach ($errors as $error)  				{ -					$error_message .= "SQLSTATE: " . $error[ 'SQLSTATE'] . "\n"; -					$error_message .= "code: " . $error[ 'code'] . "\n"; +					$error_message .= "SQLSTATE: " . $error['SQLSTATE'] . "\n"; +					$error_message .= "code: " . $error['code'] . "\n";  					$code = $error['code']; -					$error_message .= "message: " . $error[ 'message'] . "\n"; +					$error_message .= "message: " . $error['message'] . "\n";  				}  				$this->last_error_result = $error_message;  				$error = $this->last_error_result; diff --git a/phpBB/phpbb/db/driver/mysqli.php b/phpBB/phpbb/db/driver/mysqli.php index 58361ff0f8..520bb65b67 100644 --- a/phpBB/phpbb/db/driver/mysqli.php +++ b/phpBB/phpbb/db/driver/mysqli.php @@ -71,10 +71,17 @@ class mysqli extends \phpbb\db\driver\mysql_base  			if (version_compare($this->sql_server_info(true), '5.0.2', '>='))  			{  				$result = @mysqli_query($this->db_connect_id, 'SELECT @@session.sql_mode AS sql_mode'); -				$row = @mysqli_fetch_assoc($result); -				@mysqli_free_result($result); +				if ($result !== null) +				{ +					$row = @mysqli_fetch_assoc($result); -				$modes = array_map('trim', explode(',', $row['sql_mode'])); +					$modes = array_map('trim', explode(',', $row['sql_mode'])); +				} +				else +				{ +					$modes = array(); +				} +				@mysqli_free_result($result);  				// TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES  				if (!in_array('TRADITIONAL', $modes)) @@ -109,15 +116,18 @@ class mysqli extends \phpbb\db\driver\mysql_base  		if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false)  		{  			$result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version'); -			$row = @mysqli_fetch_assoc($result); -			@mysqli_free_result($result); +			if ($result !== null) +			{ +				$row = @mysqli_fetch_assoc($result); -			$this->sql_server_version = $row['version']; +				$this->sql_server_version = $row['version']; -			if (!empty($cache) && $use_cache) -			{ -				$cache->put('mysqli_version', $this->sql_server_version); +				if (!empty($cache) && $use_cache) +				{ +					$cache->put('mysqli_version', $this->sql_server_version); +				}  			} +			@mysqli_free_result($result);  		}  		return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version; @@ -224,7 +234,7 @@ class mysqli extends \phpbb\db\driver\mysql_base  			return $cache->sql_fetchrow($query_id);  		} -		if ($query_id !== false) +		if ($query_id !== false && $query_id !== null)  		{  			$result = @mysqli_fetch_assoc($query_id);  			return $result !== null ? $result : false; @@ -434,9 +444,12 @@ class mysqli extends \phpbb\db\driver\mysql_base  				$endtime = $endtime[0] + $endtime[1];  				$result = @mysqli_query($this->db_connect_id, $query); -				while ($void = @mysqli_fetch_assoc($result)) +				if ($result !== null)  				{ -					// Take the time spent on parsing rows into account +					while ($void = @mysqli_fetch_assoc($result)) +					{ +						// Take the time spent on parsing rows into account +					}  				}  				@mysqli_free_result($result); diff --git a/phpBB/phpbb/db/migration/data/v30x/local_url_bbcode.php b/phpBB/phpbb/db/migration/data/v30x/local_url_bbcode.php index 139dc95b28..edcc69e1bf 100644 --- a/phpBB/phpbb/db/migration/data/v30x/local_url_bbcode.php +++ b/phpBB/phpbb/db/migration/data/v30x/local_url_bbcode.php @@ -44,9 +44,16 @@ class local_url_bbcode extends \phpbb\db\migration\migration  		{  			if (!class_exists('acp_bbcodes'))  			{ -				global $phpEx; -				phpbb_require_updated('includes/acp/acp_bbcodes.' . $phpEx); +				if (function_exists('phpbb_require_updated')) +				{ +					phpbb_require_updated('includes/acp/acp_bbcodes.' . $this->php_ext); +				} +				else +				{ +					require($this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext); +				}  			} +  			$bbcode_match = $row['bbcode_match'];  			$bbcode_tpl = $row['bbcode_tpl']; diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php new file mode 100644 index 0000000000..20bd547ac3 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php @@ -0,0 +1,31 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class contact_admin_acp_module extends \phpbb\db\migration\migration +{ +	public function update_data() +	{ +		return array( +			array('module.add', array( +				'acp', +				'ACP_BOARD_CONFIGURATION', +				array( +					'module_basename'	=> 'acp_contact', +					'modes'				=> array('contact'), +				), +			)), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php new file mode 100644 index 0000000000..c2dd09ddf6 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php @@ -0,0 +1,41 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class contact_admin_form extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		return isset($this->config['contact_admin_form_enable']); +	} + +	public function update_data() +	{ +		return array( +			array('config.add', array('contact_admin_form_enable', 1)), +			array('custom', array(array($this, 'contact_admin_info'))), +		); +	} + +	public function contact_admin_info() +	{ +		$text_config = new \phpbb\config\db_text($this->db, $this->table_prefix . 'config_text'); +		$text_config->set_array(array( +			'contact_admin_info'			=> '', +			'contact_admin_info_uid'		=> '', +			'contact_admin_info_bitfield'	=> '', +			'contact_admin_info_flags'		=> OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS, +		)); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php new file mode 100644 index 0000000000..aad8e44681 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php @@ -0,0 +1,84 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class passwords_convert_p1 extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v310\passwords_p2'); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'update_passwords'))), +		); +	} + +	public function update_passwords($start) +	{ +		// Nothing to do if user_pass_convert column doesn't exist +		if (!$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_pass_convert')) +		{ +			return; +		} + +		$start = (int) $start; +		$limit = 1000; +		$converted_users = 0; + +		$sql = 'SELECT user_password, user_id +			FROM ' . $this->table_prefix . 'users +			WHERE user_pass_convert = 1 +			ORDER BY user_id'; +		$result = $this->db->sql_query_limit($sql, $limit, $start); + +		$update_users = array(); +		while ($row = $this->db->sql_fetchrow($result)) +		{ +			$converted_users++; + +			$user_id = (int) $row['user_id']; +			// Only prefix passwords without proper prefix +			if (!isset($update_users[$user_id]) && !preg_match('#^\$([a-zA-Z0-9\\\]*?)\$#', $row['user_password'])) +			{ +				// Use $CP$ prefix for passwords that need to +				// be converted and set pass convert to false. +				$update_users[$user_id] = array( +					'user_password'		=> '$CP$' . $row['user_password'], +					'user_pass_convert'	=> 0, +				); +			} +		} +		$this->db->sql_freeresult($result); + +		foreach ($update_users as $user_id => $user_data) +		{ +			$sql = 'UPDATE ' . $this->table_prefix . 'users +				SET ' . $this->db->sql_build_array('UPDATE', $user_data) . ' +				WHERE user_id = ' . $user_id; +			$this->sql_query($sql); +		} + +		if ($converted_users < $limit) +		{ +			// There are no more users to be converted +			return; +		} + +		// There are still more users to query, return the next start value +		return $start + $limit; +	} +} diff --git a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php new file mode 100644 index 0000000000..26a99184a6 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php @@ -0,0 +1,49 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class passwords_convert_p2 extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_pass_convert'); +	} + +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v310\passwords_convert_p1'); +	} + +	public function update_schema() +	{ +		return array( +			'drop_columns'		=> array( +				$this->table_prefix . 'users'		=> array( +					'user_pass_convert', +				), +			), +		); +	} + +	public function revert_schema() +	{ +		return array( +			'add_columns'		=> array( +				$this->table_prefix . 'users'		=> array( +					'user_pass_convert'	=> array('BOOL', 0, 'after' => 'user_passchg'), +				), +			), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_facebook.php b/phpBB/phpbb/db/migration/data/v310/profilefield_facebook.php new file mode 100644 index 0000000000..5964e7a997 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_facebook.php @@ -0,0 +1,60 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_facebook extends \phpbb\db\migration\profilefield_base_migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v310\profilefield_types', +			'\phpbb\db\migration\data\v310\profilefield_show_novalue', +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	protected $profilefield_name = 'phpbb_facebook'; + +	protected $profilefield_database_type = array('VCHAR', ''); + +	protected $profilefield_data = array( +		'field_name'			=> 'phpbb_facebook', +		'field_type'			=> 'profilefields.type.string', +		'field_ident'			=> 'phpbb_facebook', +		'field_length'			=> '20', +		'field_minlen'			=> '5', +		'field_maxlen'			=> '50', +		'field_novalue'			=> '', +		'field_default_value'	=> '', +		'field_validation'		=> '[\w.]+', +		'field_required'		=> 0, +		'field_show_novalue'	=> 0, +		'field_show_on_reg'		=> 0, +		'field_show_on_pm'		=> 1, +		'field_show_on_vt'		=> 1, +		'field_show_profile'	=> 1, +		'field_hide'			=> 0, +		'field_no_view'			=> 0, +		'field_active'			=> 1, +		'field_is_contact'		=> 1, +		'field_contact_desc'	=> 'VIEW_FACEBOOK_PROFILE', +		'field_contact_url'		=> 'http://facebook.com/%s/', +	); +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_googleplus.php b/phpBB/phpbb/db/migration/data/v310/profilefield_googleplus.php new file mode 100644 index 0000000000..9bef0a4c0b --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_googleplus.php @@ -0,0 +1,60 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_googleplus extends \phpbb\db\migration\profilefield_base_migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v310\profilefield_types', +			'\phpbb\db\migration\data\v310\profilefield_show_novalue', +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	protected $profilefield_name = 'phpbb_googleplus'; + +	protected $profilefield_database_type = array('VCHAR', ''); + +	protected $profilefield_data = array( +		'field_name'			=> 'phpbb_googleplus', +		'field_type'			=> 'profilefields.type.googleplus', +		'field_ident'			=> 'phpbb_googleplus', +		'field_length'			=> '20', +		'field_minlen'			=> '3', +		'field_maxlen'			=> '255', +		'field_novalue'			=> '', +		'field_default_value'	=> '', +		'field_validation'		=> '[\w]+', +		'field_required'		=> 0, +		'field_show_novalue'	=> 0, +		'field_show_on_reg'		=> 0, +		'field_show_on_pm'		=> 1, +		'field_show_on_vt'		=> 1, +		'field_show_profile'	=> 1, +		'field_hide'			=> 0, +		'field_no_view'			=> 0, +		'field_active'			=> 1, +		'field_is_contact'		=> 1, +		'field_contact_desc'	=> 'VIEW_GOOGLEPLUS_PROFILE', +		'field_contact_url'		=> 'http://plus.google.com/%s', +	); +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_skype.php b/phpBB/phpbb/db/migration/data/v310/profilefield_skype.php new file mode 100644 index 0000000000..9a5de9d0eb --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_skype.php @@ -0,0 +1,60 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_skype extends \phpbb\db\migration\profilefield_base_migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v310\profilefield_types', +			'\phpbb\db\migration\data\v310\profilefield_show_novalue', +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	protected $profilefield_name = 'phpbb_skype'; + +	protected $profilefield_database_type = array('VCHAR', ''); + +	protected $profilefield_data = array( +		'field_name'			=> 'phpbb_skype', +		'field_type'			=> 'profilefields.type.string', +		'field_ident'			=> 'phpbb_skype', +		'field_length'			=> '20', +		'field_minlen'			=> '6', +		'field_maxlen'			=> '32', +		'field_novalue'			=> '', +		'field_default_value'	=> '', +		'field_validation'		=> '[a-zA-Z][\w\.,\-_]+', +		'field_required'		=> 0, +		'field_show_novalue'	=> 0, +		'field_show_on_reg'		=> 0, +		'field_show_on_pm'		=> 1, +		'field_show_on_vt'		=> 1, +		'field_show_profile'	=> 1, +		'field_hide'			=> 0, +		'field_no_view'			=> 0, +		'field_active'			=> 1, +		'field_is_contact'		=> 1, +		'field_contact_desc'	=> 'VIEW_SKYPE_PROFILE', +		'field_contact_url'		=> 'skype:%s?userinfo', +	); +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_twitter.php b/phpBB/phpbb/db/migration/data/v310/profilefield_twitter.php new file mode 100644 index 0000000000..68d038f609 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_twitter.php @@ -0,0 +1,60 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_twitter extends \phpbb\db\migration\profilefield_base_migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v310\profilefield_types', +			'\phpbb\db\migration\data\v310\profilefield_show_novalue', +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	protected $profilefield_name = 'phpbb_twitter'; + +	protected $profilefield_database_type = array('VCHAR', ''); + +	protected $profilefield_data = array( +		'field_name'			=> 'phpbb_twitter', +		'field_type'			=> 'profilefields.type.string', +		'field_ident'			=> 'phpbb_twitter', +		'field_length'			=> '20', +		'field_minlen'			=> '1', +		'field_maxlen'			=> '15', +		'field_novalue'			=> '', +		'field_default_value'	=> '', +		'field_validation'		=> '[\w_]+', +		'field_required'		=> 0, +		'field_show_novalue'	=> 0, +		'field_show_on_reg'		=> 0, +		'field_show_on_pm'		=> 1, +		'field_show_on_vt'		=> 1, +		'field_show_profile'	=> 1, +		'field_hide'			=> 0, +		'field_no_view'			=> 0, +		'field_active'			=> 1, +		'field_is_contact'		=> 1, +		'field_contact_desc'	=> 'VIEW_TWITTER_PROFILE', +		'field_contact_url'		=> 'http://twitter.com/%s', +	); +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_youtube.php b/phpBB/phpbb/db/migration/data/v310/profilefield_youtube.php new file mode 100644 index 0000000000..bb90c0aa5c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_youtube.php @@ -0,0 +1,60 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_youtube extends \phpbb\db\migration\profilefield_base_migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v310\profilefield_types', +			'\phpbb\db\migration\data\v310\profilefield_show_novalue', +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	protected $profilefield_name = 'phpbb_youtube'; + +	protected $profilefield_database_type = array('VCHAR', ''); + +	protected $profilefield_data = array( +		'field_name'			=> 'phpbb_youtube', +		'field_type'			=> 'profilefields.type.string', +		'field_ident'			=> 'phpbb_youtube', +		'field_length'			=> '20', +		'field_minlen'			=> '3', +		'field_maxlen'			=> '60', +		'field_novalue'			=> '', +		'field_default_value'	=> '', +		'field_validation'		=> '[a-zA-Z][\w\.,\-_]+', +		'field_required'		=> 0, +		'field_show_novalue'	=> 0, +		'field_show_on_reg'		=> 0, +		'field_show_on_pm'		=> 1, +		'field_show_on_vt'		=> 1, +		'field_show_profile'	=> 1, +		'field_hide'			=> 0, +		'field_no_view'			=> 0, +		'field_active'			=> 1, +		'field_is_contact'		=> 1, +		'field_contact_desc'	=> 'VIEW_YOUTUBE_CHANNEL', +		'field_contact_url'		=> 'http://youtube.com/user/%s', +	); +} diff --git a/phpBB/phpbb/db/migration/schema_generator.php b/phpBB/phpbb/db/migration/schema_generator.php index 818e27a362..91d8307d91 100644 --- a/phpBB/phpbb/db/migration/schema_generator.php +++ b/phpBB/phpbb/db/migration/schema_generator.php @@ -217,7 +217,7 @@ class schema_generator  	* Check if one of the migrations files' dependencies can't be resolved  	* by the supplied list of migrations  	* -	* @throws UnexpectedValueException If a dependency can't be resolved +	* @throws \UnexpectedValueException If a dependency can't be resolved  	*/  	protected function check_dependencies()  	{ diff --git a/phpBB/phpbb/db/migration/tool/config.php b/phpBB/phpbb/db/migration/tool/config.php index 1027b425ff..f93e7118c4 100644 --- a/phpBB/phpbb/db/migration/tool/config.php +++ b/phpBB/phpbb/db/migration/tool/config.php @@ -66,6 +66,7 @@ class config implements \phpbb\db\migration\tool\tool_interface  	* 	like to update  	* @param mixed $config_value The value of the config setting  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function update($config_name, $config_value)  	{ @@ -87,6 +88,7 @@ class config implements \phpbb\db\migration\tool\tool_interface  	* 	like to update  	* @param mixed $config_value The value of the config setting  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function update_if_equals($compare, $config_name, $config_value)  	{ diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index 17deb1b19c..db43046a95 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -167,6 +167,7 @@ class module implements \phpbb\db\migration\tool\tool_interface  	* 			modules in that info file.  	* 	path, specify that here  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function add($class, $parent = 0, $data = array())  	{ @@ -331,6 +332,7 @@ class module implements \phpbb\db\migration\tool\tool_interface  	* @param int|string $module The module id|module_langname  	* 	specify that here  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function remove($class, $parent = 0, $module = '')  	{ @@ -466,6 +468,7 @@ class module implements \phpbb\db\migration\tool\tool_interface  	* @param string $class Module Class  	* @param string $basename Module Basename  	* @return array Module Information +	* @throws \phpbb\db\migration\exception  	*/  	protected function get_module_info($class, $basename)  	{ diff --git a/phpBB/phpbb/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php index ba856fbeda..d2df27613a 100644 --- a/phpBB/phpbb/db/migration/tool/permission.php +++ b/phpBB/phpbb/db/migration/tool/permission.php @@ -283,6 +283,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface  	* @param string $old_role_name The old role name  	* @param string $new_role_name The new role name  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function role_update($old_role_name, $new_role_name)  	{ @@ -345,6 +346,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface  	* @param bool $has_permission True if you want to give them permission,  	* 	false if you want to deny them permission  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function permission_set($name, $auth_option, $type = 'role', $has_permission = true)  	{ @@ -490,6 +492,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface  	* 	auth_options you would like to set  	* @param string $type The type (role|group)  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function permission_unset($name, $auth_option, $type = 'role')  	{ diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index 9b9532a7ad..c2f7b5ab23 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -167,8 +167,9 @@ class migrator  	/**  	* Attempts to apply a step of the given migration or one of its dependencies  	* -	* @param	string	The class name of the migration +	* @param	string	$name The class name of the migration  	* @return	bool	Whether any update step was successfully run +	* @throws \phpbb\db\migration\exception  	*/  	protected function try_apply($name)  	{ @@ -302,7 +303,7 @@ class migrator  	/**  	* Attempts to revert a step of the given migration or one of its dependencies  	* -	* @param	string	The class name of the migration +	* @param	string	$name The class name of the migration  	* @return	bool	Whether any update step was successfully run  	*/  	protected function try_revert($name) @@ -368,6 +369,7 @@ class migrator  	* @param bool|string $state Current state of the migration  	* @param bool $revert true to revert a data step  	* @return bool|string migration state. True if completed, serialized array if not finished +	* @throws \phpbb\db\migration\exception  	*/  	protected function process_data_step($steps, $state, $revert = false)  	{ @@ -464,6 +466,7 @@ class migrator  	* @param mixed $last_result Result to pass to the callable (only for 'custom' method)  	* @param bool $reverse False to install, True to attempt uninstallation by reversing the call  	* @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters +	* @throws \phpbb\db\migration\exception  	*/  	protected function get_callable_from_step(array $step, $last_result = 0, $reverse = false)  	{ @@ -714,7 +717,7 @@ class migrator  	/**  	* Load migration data files from a directory  	* -	* @param \phpbb\extension\finder $finder +	* @param \phpbb\finder $finder  	* @param string $path Path to migration data files  	* @param bool $check_fulfillable If TRUE (default), we will check  	* 	if all of the migrations are fulfillable after loading them. @@ -722,8 +725,9 @@ class migrator  	* 	to prevent errors (if including multiple directories, check  	* 	with the last call to prevent throwing errors unnecessarily).  	* @return array Array of migration names +	* @throws \phpbb\db\migration\exception  	*/ -	public function load_migrations(\phpbb\extension\finder $finder, $path, $check_fulfillable = true) +	public function load_migrations(\phpbb\finder $finder, $path, $check_fulfillable = true)  	{  		if (!is_dir($path))  		{ diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 3d065ede8e..2ee842eace 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -1996,7 +1996,7 @@ class tools  				$columns = implode(',', $column_list); -				$new_table_cols = trim(preg_replace('/' . $column_name . '[^,]+(?:,|$)/m', '', $new_table_cols)); +				$new_table_cols = trim(preg_replace('/' . $column_name . '\b[^,]+(?:,|$)/m', '', $new_table_cols));  				if (substr($new_table_cols, -1) === ',')  				{  					// Remove the comma from the last entry again @@ -2561,7 +2561,18 @@ class tools  				foreach ($old_table_cols as $key => $declaration)  				{ -					$entities = preg_split('#\s+#', trim($declaration)); +					$declaration = trim($declaration); + +					// Check for the beginning of the constraint section and stop +					if (preg_match('/[^\(]*\s*PRIMARY KEY\s+\(/', $declaration) || +						preg_match('/[^\(]*\s*UNIQUE\s+\(/', $declaration) || +						preg_match('/[^\(]*\s*FOREIGN KEY\s+\(/', $declaration) || +						preg_match('/[^\(]*\s*CHECK\s+\(/', $declaration)) +					{ +						break; +					} + +					$entities = preg_split('#\s+#', $declaration);  					$column_list[] = $entities[0];  					if ($entities[0] == $column_name)  					{ | 
