From 0d7f61dc7ab8b875b288b2d41ef27aa360973e57 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 18 Dec 2012 13:31:38 +0100 Subject: [PATCH 01/17] [ticket/11166] Use provided custom templates on AJAX confirm box PHPBB3-11166 --- phpBB/assets/javascript/core.js | 2 +- phpBB/includes/functions.php | 8 +++++--- .../styles/prosilver/template/confirm_body.html | 17 +++++++++++++++-- .../prosilver/template/overall_footer.html | 4 +--- phpBB/styles/prosilver/theme/common.css | 7 ++++--- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index f7d6688f68..aab9153003 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -320,7 +320,7 @@ phpbb.ajaxify = function(options) { else { // If confirmation is required, display a diologue to the user. - phpbb.confirm(res.MESSAGE_TEXT, function(del) { + phpbb.confirm(res.MESSAGE_BODY, function(del) { if (del) { phpbb.loading_alert(); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8ef5284134..fe42373862 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3084,8 +3084,9 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo 'YES_VALUE' => $user->lang['YES'], 'S_CONFIRM_ACTION' => $u_action, - 'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields) - ); + 'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields, + 'S_AJAX_REQUEST' => $request->is_ajax(), + )); $sql = 'UPDATE ' . USERS_TABLE . " SET user_last_confirm_key = '" . $db->sql_escape($confirm_key) . "' WHERE user_id = " . $user->data['user_id']; @@ -3097,8 +3098,9 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo $u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id; $json_response = new phpbb_json_response; $json_response->send(array( + 'MESSAGE_BODY' => $template->assign_display('body'), 'MESSAGE_TITLE' => (!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title], - 'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'], + 'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'], 'YES_VALUE' => $user->lang['YES'], 'S_CONFIRM_ACTION' => str_replace('&', '&', $u_action), //inefficient, rewrite whole function diff --git a/phpBB/styles/prosilver/template/confirm_body.html b/phpBB/styles/prosilver/template/confirm_body.html index cddbdee391..4a3de01091 100644 --- a/phpBB/styles/prosilver/template/confirm_body.html +++ b/phpBB/styles/prosilver/template/confirm_body.html @@ -1,3 +1,14 @@ + + +

{MESSAGE_TEXT}

+ +
+   + +
+ + +
@@ -6,10 +17,10 @@

{MESSAGE_TITLE}

{MESSAGE_TEXT}

- +
{S_HIDDEN_FIELDS} -   +  
@@ -18,3 +29,5 @@
+ + diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 7e43ff2d0a..97083b144b 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -36,9 +36,7 @@
-

-   - +
diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 50b22f44df..416c660a2c 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -548,9 +548,9 @@ li.pagination ul { border: 1px solid transparent; position: fixed; display: none; - top: 40%; - left: 35%; - width: 30%; + top: 30%; + left: 25%; + width: 50%; z-index: 50; padding: 25px; padding: 0 25px 20px 25px; @@ -574,6 +574,7 @@ li.pagination ul { .phpbb_alert p { margin: 8px 0; padding-bottom: 8px; + font-size: 1.2em; } #darkenwrapper { From 5028fb981d422111f02fac31fdd48aa8f3da5617 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 15 Jan 2013 13:10:25 +0100 Subject: [PATCH 02/17] [ticket/11166] Fix typo in comment PHPBB3-11166 --- phpBB/assets/javascript/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index aab9153003..0862c553d9 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -319,7 +319,7 @@ phpbb.ajaxify = function(options) { } else { - // If confirmation is required, display a diologue to the user. + // If confirmation is required, display a dialog to the user. phpbb.confirm(res.MESSAGE_BODY, function(del) { if (del) { From 0baa36f6ba1354f0e8ce78fe645392d3968e0e4e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 15 Jan 2013 13:11:01 +0100 Subject: [PATCH 03/17] [ticket/11166] Add caption to AJAX confirm box default template PHPBB3-11166 --- phpBB/styles/prosilver/template/confirm_body.html | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/template/confirm_body.html b/phpBB/styles/prosilver/template/confirm_body.html index 4a3de01091..eb0cad2597 100644 --- a/phpBB/styles/prosilver/template/confirm_body.html +++ b/phpBB/styles/prosilver/template/confirm_body.html @@ -1,5 +1,6 @@ +

{MESSAGE_TITLE}

{MESSAGE_TEXT}

From 3c5eb8bcadb9af8e87525ea6dbf8b5ffc3e7bb26 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 3 Mar 2013 17:23:06 +0100 Subject: [PATCH 04/17] [ticket/11166] Fix several custom confirm templates in prosilver PHPBB3-11166 --- .../prosilver/template/mcp_approve.html | 28 ++++++++++++++++ phpBB/styles/prosilver/template/mcp_move.html | 32 +++++++++++++++++++ phpBB/styles/prosilver/theme/common.css | 17 ++++++++-- 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/mcp_approve.html b/phpBB/styles/prosilver/template/mcp_approve.html index faa88aefc7..6c8215c7c6 100644 --- a/phpBB/styles/prosilver/template/mcp_approve.html +++ b/phpBB/styles/prosilver/template/mcp_approve.html @@ -1,3 +1,30 @@ + + +

{MESSAGE_TITLE}

+

{MESSAGE_TEXT}

+ + + + + + + + + + + +
+   + +
+ + +
@@ -51,3 +78,4 @@
+ diff --git a/phpBB/styles/prosilver/template/mcp_move.html b/phpBB/styles/prosilver/template/mcp_move.html index d7a4f3d798..c2ee25f0d9 100644 --- a/phpBB/styles/prosilver/template/mcp_move.html +++ b/phpBB/styles/prosilver/template/mcp_move.html @@ -1,3 +1,34 @@ + + +

{MESSAGE_TITLE}

+

{MESSAGE_TEXT}

+ +

{ADDITIONAL_MSG}

+ + + + + + + + + + + +
+   + +
+ + +
@@ -35,3 +66,4 @@
+ diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 416c660a2c..0af8e28423 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -548,7 +548,7 @@ li.pagination ul { border: 1px solid transparent; position: fixed; display: none; - top: 30%; + top: 150px; left: 25%; width: 50%; z-index: 50; @@ -574,7 +574,20 @@ li.pagination ul { .phpbb_alert p { margin: 8px 0; padding-bottom: 8px; - font-size: 1.2em; +} + +.phpbb_alert label { + display: block; + margin: 8px 0; + padding-bottom: 8px; +} + +.phpbb_alert div.alert_text > p, +.phpbb_alert div.alert_text > label, +.phpbb_alert div.alert_text > select, +.phpbb_alert div.alert_text > textarea, +.phpbb_alert div.alert_text > input { + font-size: 1.1em; } #darkenwrapper { From 001572f76425a1fdb6621d26dae875438152cc97 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 3 Mar 2013 17:34:01 +0100 Subject: [PATCH 05/17] [ticket/11166] Add ajaxify support to normal ACP confirm_box() Currently no custom template from the ACP uses AJAX support. PHPBB3-11166 --- phpBB/adm/style/admin.css | 21 ++++++++++++++++++--- phpBB/adm/style/confirm_body.html | 14 +++++++++++++- phpBB/adm/style/overall_footer.html | 4 +--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index 8551c952c7..f7a7f9f9bf 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -1098,12 +1098,13 @@ input.disabled { border: 1px solid #999999; position: fixed; display: none; - top: 100px; - left: 35%; - width: 30%; + top: 150px; + left: 25%; + width: 50%; z-index: 50; padding: 25px; padding: 0 25px 20px 25px; + text-align: left; } .phpbb_alert .alert_close { @@ -1127,6 +1128,20 @@ input.disabled { padding-bottom: 8px; } +.phpbb_alert label { + display: block; + margin: 8px 0; + padding-bottom: 8px; +} + +.phpbb_alert div.alert_text > p, +.phpbb_alert div.alert_text > label, +.phpbb_alert div.alert_text > select, +.phpbb_alert div.alert_text > textarea, +.phpbb_alert div.alert_text > input { + font-size: 0.9em; +} + #darkenwrapper { display: none; } diff --git a/phpBB/adm/style/confirm_body.html b/phpBB/adm/style/confirm_body.html index 2fbb1a60d7..d0360d1b3a 100644 --- a/phpBB/adm/style/confirm_body.html +++ b/phpBB/adm/style/confirm_body.html @@ -1,3 +1,15 @@ + + +

{MESSAGE_TITLE}

+

{MESSAGE_TEXT}

+ +
+   + +
+ + +
@@ -14,7 +26,7 @@
- + diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 2bc9ee52d7..bac0cd6625 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -29,9 +29,7 @@
-

-   - +
From 50b557ca4e0a80b3f153bc43f261e6b59e197371 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 4 Mar 2013 22:00:37 +0100 Subject: [PATCH 06/17] [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 07/17] [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 08/17] [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 09/17] [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 10/17] [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 11/17] [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 12/17] [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 13/17] [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 14/17] [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 15/17] [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 16/17] [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')); From 3aab72d79bdad45933e87ebce39483a7664ffd68 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 6 Mar 2013 09:53:41 -0600 Subject: [PATCH 17/17] [ticket/11408] user_jabber instead of jabber PHPBB3-11408 --- phpBB/includes/notification/method/jabber.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/notification/method/jabber.php b/phpBB/includes/notification/method/jabber.php index e3eb571fbc..863846b8a5 100644 --- a/phpBB/includes/notification/method/jabber.php +++ b/phpBB/includes/notification/method/jabber.php @@ -53,7 +53,7 @@ class phpbb_notification_method_jabber extends phpbb_notification_method_email */ public function is_available() { - return ($this->global_available() && $this->user->data['jabber']); + return ($this->global_available() && $this->user->data['user_jabber']); } /**