ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

Update from 1.x to 2.x impossible under rare but valid circumstances (Bug #633)


Added by Gregor Schmidt at 2011-09-21 10:11 am. Updated at 2011-10-04 03:04 pm.


Status:Closed Start date:2011-09-21
Priority:Normal Due date:
Assignee:Holger Just % Done:

0%

Category:Journals / History
Target version:2.3.0
Remote issue URL: Affected version:

Description

In 1.x WikiContents w/o author where valid. A plugin, we are using - redmine_backlogs - is making use of that fact. When updating to ChiliProject 2.x the migration, that transforms the journals pukes because of that.

I propose to change that migration to assign all WikiContents w/o author to the Anonymous user. This is what is happening automatically when creating WikiContents using the 2.x code base anyway.

Steps to reproduce:

1. Set up ChiliProject 1.5.x

Clone the git repository if ChiliProject and switch to the stable-1.x branch.
Create config/database.yml

Make sure, to run the following rake tasks.

  rake db:create
  rake db:migrate
  rake redmine:load_default_data

2. Create a Wiki Page programatically

Run the following code in a script/console

    project = Project.create(:name => "Test Project", :identifier => 'test_project')
    wiki = project.create_wiki(:start_page => 'Wiki')
    page = wiki.pages.build(:title => "Wiki")
    page.build_content(:text => "h1. Wiki\n\nWiki Page w/o author")

    page.save!

This was done by a plugin, we are using. Namely redmine_backlogs in
https://github.com/relaxdiego/redmine_backlogs/blob/master/app/models/rb_sprint.rb#L157

3. Try to update to ChiliProject 2.x

Switch to the master branch and run

  rake db:migrate

4. See it break

The following output is generated:

  ...

  ==  MergeWikiVersionsWithJournals: migrating ==================================
  rake aborted!
  An error has occurred, all later migrations canceled:

  Mysql::Error: Column 'user_id' cannot be null: INSERT INTO `journals` (`created_at`, `notes`, `journaled_id`, `user_id`, `version`, `type`, `changes`, `activity_type`) VALUES('2011-09-21 11:55:49', '', 1, NULL, 0, 'WikiContentJournal', NULL, 'wiki_edits')

Associated revisions

Revision 3fd809f0
Added by Gregor Schmidt at 2011-10-04 10:27 am

[#633] WikiPages may have no author - but should have

Chili 1.x did not enforce the presence of an author for wiki pages, but Chili 2.x does. This migrations fails, if there are WikiPages or Versions without author. By updating the migration, we may ensure, that the erroneous pages are correctly updated.

Signed-off-by: Holger Just <>

Revision e7f69d42
Added by Holger Just at 2011-10-04 11:12 am

[#633] Fix mock of WikiContent::Version for Ruby 1.9

History

Updated by Gregor Schmidt at 2011-09-21 10:33 am

The script/console code should be

    project = Project.create(:name => "Test Project", :identifier => 'test_project')
    project.reload # to make the wiki available
    page = project.wiki.pages.build(:title => "Wiki")
    page.build_content(:text => "h1. Wiki\n\nWiki Page w/o author")

    page.save!

Updated by Gregor Schmidt at 2011-09-21 11:47 am

A pull request containing a fix is at https://github.com/chiliproject/chiliproject/pull/102.

If update the migration such that the wiki pages, which are invalid in the new version, are fixed before the journal transition is performed. Updating that migration should be save for users of Chili 2.x since, they obviously did not have WikiContents without author.

  • Status changed from Open to Ready for review

Updated by Gregor Schmidt at 2011-09-21 12:21 pm

To clear things up a bit:

WikiContents w/o author are still valid, but somehow, during save, Anonymous or better User.current is assigned as author. I don't known why and how, but I think, this would also deserve some investigation.

Nonetheless, the proposed fix should allow a working transition to Chili 2.x without negative side effects.

Updated by Holger Just at 2011-09-21 12:55 pm

With an empty author, acts_as_journalized defaults to User.current. See https://github.com/chiliproject/chiliproject/blob/master/vendor/plugins/acts_as_journalized/lib/redmine/acts/journalized/save_hooks.rb#L37 And if you ask me, this is a sensible default.

Updated by Gregor Schmidt at 2011-09-21 01:00 pm

On the other hand, WikiContent calls init_journal directly and passes an author, which might be nil. https://github.com/chiliproject/chiliproject/blob/master/app/models/wiki_content.rb#L68

This whole construct seems to be rather fragile. I managed to create a WikiContent where content.journals.map(&:user_id) != content.versions.map(&:user_id) and I don't know how.

Updated by Holger Just at 2011-10-04 08:37 am

You could argue that an empty author is ALWAYS wrong.

The behavior you observe is however the result of init_journal always being called during before save, irregardless of it being called before by hand. That way, an empty author is currently always set to User.current, which, as I said, I consider a good thing.

Anyways, I have merged your patch into master for inclusion into 2.3. Thanks!

Updated by Holger Just at 2011-10-04 03:04 pm

  • Assignee set to Holger Just
  • Status changed from Ready for review to Closed

Also available in: Atom PDF