From 606d82f7dd03da2646333c9ca868071b3e47a970 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 5 Jul 2014 00:57:34 -0700 Subject: [ticket/12812] Add a migrator tool for config_text database changes PHPBB3-12812 --- phpBB/phpbb/db/migration/tool/config_text.php | 125 ++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 phpBB/phpbb/db/migration/tool/config_text.php (limited to 'phpBB/phpbb/db/migration/tool/config_text.php') diff --git a/phpBB/phpbb/db/migration/tool/config_text.php b/phpBB/phpbb/db/migration/tool/config_text.php new file mode 100644 index 0000000000..bf8ac55023 --- /dev/null +++ b/phpBB/phpbb/db/migration/tool/config_text.php @@ -0,0 +1,125 @@ + +* @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\tool; + +/** +* Migration config_text tool +*/ +class config_text implements \phpbb\db\migration\tool\tool_interface +{ + /** @var \phpbb\config\db_text */ + protected $config_text; + + /** + * Constructor + * + * @param \phpbb\config\db_text $config_text + */ + public function __construct(\phpbb\config\db_text $config_text) + { + $this->config_text = $config_text; + } + + /** + * {@inheritdoc} + */ + public function get_name() + { + return 'config_text'; + } + + /** + * Add a config_text setting. + * + * @param string $config_name The name of the config_text setting + * you would like to add + * @param mixed $config_value The value of the config_text setting + * @return null + */ + public function add($config_name, $config_value) + { + if (!is_null($this->config_text->get($config_name))) + { + return; + } + + $this->config_text->set($config_name, $config_value); + } + + /** + * Update an existing config_text setting. + * + * @param string $config_name The name of the config_text setting you would + * like to update + * @param mixed $config_value The value of the config_text setting + * @return null + * @throws \phpbb\db\migration\exception + */ + public function update($config_name, $config_value) + { + if (is_null($this->config_text->get($config_name))) + { + throw new \phpbb\db\migration\exception('CONFIG_NOT_EXIST', $config_name); + } + + $this->config_text->set($config_name, $config_value); + } + + /** + * Remove an existing config_text setting. + * + * @param string $config_name The name of the config_text setting you would + * like to remove + * @return null + */ + public function remove($config_name) + { + if (is_null($this->config_text->get($config_name))) + { + return; + } + + $this->config_text->delete($config_name); + } + + /** + * {@inheritdoc} + */ + public function reverse() + { + $arguments = func_get_args(); + $original_call = array_shift($arguments); + + $call = false; + switch ($original_call) + { + case 'add': + $call = 'remove'; + break; + + case 'remove': + $call = 'add'; + if (sizeof($arguments) == 1) + { + $arguments[] = ''; + } + break; + } + + if ($call) + { + return call_user_func_array(array(&$this, $call), $arguments); + } + } +} -- cgit v1.2.1 From 8e1461ca61e3f452935a1253d3afe65e7322d6bc Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 10 Aug 2016 14:55:39 +0200 Subject: [ticket/14742] Avoid loop while reverting data This combines reverted updata_data and revert_data into a single array. PHPBB3-14742 --- phpBB/phpbb/db/migration/tool/config_text.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/phpbb/db/migration/tool/config_text.php') diff --git a/phpBB/phpbb/db/migration/tool/config_text.php b/phpBB/phpbb/db/migration/tool/config_text.php index bf8ac55023..21b8a8b3a0 100644 --- a/phpBB/phpbb/db/migration/tool/config_text.php +++ b/phpBB/phpbb/db/migration/tool/config_text.php @@ -115,6 +115,11 @@ class config_text implements \phpbb\db\migration\tool\tool_interface $arguments[] = ''; } break; + + case 'reverse': + // It's like double negative + $call = array_shift($arguments); + break; } if ($call) -- cgit v1.2.1 From e050cf5c1163dc18e948ac0706b86743243d72f5 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 20 Aug 2016 03:35:38 +0200 Subject: [ticket/14742] Fix comments in migrator PHPBB3-14742 --- phpBB/phpbb/db/migration/tool/config_text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/db/migration/tool/config_text.php') diff --git a/phpBB/phpbb/db/migration/tool/config_text.php b/phpBB/phpbb/db/migration/tool/config_text.php index 21b8a8b3a0..54b45f6f6d 100644 --- a/phpBB/phpbb/db/migration/tool/config_text.php +++ b/phpBB/phpbb/db/migration/tool/config_text.php @@ -117,7 +117,7 @@ class config_text implements \phpbb\db\migration\tool\tool_interface break; case 'reverse': - // It's like double negative + // Reversing a reverse is just the call itself $call = array_shift($arguments); break; } -- cgit v1.2.1