aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/db/migration
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/db/migration')
-rw-r--r--phpBB/phpbb/db/migration/data/v310/acp_style_components_module.php42
-rw-r--r--phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php39
-rw-r--r--phpBB/phpbb/db/migration/data/v310/signature_module_auth.php2
-rw-r--r--phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php4
-rw-r--r--phpBB/phpbb/db/migration/data/v310/softdelete_p1.php37
-rw-r--r--phpBB/phpbb/db/migration/tool/module.php7
6 files changed, 105 insertions, 26 deletions
diff --git a/phpBB/phpbb/db/migration/data/v310/acp_style_components_module.php b/phpBB/phpbb/db/migration/data/v310/acp_style_components_module.php
new file mode 100644
index 0000000000..9f168f4fd6
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v310/acp_style_components_module.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* @package migration
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace phpbb\db\migration\data\v310;
+
+class acp_style_components_module extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ $sql = 'SELECT module_id
+ FROM ' . MODULES_TABLE . "
+ WHERE module_class = 'acp'
+ AND module_langname = 'ACP_STYLE_COMPONENTS'";
+ $result = $this->db->sql_query($sql);
+ $module_id = $this->db->sql_fetchfield('module_id');
+ $this->db->sql_freeresult($result);
+
+ return $module_id == false;
+ }
+
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v310\dev');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('module.remove', array(
+ 'acp',
+ false,
+ 'ACP_STYLE_COMPONENTS',
+ )),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php b/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php
index bd7614e1c2..4195623618 100644
--- a/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php
+++ b/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php
@@ -19,35 +19,44 @@ class notification_options_reconvert extends \phpbb\db\migration\migration
public function update_data()
{
return array(
+ array('custom', array(array($this, 'purge_notifications'))),
array('custom', array(array($this, 'convert_notifications'))),
);
}
- public function convert_notifications()
+ public function purge_notifications()
{
- $insert_table = $this->table_prefix . 'user_notifications';
- $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $insert_table);
+ $sql = 'DELETE FROM ' . $this->table_prefix . 'user_notifications';
+ $this->sql_query($sql);
+ }
+
+ public function convert_notifications($start)
+ {
+ $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'user_notifications');
- $this->perform_conversion($insert_buffer, $insert_table);
+ return $this->perform_conversion($insert_buffer, $start);
}
/**
* Perform the conversion (separate for testability)
*
- * @param \phpbb\db\sql_insert_buffer $insert_buffer
- * @param string $insert_table
+ * @param \phpbb\db\sql_insert_buffer $insert_buffer
+ * @param int $start Start of staggering step
+ * @return mixed int start of the next step, null if the end was reached
*/
- public function perform_conversion(\phpbb\db\sql_insert_buffer $insert_buffer, $insert_table)
+ public function perform_conversion(\phpbb\db\sql_insert_buffer $insert_buffer, $start)
{
- $sql = 'DELETE FROM ' . $insert_table;
- $this->db->sql_query($sql);
+ $limit = 250;
+ $converted_users = 0;
$sql = 'SELECT user_id, user_notify_type, user_notify_pm
- FROM ' . USERS_TABLE;
- $result = $this->db->sql_query($sql);
+ FROM ' . $this->table_prefix . 'users
+ ORDER BY user_id';
+ $result = $this->db->sql_query_limit($sql, $limit, $start);
while ($row = $this->db->sql_fetchrow($result))
{
+ $converted_users++;
$notification_methods = array();
// In-board notification
@@ -91,6 +100,14 @@ class notification_options_reconvert extends \phpbb\db\migration\migration
$this->db->sql_freeresult($result);
$insert_buffer->flush();
+
+ if ($converted_users < $limit)
+ {
+ // No more users left, we are done...
+ return;
+ }
+
+ return $start + $limit;
}
/**
diff --git a/phpBB/phpbb/db/migration/data/v310/signature_module_auth.php b/phpBB/phpbb/db/migration/data/v310/signature_module_auth.php
index a85e0be01c..6da1cb8009 100644
--- a/phpBB/phpbb/db/migration/data/v310/signature_module_auth.php
+++ b/phpBB/phpbb/db/migration/data/v310/signature_module_auth.php
@@ -27,7 +27,7 @@ class signature_module_auth extends \phpbb\db\migration\migration
static public function depends_on()
{
- return array('\phpbb\db\migration\data\v31x\dev');
+ return array('\phpbb\db\migration\data\v310\dev');
}
public function update_data()
diff --git a/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php b/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php
index 2db9780601..d1a31815b2 100644
--- a/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php
+++ b/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php
@@ -28,8 +28,8 @@ class softdelete_mcp_modules extends \phpbb\db\migration\migration
static public function depends_on()
{
return array(
- 'phpbb\db\migration\data\v310\dev',
- 'phpbb\db\migration\data\v310\softdelete_p2',
+ '\phpbb\db\migration\data\v310\dev',
+ '\phpbb\db\migration\data\v310\softdelete_p2',
);
}
diff --git a/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php b/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php
index 0418d5cc2b..f080c78c50 100644
--- a/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php
+++ b/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php
@@ -101,7 +101,8 @@ class softdelete_p1 extends \phpbb\db\migration\migration
return array(
array('custom', array(array($this, 'update_post_visibility'))),
array('custom', array(array($this, 'update_topic_visibility'))),
- array('custom', array(array($this, 'update_topic_forum_counts'))),
+ array('custom', array(array($this, 'update_topics_post_counts'))),
+ array('custom', array(array($this, 'update_forums_topic_and_post_counts'))),
array('permission.add', array('f_softdelete', false)),
array('permission.add', array('m_softdelete', false)),
@@ -122,28 +123,43 @@ class softdelete_p1 extends \phpbb\db\migration\migration
$this->sql_query($sql);
}
- public function update_topic_forum_counts()
+ public function update_topics_post_counts()
{
+ /*
+ * 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.
+ */
$sql = 'UPDATE ' . $this->table_prefix . 'topics
SET topic_posts_approved = topic_replies + 1,
- topic_posts_unapproved = topic_replies_real - topic_replies
+ topic_posts_unapproved = ' . $this->db->sql_case('topic_replies_real > topic_replies', 'topic_replies_real - topic_replies', '0') . '
WHERE topic_visibility = ' . ITEM_APPROVED;
$this->sql_query($sql);
$sql = 'UPDATE ' . $this->table_prefix . 'topics
SET topic_posts_approved = 0,
- topic_posts_unapproved = (topic_replies_real - topic_replies) + 1
+ topic_posts_unapproved = (' . $this->db->sql_case('topic_replies_real > topic_replies', 'topic_replies_real - topic_replies', '0') . ') + 1
WHERE topic_visibility = ' . ITEM_UNAPPROVED;
$this->sql_query($sql);
+ }
+
+ public function update_forums_topic_and_post_counts($start)
+ {
+ $start = (int) $start;
+ $limit = 10;
+ $converted_forums = 0;
$sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS sum_topics, SUM(topic_posts_approved) AS sum_posts_approved, SUM(topic_posts_unapproved) AS sum_posts_unapproved
FROM ' . $this->table_prefix . 'topics
- GROUP BY forum_id, topic_visibility';
- $result = $this->db->sql_query($sql);
+ GROUP BY forum_id, topic_visibility
+ ORDER BY forum_id, topic_visibility';
+ $result = $this->db->sql_query_limit($sql, $limit, $start);
$update_forums = array();
while ($row = $this->db->sql_fetchrow($result))
{
+ $converted_forums++;
+
$forum_id = (int) $row['forum_id'];
if (!isset($update_forums[$forum_id]))
{
@@ -169,5 +185,14 @@ class softdelete_p1 extends \phpbb\db\migration\migration
WHERE forum_id = ' . $forum_id;
$this->sql_query($sql);
}
+
+ if ($converted_forums < $limit)
+ {
+ // There are no more topics, we are done
+ return;
+ }
+
+ // There are still more topics to query, return the next start value
+ return $start + $limit;
}
}
diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php
index 9869dd4230..3e39d87c04 100644
--- a/phpBB/phpbb/db/migration/tool/module.php
+++ b/phpBB/phpbb/db/migration/tool/module.php
@@ -182,9 +182,6 @@ class module implements \phpbb\db\migration\tool\tool_interface
{
// The "automatic" way
$basename = (isset($data['module_basename'])) ? $data['module_basename'] : '';
- $basename = str_replace(array('/', '\\'), '', $basename);
- $class = str_replace(array('/', '\\'), '', $class);
-
$module = $this->get_module_info($class, $basename);
$result = '';
@@ -353,9 +350,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
}
// Automatic method
- $basename = str_replace(array('/', '\\'), '', $module['module_basename']);
- $class = str_replace(array('/', '\\'), '', $class);
-
+ $basename = $module['module_basename'];
$module_info = $this->get_module_info($class, $basename);
foreach ($module_info['modes'] as $mode => $info)