summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-02-09 08:33:36 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-02-09 08:33:36 +0000
commitc9a19e3084d3d9932dc83f9f61126c7ac5d6e366 (patch)
treeddfd9d8a76e3b1db6556089a0cc4a2ad8ab14679 /database
parent0d89f29a3fd72e328346eb3e06dbb4b4b99bc403 (diff)
downloadbrdo-c9a19e3084d3d9932dc83f9f61126c7ac5d6e366.tar.gz
brdo-c9a19e3084d3d9932dc83f9f61126c7ac5d6e366.tar.bz2
- #48239: Comment thread coding inefficient
Diffstat (limited to 'database')
-rw-r--r--database/updates.inc30
1 files changed, 30 insertions, 0 deletions
diff --git a/database/updates.inc b/database/updates.inc
index b09442529..10c6c5aab 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -1586,3 +1586,33 @@ function system_update_171() {
$ret[] = update_sql('DELETE FROM {users_roles} WHERE rid IN ('. DRUPAL_ANONYMOUS_RID. ', '. DRUPAL_AUTHENTICATED_RID. ')');
return $ret;
}
+
+function system_update_172() {
+ // Multi-part update
+ if (!isset($_SESSION['system_update_172'])) {
+ $_SESSION['system_update_172'] = 0;
+ $_SESSION['system_update_172_max'] = db_result(db_query('SELECT MAX(cid) FROM comments'));
+ }
+
+ include_once './modules/comment.module';
+
+ $limit = 20;
+ $result = db_query_range("SELECT cid, thread FROM {comments} WHERE cid > %d", $_SESSION['system_update_172'], 0, $limit);
+ while ($comment = db_fetch_object($result)) {
+ $_SESSION['system_update_172'] = $comment->cid;
+ $thread = explode('.', rtrim($comment->thread, '/'));
+ foreach ($thread as $i => $offset) {
+ // Decode old-style comment codes: 1,2,...,9,90,91,92,...,99,990,991,...
+ $thread[$i] = int2vancode((strlen($offset) - 1) * 10 + substr($offset, -1, 1));
+ }
+ $thread = implode('.', $thread) .'/';
+ db_query("UPDATE comments SET thread = '%s' WHERE cid = %d", $thread, $comment->cid);
+ }
+
+ if ($_SESSION['system_update_172'] == $_SESSION['system_update_172_max']) {
+ unset($_SESSION['system_update_172']);
+ unset($_SESSION['system_update_172_max']);
+ return array();
+ }
+ return array('#finished' => $_SESSION['system_update_172'] / $_SESSION['system_update_172_max']);
+}