Skip to content

Instantly share code, notes, and snippets.

@jazzl0ver
Created September 8, 2020 12:49
Show Gist options
  • Save jazzl0ver/c61eec1fd544f7d3c1a6e8140e4e5c22 to your computer and use it in GitHub Desktop.
Save jazzl0ver/c61eec1fd544f7d3c1a6e8140e4e5c22 to your computer and use it in GitHub Desktop.
A dirty hack to move MantisBT attachments to disk by 100 at a time. Might be needed to execute it several times. Useful when there're a lot of attachments out there. Don't forget to raise max_execution_time and memory_limit PHP parameters in php.ini.
--- mantisbt-1.3.20/admin/move_attachments.php.orig 2019-09-26 19:42:19.000000000 +0300
+++ mantisbt-1.3.20/admin/move_attachments.php 2020-09-08 15:43:06.000000000 +0300
@@ -175,8 +175,13 @@
# Process projects list
foreach( $p_projects as $t_project ) {
+
+ $start = 0;
+ while ($start <= 1500) {
+ error_log($start);
+
# Retrieve attachments for the project
- $t_result = db_query( $t_query, array( $t_project ) );
+ $t_result = db_query( $t_query, array( $t_project ), 100, $start );
# Project upload path
$t_upload_path = project_get_upload_path( $t_project );
@@ -253,6 +258,9 @@
'data' => $t_data,
);
+ $start += 100;
+ }
+
}
return $t_moved;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment