diff options
Diffstat (limited to 'phpBB/phpbb/db')
20 files changed, 222 insertions, 53 deletions
| diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php index a36ce8c0d7..93f0a749e5 100644 --- a/phpBB/phpbb/db/driver/driver.php +++ b/phpBB/phpbb/db/driver/driver.php @@ -76,6 +76,16 @@ abstract class driver implements driver_interface  	const SUBQUERY_BUILD = 5;  	/** +	* @var bool +	*/ +	protected $debug_load_time = false; + +	/** +	* @var bool +	*/ +	protected $debug_sql_explain = false; + +	/**  	* Constructor  	*/  	function __construct() @@ -98,6 +108,22 @@ abstract class driver implements driver_interface  	/**  	* {@inheritdoc}  	*/ +	public function set_debug_load_time($value) +	{ +		$this->debug_load_time = $value; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function set_debug_sql_explain($value) +	{ +		$this->debug_sql_explain = $value; +	} + +	/** +	* {@inheritdoc} +	*/  	public function get_sql_layer()  	{  		return $this->sql_layer; @@ -955,7 +981,7 @@ abstract class driver implements driver_interface  			// Show complete SQL error and path to administrators only  			// Additionally show complete error on installation or if extended debug mode is enabled  			// The DEBUG constant is for development only! -			if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG')) +			if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || $this->debug_sql_explain)  			{  				$message .= ($sql) ? '<br /><br />SQL<br /><br />' . htmlspecialchars($sql) : '';  			} diff --git a/phpBB/phpbb/db/driver/driver_interface.php b/phpBB/phpbb/db/driver/driver_interface.php index 8b487c5d42..05ff5ef066 100644 --- a/phpBB/phpbb/db/driver/driver_interface.php +++ b/phpBB/phpbb/db/driver/driver_interface.php @@ -16,6 +16,20 @@ namespace phpbb\db\driver;  interface driver_interface  {  	/** +	* Set value for load_time debug parameter +	* +	* @param bool $value +	*/ +	public function set_debug_load_time($value); + +	/** +	* Set value for sql_explain debug parameter +	* +	* @param bool $value +	*/ +	public function set_debug_sql_explain($value); + +	/**  	* Gets the name of the sql layer.  	*  	* @return string diff --git a/phpBB/phpbb/db/driver/factory.php b/phpBB/phpbb/db/driver/factory.php index fb3a826254..bb6e7a2682 100644 --- a/phpBB/phpbb/db/driver/factory.php +++ b/phpBB/phpbb/db/driver/factory.php @@ -68,6 +68,22 @@ class factory implements driver_interface  	/**  	* {@inheritdoc}  	*/ +	public function set_debug_load_time($value) +	{ +		$this->get_driver()->set_debug_load_time($value); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function set_debug_sql_explain($value) +	{ +		$this->get_driver()->set_debug_sql_explain($value); +	} + +	/** +	* {@inheritdoc} +	*/  	public function get_sql_layer()  	{  		return $this->get_driver()->get_sql_layer(); diff --git a/phpBB/phpbb/db/driver/mssql_odbc.php b/phpBB/phpbb/db/driver/mssql_odbc.php index 9d9ad603e0..06cdce7a15 100644 --- a/phpBB/phpbb/db/driver/mssql_odbc.php +++ b/phpBB/phpbb/db/driver/mssql_odbc.php @@ -151,12 +151,11 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  		{  			global $cache; -			// EXPLAIN only in extra debug mode -			if (defined('DEBUG')) +			if ($this->debug_sql_explain)  			{  				$this->sql_report('start', $query);  			} -			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			else if ($this->debug_load_time)  			{  				$this->curtime = microtime(true);  			} @@ -172,11 +171,11 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  					$this->sql_error($query);  				} -				if (defined('DEBUG')) +				if ($this->debug_sql_explain)  				{  					$this->sql_report('stop', $query);  				} -				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				else if ($this->debug_load_time)  				{  					$this->sql_time += microtime(true) - $this->curtime;  				} @@ -196,7 +195,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG')) +			else if ($this->debug_sql_explain)  			{  				$this->sql_report('fromcache', $query);  			} diff --git a/phpBB/phpbb/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php index a4dcac5966..30ef9d9bc4 100644 --- a/phpBB/phpbb/db/driver/mssqlnative.php +++ b/phpBB/phpbb/db/driver/mssqlnative.php @@ -123,12 +123,11 @@ class mssqlnative extends \phpbb\db\driver\mssql_base  		{  			global $cache; -			// EXPLAIN only in extra debug mode -			if (defined('DEBUG')) +			if ($this->debug_sql_explain)  			{  				$this->sql_report('start', $query);  			} -			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			else if ($this->debug_load_time)  			{  				$this->curtime = microtime(true);  			} @@ -146,11 +145,11 @@ class mssqlnative extends \phpbb\db\driver\mssql_base  				// reset options for next query  				$this->query_options = array(); -				if (defined('DEBUG')) +				if ($this->debug_sql_explain)  				{  					$this->sql_report('stop', $query);  				} -				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				else if ($this->debug_load_time)  				{  					$this->sql_time += microtime(true) - $this->curtime;  				} @@ -170,7 +169,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG')) +			else if ($this->debug_sql_explain)  			{  				$this->sql_report('fromcache', $query);  			} diff --git a/phpBB/phpbb/db/driver/mysql.php b/phpBB/phpbb/db/driver/mysql.php index a94e88b331..8ce70444c2 100644 --- a/phpBB/phpbb/db/driver/mysql.php +++ b/phpBB/phpbb/db/driver/mysql.php @@ -171,12 +171,11 @@ class mysql extends \phpbb\db\driver\mysql_base  		{  			global $cache; -			// EXPLAIN only in extra debug mode -			if (defined('DEBUG')) +			if ($this->debug_sql_explain)  			{  				$this->sql_report('start', $query);  			} -			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			else if ($this->debug_load_time)  			{  				$this->curtime = microtime(true);  			} @@ -191,11 +190,11 @@ class mysql extends \phpbb\db\driver\mysql_base  					$this->sql_error($query);  				} -				if (defined('DEBUG')) +				if ($this->debug_sql_explain)  				{  					$this->sql_report('stop', $query);  				} -				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				else if ($this->debug_load_time)  				{  					$this->sql_time += microtime(true) - $this->curtime;  				} @@ -215,7 +214,7 @@ class mysql extends \phpbb\db\driver\mysql_base  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG')) +			else if ($this->debug_sql_explain)  			{  				$this->sql_report('fromcache', $query);  			} @@ -390,7 +389,7 @@ class mysql extends \phpbb\db\driver\mysql_base  	{  		static $test_prof; -		// current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING +		// current detection method, might just switch to see the existence of INFORMATION_SCHEMA.PROFILING  		if ($test_prof === null)  		{  			$test_prof = false; diff --git a/phpBB/phpbb/db/driver/mysqli.php b/phpBB/phpbb/db/driver/mysqli.php index d43e201526..df8b88c315 100644 --- a/phpBB/phpbb/db/driver/mysqli.php +++ b/phpBB/phpbb/db/driver/mysqli.php @@ -173,12 +173,11 @@ class mysqli extends \phpbb\db\driver\mysql_base  		{  			global $cache; -			// EXPLAIN only in extra debug mode -			if (defined('DEBUG')) +			if ($this->debug_sql_explain)  			{  				$this->sql_report('start', $query);  			} -			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			else if ($this->debug_load_time)  			{  				$this->curtime = microtime(true);  			} @@ -193,11 +192,11 @@ class mysqli extends \phpbb\db\driver\mysql_base  					$this->sql_error($query);  				} -				if (defined('DEBUG')) +				if ($this->debug_sql_explain)  				{  					$this->sql_report('stop', $query);  				} -				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				else if ($this->debug_load_time)  				{  					$this->sql_time += microtime(true) - $this->curtime;  				} @@ -212,7 +211,7 @@ class mysqli extends \phpbb\db\driver\mysql_base  					$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);  				}  			} -			else if (defined('DEBUG')) +			else if ($this->debug_sql_explain)  			{  				$this->sql_report('fromcache', $query);  			} @@ -373,7 +372,7 @@ class mysqli extends \phpbb\db\driver\mysql_base  	{  		static $test_prof; -		// current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING +		// current detection method, might just switch to see the existence of INFORMATION_SCHEMA.PROFILING  		if ($test_prof === null)  		{  			$test_prof = false; diff --git a/phpBB/phpbb/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php index 5fd14709f8..f2a0bb557a 100644 --- a/phpBB/phpbb/db/driver/oracle.php +++ b/phpBB/phpbb/db/driver/oracle.php @@ -246,12 +246,11 @@ class oracle extends \phpbb\db\driver\driver  		{  			global $cache; -			// EXPLAIN only in extra debug mode -			if (defined('DEBUG')) +			if ($this->debug_sql_explain)  			{  				$this->sql_report('start', $query);  			} -			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			else if ($this->debug_load_time)  			{  				$this->curtime = microtime(true);  			} @@ -428,11 +427,11 @@ class oracle extends \phpbb\db\driver\driver  					}  				} -				if (defined('DEBUG')) +				if ($this->debug_sql_explain)  				{  					$this->sql_report('stop', $query);  				} -				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				else if ($this->debug_load_time)  				{  					$this->sql_time += microtime(true) - $this->curtime;  				} @@ -452,7 +451,7 @@ class oracle extends \phpbb\db\driver\driver  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG')) +			else if ($this->debug_sql_explain)  			{  				$this->sql_report('fromcache', $query);  			} diff --git a/phpBB/phpbb/db/driver/postgres.php b/phpBB/phpbb/db/driver/postgres.php index 44476612c3..ed330bc540 100644 --- a/phpBB/phpbb/db/driver/postgres.php +++ b/phpBB/phpbb/db/driver/postgres.php @@ -173,12 +173,11 @@ class postgres extends \phpbb\db\driver\driver  		{  			global $cache; -			// EXPLAIN only in extra debug mode -			if (defined('DEBUG')) +			if ($this->debug_sql_explain)  			{  				$this->sql_report('start', $query);  			} -			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			else if ($this->debug_load_time)  			{  				$this->curtime = microtime(true);  			} @@ -194,11 +193,11 @@ class postgres extends \phpbb\db\driver\driver  					$this->sql_error($query);  				} -				if (defined('DEBUG')) +				if ($this->debug_sql_explain)  				{  					$this->sql_report('stop', $query);  				} -				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				else if ($this->debug_load_time)  				{  					$this->sql_time += microtime(true) - $this->curtime;  				} @@ -218,7 +217,7 @@ class postgres extends \phpbb\db\driver\driver  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG')) +			else if ($this->debug_sql_explain)  			{  				$this->sql_report('fromcache', $query);  			} diff --git a/phpBB/phpbb/db/driver/sqlite3.php b/phpBB/phpbb/db/driver/sqlite3.php index 0508500c52..43906f1b58 100644 --- a/phpBB/phpbb/db/driver/sqlite3.php +++ b/phpBB/phpbb/db/driver/sqlite3.php @@ -118,12 +118,11 @@ class sqlite3 extends \phpbb\db\driver\driver  		{  			global $cache; -			// EXPLAIN only in extra debug mode -			if (defined('DEBUG')) +			if ($this->debug_sql_explain)  			{  				$this->sql_report('start', $query);  			} -			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			else if ($this->debug_load_time)  			{  				$this->curtime = microtime(true);  			} @@ -156,11 +155,11 @@ class sqlite3 extends \phpbb\db\driver\driver  					}  				} -				if (defined('DEBUG')) +				if ($this->debug_sql_explain)  				{  					$this->sql_report('stop', $query);  				} -				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				else if ($this->debug_load_time)  				{  					$this->sql_time += microtime(true) - $this->curtime;  				} @@ -175,7 +174,7 @@ class sqlite3 extends \phpbb\db\driver\driver  					$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);  				}  			} -			else if (defined('DEBUG')) +			else if ($this->debug_sql_explain)  			{  				$this->sql_report('fromcache', $query);  			} diff --git a/phpBB/phpbb/db/extractor/mysql_extractor.php b/phpBB/phpbb/db/extractor/mysql_extractor.php index 34e309c19e..534e8b7653 100644 --- a/phpBB/phpbb/db/extractor/mysql_extractor.php +++ b/phpBB/phpbb/db/extractor/mysql_extractor.php @@ -300,7 +300,7 @@ class mysql_extractor extends base_extractor  	}  	/** -	* Extracts database table structure (for MySQL verisons older than 3.23.20) +	* Extracts database table structure (for MySQL versions older than 3.23.20)  	*  	* @param	string	$table_name	name of the database table  	* @return null diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_4_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_4_rc1.php index 10343438b3..247ccc7a76 100644 --- a/phpBB/phpbb/db/migration/data/v30x/release_3_0_4_rc1.php +++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_4_rc1.php @@ -117,7 +117,7 @@ class release_3_0_4_rc1 extends \phpbb\db\migration\migration  			}  			else  			{ -				// equivelant to "none", which is the "Display in user control panel" option +				// equivalent to "none", which is the "Display in user control panel" option  				$sql_ary['field_show_profile'] = 1;  			} diff --git a/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php b/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php index b1e7486e24..877cdc2fa3 100644 --- a/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php +++ b/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php @@ -132,7 +132,7 @@ class softdelete_p1 extends \phpbb\db\migration\migration  		/*  		* Using sql_case here to avoid "BIGINT UNSIGNED value is out of range" errors.  		* As we update all topics in 2 queries, one broken topic would stop the conversion -		* for all topics and the surpressed error will cause the admin to not even notice it. +		* for all topics and the suppressed error will cause the admin to not even notice it.  		*/  		$sql = 'UPDATE ' . $this->table_prefix . 'topics  			SET topic_posts_approved = topic_replies + 1, diff --git a/phpBB/phpbb/db/migration/data/v330/dev.php b/phpBB/phpbb/db/migration/data/v330/dev.php new file mode 100644 index 0000000000..209f9fc7ec --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v330/dev.php @@ -0,0 +1,36 @@ +<?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\v330; + +class dev extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		return version_compare($this->config['version'], '3.3.0-dev', '>='); +	} + +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v32x\v327', +		); +	} + +	public function update_data() +	{ +		return array( +			array('config.update', array('version', '3.3.0-dev')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v330/remove_attachment_flash.php b/phpBB/phpbb/db/migration/data/v330/remove_attachment_flash.php new file mode 100644 index 0000000000..11dc43483b --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v330/remove_attachment_flash.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\v330; + +class remove_attachment_flash extends \phpbb\db\migration\migration +{ +	// Following constants were deprecated in 3.3 +	// and moved from constants.php to compatibility_globals.php, +	// thus define them as class constants +	const ATTACHMENT_CATEGORY_FLASH = 5; + +	protected $cat_id = array( +			self::ATTACHMENT_CATEGORY_FLASH, +		); + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'remove_flash_group'))), +		); +	} + +	public function remove_flash_group() +	{ +		// select group ids of outdated media +		$sql = 'SELECT group_id +			FROM ' . EXTENSION_GROUPS_TABLE . ' +			WHERE ' . $this->db->sql_in_set('cat_id', $this->cat_id); +		$result = $this->db->sql_query($sql); + +		$group_ids = array(); +		while ($group_id = (int) $this->db->sql_fetchfield('group_id')) +		{ +			$group_ids[] = $group_id; +		} +		$this->db->sql_freeresult($result); + +		// nothing to do, admin has removed all the outdated media extension groups +		if (empty($group_ids)) +		{ +			return true; +		} + +		// get the group id of downloadable files +		$sql = 'SELECT group_id +			FROM ' . EXTENSION_GROUPS_TABLE . " +			WHERE group_name = 'DOWNLOADABLE_FILES'"; +		$result = $this->db->sql_query($sql); +		$download_id = (int) $this->db->sql_fetchfield('group_id'); +		$this->db->sql_freeresult($result); + +		if (empty($download_id)) +		{ +			$sql = 'UPDATE ' . EXTENSIONS_TABLE . ' +				SET group_id = 0 +				WHERE ' . $this->db->sql_in_set('group_id', $group_ids); +		} +		else +		{ +			// move outdated media extensions to downloadable files +			$sql = 'UPDATE ' . EXTENSIONS_TABLE . " +				SET group_id = $download_id" . ' +				WHERE ' . $this->db->sql_in_set('group_id', $group_ids); +		} + +		$this->db->sql_query($sql); + +		// delete the now empty, outdated media extension groups +		$sql = 'DELETE FROM ' . EXTENSION_GROUPS_TABLE . ' +			WHERE ' . $this->db->sql_in_set('group_id', $group_ids); +		$this->db->sql_query($sql); +	} +} diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index e5133c8152..93c338437e 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -509,7 +509,7 @@ class module implements \phpbb\db\migration\tool\tool_interface  	* Get parent module id  	*  	* @param string|int $parent_id The parent module_id|module_langname -	* @param int|string|array $data The module_id, module_langname for existance checking or module data array for adding +	* @param int|string|array $data The module_id, module_langname for existence checking or module data array for adding  	* @param bool $throw_exception The flag indicating if exception should be thrown on error  	* @return mixed The int parent module_id, an array of int parent module_id values or false  	* @throws \phpbb\db\migration\exception diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index 2b0c66fc58..3a1ee758cf 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -784,7 +784,7 @@ class migrator  				{  					return array(  						$parameters[0], -						array($last_result), +						isset($parameters[1]) ? array_merge($parameters[1], array($last_result)) : array($last_result),  					);  				}  			break; diff --git a/phpBB/phpbb/db/tools/mssql.php b/phpBB/phpbb/db/tools/mssql.php index cbedf9a5c4..29f816a869 100644 --- a/phpBB/phpbb/db/tools/mssql.php +++ b/phpBB/phpbb/db/tools/mssql.php @@ -194,7 +194,7 @@ class mssql extends tools  				$primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set'];  			} -			// create sequence DDL based off of the existance of auto incrementing columns +			// create sequence DDL based off of the existence of auto incrementing columns  			if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'])  			{  				$create_sequence = $column_name; diff --git a/phpBB/phpbb/db/tools/postgres.php b/phpBB/phpbb/db/tools/postgres.php index 077d6e06f9..276ac135be 100644 --- a/phpBB/phpbb/db/tools/postgres.php +++ b/phpBB/phpbb/db/tools/postgres.php @@ -141,7 +141,7 @@ class postgres extends tools  				$primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set'];  			} -			// create sequence DDL based off of the existance of auto incrementing columns +			// create sequence DDL based off of the existence of auto incrementing columns  			if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'])  			{  				$create_sequence = $column_name; diff --git a/phpBB/phpbb/db/tools/tools.php b/phpBB/phpbb/db/tools/tools.php index c3352a1f66..d128df96c4 100644 --- a/phpBB/phpbb/db/tools/tools.php +++ b/phpBB/phpbb/db/tools/tools.php @@ -335,7 +335,7 @@ class tools implements tools_interface  				$primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set'];  			} -			// create sequence DDL based off of the existance of auto incrementing columns +			// create sequence DDL based off of the existence of auto incrementing columns  			if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'])  			{  				$create_sequence = $column_name; | 
