Skip to content

Commit

Permalink
Update existing versions when copying from project
Browse files Browse the repository at this point in the history
Until now, the "Copy Versions From/To" buttons in Manage Projects page
were only adding new versions.

The code has been amended to also update versions existing in the target
project.

Note that since the copy currently ignores obsolete versions, those
marked as such in the source project after an earlier copy operation
will *not* be updated in the target project.

Fixes #10242
  • Loading branch information
dregad committed Sep 17, 2016
1 parent 6119277 commit 9f5dfad
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions manage_proj_ver_copy.php
Expand Up @@ -72,11 +72,30 @@
trigger_error( ERROR_VERSION_NO_ACTION, ERROR );
}

# Get all active versions (i.e. exclude obsolete ones)
$t_rows = version_get_all_rows( $t_src_project_id );

foreach ( $t_rows as $t_row ) {
if( version_is_unique( $t_row['version'], $t_dst_project_id ) ) {
$t_version_id = version_add( $t_dst_project_id, $t_row['version'], $t_row['released'], $t_row['description'], $t_row['date_order'] );
$t_dst_version_id = version_get_id( $t_row['version'], $t_dst_project_id );
if( $t_dst_version_id === false ) {
# Version does not exist in target project
version_add(
$t_dst_project_id,
$t_row['version'],
$t_row['released'],
$t_row['description'],
$t_row['date_order']
);
} else {
# Update existing version
# Since we're ignoring obsolete versions, those marked as such in the
# source project after an earlier copy operation will not be updated
# in the target project.
$t_version_data = new VersionData( $t_row );
$t_version_data->id = $t_dst_version_id;
$t_version_data->project_id = $t_dst_project_id;

version_update( $t_version_data );
}
}

Expand Down

0 comments on commit 9f5dfad

Please sign in to comment.