diff options
author | Joe7 <jozsef.rnagy@site.hu> | 2011-01-06 02:31:50 +0100 |
---|---|---|
committer | Joe7 <jozsef.rnagy@site.hu> | 2011-01-07 17:51:21 +0100 |
commit | c338d3138e2c93bfb219a8d32ba9110138fcf9c2 (patch) | |
tree | 638b36219d6c3be8f8f78220659e5dccd93ce411 /modules/g2_import | |
parent | f2477703faa7cd05ff1aa16da3ecef7b666bef40 (diff) |
Importing Gallery2 users in batches
Fixes Ticket #1554
Diffstat (limited to 'modules/g2_import')
-rw-r--r-- | modules/g2_import/helpers/g2_import.php | 22 | ||||
-rw-r--r-- | modules/g2_import/helpers/g2_import_task.php | 4 |
2 files changed, 23 insertions, 3 deletions
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index b2e3836a..5e2a61e8 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -1155,7 +1155,7 @@ class g2_import_Core { "SELECT [GalleryComment::id] " . "FROM [GalleryComment] " . "WHERE [GalleryComment::publishStatus] = 0 " . // 0 == COMMENT_PUBLISH_STATUS_PUBLISHED - "AND [GalleryComment::id] > ?", + "AND [GalleryComment::id] > ?", array($min_id), array("limit" => array("count" => 100)))); while ($result = $results->nextResult()) { @@ -1184,6 +1184,26 @@ class g2_import_Core { } /** + * Get a set of user ids from Gallery 2 greater than $min_id. We use this to get the + * next chunk of users to import. + */ + static function get_user_ids($min_id) { + global $gallery; + + $ids = array(); + $results = g2($gallery->search( + "SELECT [GalleryUser::id] " . + "FROM [GalleryUser] " . + "WHERE [GalleryUser::id] > ?", + array($min_id), + array("limit" => array("count" => 100)))); + while ($result = $results->nextResult()) { + $ids[] = $result[0]; + } + return $ids; + } + + /** * Look in our map to find the corresponding Gallery 3 id for the given Gallery 2 id. */ static function map($g2_id) { diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php index f2a13291..dbfe5f77 100644 --- a/modules/g2_import/helpers/g2_import_task.php +++ b/modules/g2_import/helpers/g2_import_task.php @@ -109,8 +109,8 @@ class g2_import_task_Core { case "users": if (empty($queue)) { - $task->set( - "queue", $queue = array_keys(g2(GalleryCoreApi::fetchUsersForGroup(GROUP_EVERYBODY)))); + $task->set("queue", $queue = g2_import::get_user_ids($task->get("last_id", 0))); + $task->set("last_id", end($queue)); } $log_message = g2_import::import_user($queue); if ($log_message) { |