Forum

Welcome to ProjeQtOr new Forum. We migrated old forum to the new website.
You will find all your posts here, with your usual account.
Just one point : you’ll have to reinitialize your password. Use “Lost password” feature.

Problem about Copy ...
 
Notifications
Clear all

Problem about Copy project

9 Posts
3 Users
0 Reactions
11.7 K Views
(@greg35)
Posts: 7
Active Member
Topic starter
 
[#338]

Hi,

We have found a problem when we copy a project

To reproduce this bug follow the next steps :

- Create a new project with a name project1 and a type template
- Create the activities
- Add a new activity with a name "activitySon" and project name "project1"
- Add a new activty with a name "activityFather" and project name "project1"
- Edit the activity "activitySon" and set activity parent to "activity father"
- Goto projects, select the project1 and click on copy project, for the destination project name set project2

As result on the copy we have,

The activity name "activityFather" is on project2 but the activity "activitySon" is on project1 instead of to have a link to the project2.

Best regards.


 
Posted : 08 Feb 2012 12H03
babynus
(@babynus)
Posts: 14953
Main Contributor Admin
 

Hi,
This issue should be fixed in V2.0.0

If you are using V1.9.1 (or less) I should advise you to migrate to V2.0.0.

If you are using V2.0.0, reply to this post so that I will investigate further.

Thanks.


 
Posted : 08 Feb 2012 18H41
(@greg35)
Posts: 7
Active Member
Topic starter
 

Hi,

Thanks you for you reply.
I use the 2.0.0 version.

I can send you a partial bug fix (see below).

The problem is on the copyProjectTo.php, currently the activities are iterated on id field.
Parent activity should not be migrated to the new project when the current activity is saved. A validation error is done in save method and the current activity isn't moved to the new project.

To fix the problem, activities must be ordered by wbsSortable field and not by id field. Navigation tree was done from parent activities to sons activities . The parent activities are moved and saved; then sons activities aremoved and saved. No validation errors occured.

Below the svn patch.

The last problem to resolve: sons activities order in the final project are not saved in the same order as parent. The activiy copy (in foreach statement, line 46) is the problem. It was done on an array sorted by id but not by wbs.

Index: copyProjectTo.php
===================================================================
--- copyProjectTo.php    (revision 450)
+++ copyProjectTo.php    (working copy)
@@ -41,12 +41,17 @@
     // Copy activities
   $activity=New Activity();
   $activities=$activity->getSqlElementsFromCriteria($crit, false, null, null, true);
+ 
   foreach ($activities as $activity) {
       $act=new Activity($activity->id);
     $new=$act->copy();
     $actArrayObj[$new->id]=$new;
     $actArray[$activity->id]=$new->id;
   }
+ 
+  // Sort by wbsSortable
+  usort($actArrayObj, "customSortByWbsSortable");
+ 
     foreach ($actArrayObj as $new) {
         //$new=new Activity($new->id);
         //$new->name='Copied ' . $new->name;
@@ -139,4 +144,12 @@
 } else {
   echo '' . $result . '';
 }
+
+function customSortByWbsSortable($a,$b) {
+    if (strlen($a->ActivityPlanningElement->wbsSortable) == strlen($b->ActivityPlanningElement->wbsSortable) ){
+        return $a->ActivityPlanningElement->wbsSortable > $b->ActivityPlanningElement->wbsSortable;
+    }else {
+        return $a->ActivityPlanningElement->wbsSortable ActivityPlanningElement->wbsSortable;
+    }
+}
 ?>
 No newline at end of file

Best regards


 
Posted : 08 Feb 2012 19H09
babynus
(@babynus)
Posts: 14953
Main Contributor Admin
 

Thnaks for bug fix (even if partial)
Will be implemented / completed in next patch release.


 
Posted : 09 Feb 2012 20H44
(@greg35)
Posts: 7
Active Member
Topic starter
 

Thank you for you reply.

Have you open a bug ?
And if yes, can you send me the number to follow the fix.

Regards,


 
Posted : 10 Feb 2012 10H59
babynus
(@babynus)
Posts: 14953
Main Contributor Admin
 

Ticket #560.


 
Posted : 10 Feb 2012 20H25
babynus
(@babynus)
Posts: 14953
Main Contributor Admin
 

Fixed.

Thanks gerg35. You were almost there, and your analysis was correct.

To fix completely :
- sort array $activities before copying (then copy is in the good order), but sort must preserve keys (use uasort)
- then same issue with milestones : as they are copied after activities, order is not correct (they are alway after activities) : I had to implement array of object that can be of different classes, and adapt sort functionality.

Then it works !


 
Posted : 11 Feb 2012 22H27
(@chris35)
Posts: 17
Active Member
 

Hi Babynus,

I get the v2.0.1 snapshot from the svn repository to test your fix.

When I copy a project, the following error is occured:

Erreur sur finalizeMessageDisplay('resultDiv') :
La destination n'est pas un 'node' ou pas un 'widget'
ou lastOperation or lastOperationStatus n'est pas un 'node'.

Fatal error: Maximum execution time of 30 seconds exceeded in C:projetsprojectorV2.0projectormodelpersistenceSql.php on line 171
Contactez votre administrateur.

My template project have:
- 34 activities, not assigned to resources
- 4 milestones

Where can I configure the timeout to increase the value?
It seems to be a little long time to take more than 30 seconds to copy the project, what do you think about?

Thanks


 
Posted : 13 Feb 2012 13H39
babynus
(@babynus)
Posts: 14953
Main Contributor Admin
 

Where can I configure the timeout to increase the value?

in php.ini,
max_execution_time = 300
or in the php code, for instance in copyProjctTo.php
set_time_limit(300);

It seems to be a little long time to take more than 30 seconds to copy the project, what do you think about?

Yes, it seems quite long... but all depends on your server capacity.
I should have a try...


 
Posted : 13 Feb 2012 20H54
Share:

Scroll to Top