From 50b557ca4e0a80b3f153bc43f261e6b59e197371 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 4 Mar 2013 22:00:37 +0100 Subject: [PATCH 01/11] [ticket/10202] Implementation of config options with arbitrary length values. PHPBB3-10202 --- phpBB/includes/config/db_text.php | 157 ++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 phpBB/includes/config/db_text.php diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php new file mode 100644 index 0000000000..79f83391f8 --- /dev/null +++ b/phpBB/includes/config/db_text.php @@ -0,0 +1,157 @@ +db = $db; + $this->table = $table; + } + + /** + * Sets the configuration option with the name $key to $value. + * + * @param string $key The configuration option's name + * @param string $value New configuration value + * + * @return null + */ + public function set($key, $value) + { + $this->setAll(array($key => $value)); + } + + /** + * Gets the configuration value for the name $key. + * + * @param string $key The configuration option's name + * + * @return string|null String result on success + * null if there is no such option + */ + public function get($key) + { + $map = $this->getAll(array($key)); + + return isset($map[$key]) ? $map[$key] : null; + } + + /** + * Removes a configuration option + * + * @param string $key The configuration option's name + * + * @return null + */ + public function delete($key) + { + $this->deleteAll(array($key)); + } + + /** + * Sets a configuration option's value + * + * @param array $map Map from configuration names to values + * + * @return null + */ + public function setAll(array $map) + { + $this->db->sql_transaction('begin'); + + foreach ($map as $key => $value) + { + $sql = 'UPDATE ' . $this->table . " + SET config_value = '" . $this->db->sql_escape($value) . "' + WHERE config_name = '" . $this->db->sql_escape($key) . "'"; + $result = $this->db->sql_query($sql); + + if (!$this->db->sql_affectedrows($result)) + { + $sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', array( + 'config_name' => $key, + 'config_value' => $value, + )); + $this->db->sql_query($sql); + } + } + + $this->db->sql_transaction('commit'); + } + + /** + * Gets a set of configuration options as a key => value map. + * + * @param array $keys Set of configuration option names + * + * @return array Map from configuration names to values + */ + public function getAll(array $keys) + { + $sql = 'SELECT * + FROM ' . $this->table . ' + WHERE ' . $this->db->sql_in_set('config_name', $keys, false, true); + $result = $this->db->sql_query($sql); + + $map = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $map[$row['config_name']] = $row['config_value']; + } + + return $map; + } + + /** + * Removes multiple configuration options + * + * @param array $keys Set of configuration option names + * + * @return null + */ + public function deleteAll(array $keys) + { + $sql = 'DELETE + FROM ' . $this->table . ' + WHERE ' . $this->db->sql_in_set('config_name', $keys, false, true); + $result = $this->db->sql_query($sql); + } +} From 3a5d3bdd686e93539d51d8f1a78a5489192f73ef Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 02:22:09 +0100 Subject: [PATCH 02/11] [ticket/10202] Add database schema for phpbb_config_db_text. PHPBB3-10202 --- phpBB/develop/create_schema_files.php | 8 ++++++++ phpBB/install/schemas/firebird_schema.sql | 9 +++++++++ phpBB/install/schemas/mssql_schema.sql | 17 +++++++++++++++++ phpBB/install/schemas/mysql_40_schema.sql | 8 ++++++++ phpBB/install/schemas/mysql_41_schema.sql | 8 ++++++++ phpBB/install/schemas/oracle_schema.sql | 11 +++++++++++ phpBB/install/schemas/postgres_schema.sql | 10 ++++++++++ phpBB/install/schemas/sqlite_schema.sql | 8 ++++++++ 8 files changed, 79 insertions(+) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index a9caee2e25..907d177678 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -998,6 +998,14 @@ function get_schema_struct() ), ); + $schema_data['phpbb_config_text'] = array( + 'COLUMNS' => array( + 'config_name' => array('VCHAR', ''), + 'config_value' => array('TEXT', ''), + ), + 'PRIMARY_KEY' => 'config_name', + ); + $schema_data['phpbb_confirm'] = array( 'COLUMNS' => array( 'confirm_id' => array('CHAR:32', ''), diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 3f813ef9b9..18ca184c65 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -222,6 +222,15 @@ ALTER TABLE phpbb_config ADD PRIMARY KEY (config_name);; CREATE INDEX phpbb_config_is_dynamic ON phpbb_config(is_dynamic);; +# Table: 'phpbb_config_text' +CREATE TABLE phpbb_config_text ( + config_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + config_value BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_config_text ADD PRIMARY KEY (config_name);; + + # Table: 'phpbb_confirm' CREATE TABLE phpbb_confirm ( confirm_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 30e95954d4..07c269ea3f 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -293,6 +293,23 @@ CREATE INDEX [is_dynamic] ON [phpbb_config]([is_dynamic]) ON [PRIMARY] GO +/* + Table: 'phpbb_config_text' +*/ +CREATE TABLE [phpbb_config_text] ( + [config_name] [varchar] (255) DEFAULT ('') NOT NULL , + [config_value] [varchar] (8000) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_config_text] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_config_text] PRIMARY KEY CLUSTERED + ( + [config_name] + ) ON [PRIMARY] +GO + + /* Table: 'phpbb_confirm' */ diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 3bf8c22488..b432cd4aa2 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -157,6 +157,14 @@ CREATE TABLE phpbb_config ( ); +# Table: 'phpbb_config_text' +CREATE TABLE phpbb_config_text ( + config_name varbinary(255) DEFAULT '' NOT NULL, + config_value blob NOT NULL, + PRIMARY KEY (config_name) +); + + # Table: 'phpbb_confirm' CREATE TABLE phpbb_confirm ( confirm_id binary(32) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 93348b2015..5842d35fc7 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -157,6 +157,14 @@ CREATE TABLE phpbb_config ( ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +# Table: 'phpbb_config_text' +CREATE TABLE phpbb_config_text ( + config_name varchar(255) DEFAULT '' NOT NULL, + config_value text NOT NULL, + PRIMARY KEY (config_name) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + # Table: 'phpbb_confirm' CREATE TABLE phpbb_confirm ( confirm_id char(32) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 4dd151e54b..35f05e34cd 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -331,6 +331,17 @@ CREATE TABLE phpbb_config ( CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic) / +/* + Table: 'phpbb_config_text' +*/ +CREATE TABLE phpbb_config_text ( + config_name varchar2(255) DEFAULT '' , + config_value clob DEFAULT '' , + CONSTRAINT pk_phpbb_config_text PRIMARY KEY (config_name) +) +/ + + /* Table: 'phpbb_confirm' */ diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 77481add59..c0df97bd8f 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -269,6 +269,16 @@ CREATE TABLE phpbb_config ( CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); +/* + Table: 'phpbb_config_text' +*/ +CREATE TABLE phpbb_config_text ( + config_name varchar(255) DEFAULT '' NOT NULL, + config_value varchar(8000) DEFAULT '' NOT NULL, + PRIMARY KEY (config_name) +); + + /* Table: 'phpbb_confirm' */ diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 7dd1fe70f6..d14f6797d0 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -154,6 +154,14 @@ CREATE TABLE phpbb_config ( CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); +# Table: 'phpbb_config_text' +CREATE TABLE phpbb_config_text ( + config_name varchar(255) NOT NULL DEFAULT '', + config_value text(65535) NOT NULL DEFAULT '', + PRIMARY KEY (config_name) +); + + # Table: 'phpbb_confirm' CREATE TABLE phpbb_confirm ( confirm_id char(32) NOT NULL DEFAULT '', From a73b76cb24bcbde96735d343d2a22e6723de8390 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 02:26:46 +0100 Subject: [PATCH 03/11] [ticket/10202] Adjust method names to guidelines. PHPBB3-10202 --- phpBB/includes/config/db_text.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php index 79f83391f8..05ba4ddabf 100644 --- a/phpBB/includes/config/db_text.php +++ b/phpBB/includes/config/db_text.php @@ -56,7 +56,7 @@ class phpbb_config_db_text */ public function set($key, $value) { - $this->setAll(array($key => $value)); + $this->set_all(array($key => $value)); } /** @@ -69,7 +69,7 @@ class phpbb_config_db_text */ public function get($key) { - $map = $this->getAll(array($key)); + $map = $this->get_all(array($key)); return isset($map[$key]) ? $map[$key] : null; } @@ -83,7 +83,7 @@ class phpbb_config_db_text */ public function delete($key) { - $this->deleteAll(array($key)); + $this->delete_all(array($key)); } /** @@ -93,7 +93,7 @@ class phpbb_config_db_text * * @return null */ - public function setAll(array $map) + public function set_all(array $map) { $this->db->sql_transaction('begin'); @@ -124,7 +124,7 @@ class phpbb_config_db_text * * @return array Map from configuration names to values */ - public function getAll(array $keys) + public function get_all(array $keys) { $sql = 'SELECT * FROM ' . $this->table . ' @@ -147,7 +147,7 @@ class phpbb_config_db_text * * @return null */ - public function deleteAll(array $keys) + public function delete_all(array $keys) { $sql = 'DELETE FROM ' . $this->table . ' From 828c6c01bb3ffff4d58f1bea1aad82663d656f2c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 03:10:57 +0100 Subject: [PATCH 04/11] [ticket/10202] Add tests for phpbb_config_db_text. PHPBB3-10202 --- tests/config/db_text_test.php | 115 ++++++++++++++++++++++++++ tests/config/fixtures/config_text.xml | 19 +++++ 2 files changed, 134 insertions(+) create mode 100644 tests/config/db_text_test.php create mode 100644 tests/config/fixtures/config_text.xml diff --git a/tests/config/db_text_test.php b/tests/config/db_text_test.php new file mode 100644 index 0000000000..03e581fead --- /dev/null +++ b/tests/config/db_text_test.php @@ -0,0 +1,115 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/config_text.xml'); + } + + public function setUp() + { + parent::setUp(); + + $this->db = $this->new_dbal(); + $this->config_text = new phpbb_config_db_text($this->db, 'phpbb_config_text'); + } + + public function test_get() + { + $this->assertSame('23', $this->config_text->get('foo')); + $this->assertSame('string-de-ding', $this->config_text->get('meh')); + } + + public function test_get_nonexisting() + { + $this->assertNull($this->config_text->get('noooooo')); + } + + public function test_set_new_get() + { + $this->config_text->set('barz', 'phpbb'); + $this->assertSame('phpbb', $this->config_text->get('barz')); + } + + public function test_set_replace_get() + { + $this->config_text->set('foo', '24'); + $this->assertSame('24', $this->config_text->get('foo')); + } + + public function test_set_get_long_string() + { + $expected = str_repeat('ABC', 10000); + $this->config_text->set('long', $expected); + $this->assertSame($expected, $this->config_text->get('long')); + } + + public function test_delete_get() + { + $this->config_text->delete('foo'); + $this->assertNull($this->config_text->get('foo')); + + $this->assertSame('42', $this->config_text->get('bar')); + $this->assertSame('string-de-ding', $this->config_text->get('meh')); + } + + public function test_get_all_empty() + { + $this->assertEmpty($this->config_text->get_all(array('key1', 'key2'))); + } + + public function test_get_all_subset() + { + $expected = array( + 'bar' => '42', + 'foo' => '23', + ); + + $actual = $this->config_text->get_all(array_keys($expected)); + ksort($actual); + + $this->assertSame($expected, $actual); + } + + public function test_set_all_get_all_subset() + { + $set_all_param = array( + // New entry + 'baby' => 'phpBB', + // Entry update + 'bar' => '64', + ); + + $this->config_text->set_all($set_all_param); + + $expected = array_merge($set_all_param, array( + 'foo' => '23', + )); + + $actual = $this->config_text->get_all(array_keys($expected)); + ksort($actual); + + $this->assertSame($expected, $actual); + } + + public function test_delete_all_get_remaining() + { + $this->config_text->delete_all(array('foo', 'bar')); + + $this->assertNull($this->config_text->get('bar')); + $this->assertNull($this->config_text->get('foo')); + + $this->assertSame('string-de-ding', $this->config_text->get('meh')); + } +} diff --git a/tests/config/fixtures/config_text.xml b/tests/config/fixtures/config_text.xml new file mode 100644 index 0000000000..5acac13ea3 --- /dev/null +++ b/tests/config/fixtures/config_text.xml @@ -0,0 +1,19 @@ + + + + config_name + config_value + + foo + 23 + + + bar + 42 + + + meh + string-de-ding + +
+
From 722092fe546025deeba487f18a34db0e60ca6f1c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 03:13:27 +0100 Subject: [PATCH 05/11] [ticket/10202] Define phpbb_config_db_text as a service. PHPBB3-10202 --- phpBB/config/services.yml | 6 ++++++ phpBB/config/tables.yml | 1 + 2 files changed, 7 insertions(+) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 7b2a24b2b3..b9c71844dc 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -58,6 +58,12 @@ services: - @cache.driver - %tables.config% + config_text: + class: phpbb_config_db_text + arguments: + - @dbal.conn + - %tables.config_text% + controller.helper: class: phpbb_controller_helper arguments: diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index b3093abf0c..1191fd0ae1 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -1,5 +1,6 @@ parameters: tables.config: %core.table_prefix%config + tables.config_text: %core.table_prefix%config_text tables.ext: %core.table_prefix%ext tables.log: %core.table_prefix%log tables.notification_types: %core.table_prefix%notification_types From 95764c4f0e6b1ceef7b14e2394637891482ade43 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 03:41:26 +0100 Subject: [PATCH 06/11] [ticket/10202] Add $this->db->sql_freeresult($result) to SELECT queries. PHPBB3-10202 --- phpBB/includes/config/db_text.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php index 05ba4ddabf..0c18675ffc 100644 --- a/phpBB/includes/config/db_text.php +++ b/phpBB/includes/config/db_text.php @@ -136,6 +136,7 @@ class phpbb_config_db_text { $map[$row['config_name']] = $row['config_value']; } + $this->db->sql_freeresult($result); return $map; } From af02681960257a1df344275b2a1eb2893bc470df Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 03:43:51 +0100 Subject: [PATCH 07/11] [ticket/10202] SQL escape the table name. PHPBB3-10202 --- phpBB/includes/config/db_text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php index 0c18675ffc..7563a228f5 100644 --- a/phpBB/includes/config/db_text.php +++ b/phpBB/includes/config/db_text.php @@ -43,7 +43,7 @@ class phpbb_config_db_text public function __construct(phpbb_db_driver $db, $table) { $this->db = $db; - $this->table = $table; + $this->table = $this->db->sql_escape($table); } /** From 0071ad3bfd88780af24ebf9cb4d02eac76369994 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 04:02:05 +0100 Subject: [PATCH 08/11] [ticket/10202] Improve method documentation. PHPBB3-10202 --- phpBB/includes/config/db_text.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php index 7563a228f5..6449a2e02b 100644 --- a/phpBB/includes/config/db_text.php +++ b/phpBB/includes/config/db_text.php @@ -75,7 +75,7 @@ class phpbb_config_db_text } /** - * Removes a configuration option + * Removes the configuration option with the name $key. * * @param string $key The configuration option's name * @@ -87,7 +87,9 @@ class phpbb_config_db_text } /** - * Sets a configuration option's value + * Mass set configuration options: Receives an associative array, + * treats array keys as configuration option names and associated + * array values as their configuration option values. * * @param array $map Map from configuration names to values * @@ -118,7 +120,10 @@ class phpbb_config_db_text } /** - * Gets a set of configuration options as a key => value map. + * Mass get configuration options: Receives a set of configuration + * option names and returns the result as a key => value map where + * array keys are configuration option names and array values are + * associated config option values. * * @param array $keys Set of configuration option names * @@ -142,7 +147,7 @@ class phpbb_config_db_text } /** - * Removes multiple configuration options + * Mass delete configuration options. * * @param array $keys Set of configuration option names * From 5158224845d4d21fc3d4bbb62ff3e0d798285071 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 22:39:41 +0100 Subject: [PATCH 09/11] [ticket/10202] Upgrade TEXT to the bigger MTEXT. PHPBB3-10202 --- phpBB/develop/create_schema_files.php | 2 +- phpBB/install/schemas/mssql_schema.sql | 4 ++-- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/sqlite_schema.sql | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 907d177678..b454fb2c16 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1001,7 +1001,7 @@ function get_schema_struct() $schema_data['phpbb_config_text'] = array( 'COLUMNS' => array( 'config_name' => array('VCHAR', ''), - 'config_value' => array('TEXT', ''), + 'config_value' => array('MTEXT', ''), ), 'PRIMARY_KEY' => 'config_name', ); diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 07c269ea3f..3530f9cd25 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -298,8 +298,8 @@ GO */ CREATE TABLE [phpbb_config_text] ( [config_name] [varchar] (255) DEFAULT ('') NOT NULL , - [config_value] [varchar] (8000) DEFAULT ('') NOT NULL -) ON [PRIMARY] + [config_value] [text] DEFAULT ('') NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO ALTER TABLE [phpbb_config_text] WITH NOCHECK ADD diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index b432cd4aa2..8c405677a8 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -160,7 +160,7 @@ CREATE TABLE phpbb_config ( # Table: 'phpbb_config_text' CREATE TABLE phpbb_config_text ( config_name varbinary(255) DEFAULT '' NOT NULL, - config_value blob NOT NULL, + config_value mediumblob NOT NULL, PRIMARY KEY (config_name) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 5842d35fc7..cb259aa57d 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -160,7 +160,7 @@ CREATE TABLE phpbb_config ( # Table: 'phpbb_config_text' CREATE TABLE phpbb_config_text ( config_name varchar(255) DEFAULT '' NOT NULL, - config_value text NOT NULL, + config_value mediumtext NOT NULL, PRIMARY KEY (config_name) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index c0df97bd8f..6dc507b46d 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -274,7 +274,7 @@ CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); */ CREATE TABLE phpbb_config_text ( config_name varchar(255) DEFAULT '' NOT NULL, - config_value varchar(8000) DEFAULT '' NOT NULL, + config_value TEXT DEFAULT '' NOT NULL, PRIMARY KEY (config_name) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index d14f6797d0..ccb67ad46f 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -157,7 +157,7 @@ CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); # Table: 'phpbb_config_text' CREATE TABLE phpbb_config_text ( config_name varchar(255) NOT NULL DEFAULT '', - config_value text(65535) NOT NULL DEFAULT '', + config_value mediumtext(16777215) NOT NULL DEFAULT '', PRIMARY KEY (config_name) ); From 3a4b34ca3240c5f66faae8faa1c50baea1d6e108 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 22:58:19 +0100 Subject: [PATCH 10/11] [ticket/10202] Add migration file for config_db_text. PHPBB3-10202 --- .../db/migration/data/310/config_db_text.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 phpBB/includes/db/migration/data/310/config_db_text.php diff --git a/phpBB/includes/db/migration/data/310/config_db_text.php b/phpBB/includes/db/migration/data/310/config_db_text.php new file mode 100644 index 0000000000..89f211adda --- /dev/null +++ b/phpBB/includes/db/migration/data/310/config_db_text.php @@ -0,0 +1,45 @@ +db_tools->sql_table_exists($this->table_prefix . 'config_text'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_11'); + } + + public function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'config_text' => array( + 'COLUMNS' => array( + 'config_name' => array('VCHAR', ''), + 'config_value' => array('MTEXT', ''), + ), + 'PRIMARY_KEY' => 'config_name', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'config_text', + ), + ); + } +} From 32ff2348f10aed1aad3b78e7677dca34335b7adb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 23:15:46 +0100 Subject: [PATCH 11/11] [ticket/10202] Rename method names _all() to _array(). PHPBB3-10202 --- phpBB/includes/config/db_text.php | 12 ++++++------ tests/config/db_text_test.php | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php index 6449a2e02b..b365cb5c77 100644 --- a/phpBB/includes/config/db_text.php +++ b/phpBB/includes/config/db_text.php @@ -56,7 +56,7 @@ class phpbb_config_db_text */ public function set($key, $value) { - $this->set_all(array($key => $value)); + $this->set_array(array($key => $value)); } /** @@ -69,7 +69,7 @@ class phpbb_config_db_text */ public function get($key) { - $map = $this->get_all(array($key)); + $map = $this->get_array(array($key)); return isset($map[$key]) ? $map[$key] : null; } @@ -83,7 +83,7 @@ class phpbb_config_db_text */ public function delete($key) { - $this->delete_all(array($key)); + $this->delete_array(array($key)); } /** @@ -95,7 +95,7 @@ class phpbb_config_db_text * * @return null */ - public function set_all(array $map) + public function set_array(array $map) { $this->db->sql_transaction('begin'); @@ -129,7 +129,7 @@ class phpbb_config_db_text * * @return array Map from configuration names to values */ - public function get_all(array $keys) + public function get_array(array $keys) { $sql = 'SELECT * FROM ' . $this->table . ' @@ -153,7 +153,7 @@ class phpbb_config_db_text * * @return null */ - public function delete_all(array $keys) + public function delete_array(array $keys) { $sql = 'DELETE FROM ' . $this->table . ' diff --git a/tests/config/db_text_test.php b/tests/config/db_text_test.php index 03e581fead..4818bba8c9 100644 --- a/tests/config/db_text_test.php +++ b/tests/config/db_text_test.php @@ -64,48 +64,48 @@ class phpbb_config_db_text_test extends phpbb_database_test_case $this->assertSame('string-de-ding', $this->config_text->get('meh')); } - public function test_get_all_empty() + public function test_get_array_empty() { - $this->assertEmpty($this->config_text->get_all(array('key1', 'key2'))); + $this->assertEmpty($this->config_text->get_array(array('key1', 'key2'))); } - public function test_get_all_subset() + public function test_get_array_subset() { $expected = array( 'bar' => '42', 'foo' => '23', ); - $actual = $this->config_text->get_all(array_keys($expected)); + $actual = $this->config_text->get_array(array_keys($expected)); ksort($actual); $this->assertSame($expected, $actual); } - public function test_set_all_get_all_subset() + public function test_set_array_get_array_subset() { - $set_all_param = array( + $set_array_param = array( // New entry 'baby' => 'phpBB', // Entry update 'bar' => '64', ); - $this->config_text->set_all($set_all_param); + $this->config_text->set_array($set_array_param); - $expected = array_merge($set_all_param, array( + $expected = array_merge($set_array_param, array( 'foo' => '23', )); - $actual = $this->config_text->get_all(array_keys($expected)); + $actual = $this->config_text->get_array(array_keys($expected)); ksort($actual); $this->assertSame($expected, $actual); } - public function test_delete_all_get_remaining() + public function test_delete_array_get_remaining() { - $this->config_text->delete_all(array('foo', 'bar')); + $this->config_text->delete_array(array('foo', 'bar')); $this->assertNull($this->config_text->get('bar')); $this->assertNull($this->config_text->get('foo'));