Defect #21155

Deleting invalid wiki page version deletes whole page content

Added by Vasil Kovalevsky about 2 years ago. Updated about 2 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Wiki
Target version:2.6.8
Resolution:Fixed Affected version:3.1.1

Description

Hello.
We just found bug in redmine 3.1.1.
We was need to remove version of the redmine wiki, but we dropped whole wiki page (content).
How it was:
  • user opened "/projects/some our project/wiki/Some_Name_Of_Wiki_Page/history" in two different tabs
  • For example he has 29 versions. And he was need to delete the 29th version.
  • he clicked delete link on first tab for the 29 version
  • ok, was deleted.
  • but user went to the second tab and clicked delete link for the 29th version again
  • whole wiki was removed, but there was 28 versions. And error 500 "undefined method `versions' for nil:NilClass"
    Some piece of log
    …redmine/redmine-3.1/app/controllers/wiki_controller.rb: 210:in `history'
    …k-4.2.4/lib/action_controller/metal/implicit_render.rb:   4:in `send_action'
    …/gems/actionpack-4.2.4/lib/abstract_controller/base.rb: 198:in `process_action'
    …ionpack-4.2.4/lib/action_controller/metal/rendering.rb:  10:in `process_action'
    …/actionpack-4.2.4/lib/abstract_controller/callbacks.rb:  20:in `block in process_action'
    

Why it was:

wiki_controller.rb -> destroy_version

There is 2 lines

@content = @page.content_for_version(params[:version])
@content.destroy

Method of instance WikiPage (@page is) "content_for_version" did not found version (right, it was deleted) and return instance WikiContent instead (variable content - its assotoation to WikiContent by page_id column). And there is dropped the WikiContent instance in the second line in the controller.

def content_for_version(version=nil)
  if content
    result = content.versions.find_by_version(version.to_i) if version
    result ||= content
    result
  end
end
What will be best:
  • check wiki version existing and return 404 (render_404)
    OR
  • just move back to refreshed history page

Of cource, user has a lot of pages opened and he mistaked, when he deleted one version twice. But system can catch same misses.

And, by SubmittingBugs instruction:
Database manager version: MySQL 5.5.46 (MariaDB)
Ruby version: 2.2.1
Rails version: 4.2.4
Redmine version: 3.1.1
Plugins: for check bug we made clear redmine on new server, so, no any plugins.

Associated revisions

Revision 14856
Added by Jean-Philippe Lang about 2 years ago

Fixed that #destroy_version with invalid version destroys wiki page content (#21155).

History

#1 Updated by Toshi MARUYAMA about 2 years ago

  • Subject changed from Removed wiki content when to 500 error when show removed wiki content

#2 Updated by Jean-Philippe Lang about 2 years ago

  • Target version set to 2.6.8

#3 Updated by Toshi MARUYAMA about 2 years ago

  • Subject changed from 500 error when show removed wiki content to error 500 when show removed wiki content

#4 Updated by Jean-Philippe Lang about 2 years ago

  • Subject changed from error 500 when show removed wiki content to Deleting invalid wiki page version deletes whole page content
  • Status changed from New to Resolved
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

#5 Updated by Jean-Philippe Lang about 2 years ago

  • Status changed from Resolved to Closed

Thanks for reporting this. Redmine now responds with 404 in this case.

Also available in: Atom PDF