From f78b99dce4057dcb9125af940cb3ca369b2cce48 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 11 May 2014 22:26:17 +0200 Subject: [ticket/12352] Add $CP$ prefix to passwords that need to be converted Also set user_pass_convert to 0 in the process of doing so. PHPBB3-12352 --- .../migration/data/v310/passwords_convert_p1.php | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php (limited to 'phpBB/phpbb/db') 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..24af20cf5c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php @@ -0,0 +1,75 @@ +table_prefix . 'users + WHERE user_pass_convert = 1 + GROUP BY user_id + 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; + } +} -- cgit v1.2.1 From dde92019759e63ec176f05da98742747113944b3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 May 2014 17:46:22 +0200 Subject: [ticket/12352] Remove user_pass_convert column from database PHPBB3-12352 --- .../migration/data/v310/passwords_convert_p2.php | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php (limited to 'phpBB/phpbb/db') 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..3a7d3d2169 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php @@ -0,0 +1,40 @@ + 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'), + ), + ), + ); + } +} -- cgit v1.2.1 From 306beab4cba155a933391c40c75f5dd9c57fd69e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 31 May 2014 14:56:03 +0200 Subject: [ticket/12352] Add checks for existing user_pass_convert to migrations PHPBB3-12352 --- phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php | 6 ++++++ phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php | 5 +++++ 2 files changed, 11 insertions(+) (limited to 'phpBB/phpbb/db') diff --git a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php index 24af20cf5c..a0c7c7eb75 100644 --- a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php +++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php @@ -25,6 +25,12 @@ class passwords_convert_p1 extends \phpbb\db\migration\migration 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; diff --git a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php index 3a7d3d2169..e7d5e4e157 100644 --- a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php +++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php @@ -11,6 +11,11 @@ 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'); -- cgit v1.2.1 From 94b2b64ca199f3db66818c3830c96ea9ff7eeff9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 1 Jun 2014 21:36:53 +0200 Subject: [ticket/12352] Update file headers to fit new format PHPBB3-12352 --- phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php | 10 +++++++--- phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/db') diff --git a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php index a0c7c7eb75..004d94d8bd 100644 --- a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php +++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php index e7d5e4e157..26a99184a6 100644 --- a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php +++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ -- cgit v1.2.1