Defect #7904

Subprojects not properly deleted when deleting a parent project

Added by Tom Skerry over 6 years ago. Updated over 6 years ago.

Status:ClosedStart date:2011-03-17
Priority:HighDue date:
Assignee:-% Done:

0%

Category:Projects
Target version:1.1.3
Resolution:Fixed Affected version:

Description

Redmine version details:
Redmine version 1.1.1
Ruby version 1.8.7 (i386-mingw32)
RubyGems version 1.5.2
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Application root D:/Program Files (x86)/Redmine_Webserver/Redmine
Environment development
Database adapter mysql
Database schema version 0

Cause of bug:
1) Added 10 new projects to our internal Redmine system as sub-projects of another new "parent" project.
2) Deleted parent project containing the 10 new projects. This asks if sure as will delete all sub-projects. Clicked OK, all projects removed successfully.
3) Tried to add new project. On clicking "save" button received 500 internal server error page.
4) Production.log reported:

Processing ProjectsController#create (for 10.1.21.56 at 2011-03-17 11:36:50) [POST]
Parameters: {"commit"=>"Save", "action"=>"create", "authenticity_token"=>"ajshQQHoNa6r2vokeJqZI5HWMpr+TWvFPTLFbmOtyp0=", "project"=>{"name"=>"Code Reviewer", "tracker_ids"=>["1", "2", "3", ""], "homepage"=>"", "parent_id"=>"21", "is_public"=>"1", "description"=>"A web based tool for reviewing code", "identifier"=>"codereviewer", "enabled_module_names"=>["wiki", ""]}, "controller"=>"projects"}

ActiveRecord::StatementInvalid (Mysql::Error: Duplicate entry '25-1' for key 'projects_trackers_unique': INSERT INTO `projects_trackers` (`project_id`, `tracker_id`) VALUES (25, 1)):
app/controllers/projects_controller.rb:78:in `create'

Rendering D:/Program Files (x86)/Redmine_Webserver/Redmine/public/500.html (500 Internal Server Error)

Reason:
Within the projects_trackers table the project_id "25" was already populated. As were "26" through "35". It would appear these weren't cleared out when the previous projects were deleted, either that or the project_id counter was decremented when it shouldn't have been.

Temporary Fix:
Every time a project is created and the 500 internal error screen appears the project_id still gets incremented. Therefore if you try enough times (in my case 10 or 11 times), the project_id will be incremented to a free unique number and the project will save successfully (no 500 screen). The system will then behave itself until more things are deleted in a similar manor. Moral of the story, if it wont save a new project, keep trying until it does!


Related issues

Related to Redmine - Defect #7385: Error when viewing an issue which was related to a delete... Closed 2011-01-20

Associated revisions

Revision 5171
Added by Jean-Philippe Lang over 6 years ago

Fixed: children projects are deleted instead of being destroyed when destroying parent project (#7904).

Revision 5176
Added by Jean-Philippe Lang over 6 years ago

Fixed: news comments not deleted when deleting a project (#7904).

History

#1 Updated by Etienne Massip over 6 years ago

  • Category set to Projects
  • Target version set to Candidate for next minor release

#2 Updated by Jean-Philippe Lang over 6 years ago

  • Subject changed from 500 internal error whilst creating a new project to Subprojects not properly deleted when deleting a parent project
  • Status changed from New to Resolved
  • Target version changed from Candidate for next minor release to 1.1.3
  • Resolution set to Fixed

Fix committed in r5171. Subprojects are now properly destroyed.
Fix relies on r4735 which needs to be merged in 1.1-stable.

#3 Updated by Jean-Philippe Lang over 6 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF