alexbevi / redmine_knowledgebase

A knowledgebase plugin for Redmine
452 stars 199 forks source link

Categories and Tags throw 404, multiple projects are combined #402

Open Keksparade opened 2 years ago

Keksparade commented 2 years ago

Hi there,

we love the knowledgebase feature and use it in our team for quite a while. Some time ago we upgraded Redmine from version 4.0.3 to 4.1.1. Since then - it seems - the knowledgebase categories and tags are messed up. We have multiple issues in this context and I'm not quite sure if this is one big issue or if we have multiple issues here. I would really appreciate if you could give me any hint how to solve one or more issues.

  1. At least two of the roundabout 150 tags do not work. Clicking on them results in an "Internal error" and the production log shows:
Started GET "/projects/project-coordination/knowledgebase/categories?author_id=&tag=HowTo" for my.ip.is.here at 2022-07-26 07:25:18 +0000
Processing by CategoriesController#index as HTML
  Parameters: {"author_id"=>"", "tag"=>"HowTo", "project_id"=>"project-coordination"}
  Current user: myusername (id=8)
  Rendering plugins/redmine_knowledgebase/app/views/categories/index.html.erb within layouts/base
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tree_row.html.erb (2.9ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tree_row.html.erb (2.6ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tree_row.html.erb (2.7ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tree.html.erb (9.7ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tags.html.erb (0.1ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tags_used.html.erb (0.4ms)
  Rendered plugins/redmine_knowledgebase/app/views/articles/_list_table.html.erb (8.0ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/index.html.erb within layouts/base (22.2ms)
Completed 500 Internal Server Error in 43ms (ActiveRecord: 8.4ms)

ActionView::Template::Error (undefined method `name' for nil:NilClass):
    51:
    52:       <% unless @author_id %>
    53:         <td class="author">
    54:           <%= link_to article.author.name, { :controller => 'articles',
    55:           :action => 'authored',
    56:           :author_id => article.author.id,
    57:           :project_id => @project} %>

plugins/redmine_knowledgebase/app/views/articles/_list_table.html.erb:54:in `block in _plugins_redmine_knowledgebase_app_views_articles__list_table_html_erb__2506762036978310885_70023877363260'
plugins/redmine_knowledgebase/app/views/articles/_list_table.html.erb:22:in `_plugins_redmine_knowledgebase_app_views_articles__list_table_html_erb__2506762036978310885_70023877363260'
plugins/redmine_knowledgebase/app/views/categories/index.html.erb:31:in `_plugins_redmine_knowledgebase_app_views_categories_index_html_erb__2045731228572261506_47059210984680'
plugins/redmine_knowledgebase/app/controllers/categories_controller.rb:23:in `block (2 levels) in index'
plugins/redmine_knowledgebase/app/controllers/categories_controller.rb:22:in `index'
lib/redmine/sudo_mode.rb:65:in `sudo_mode'

Similar for one of eight categories. Clicking on it results in an "Internal error" and the production.log shows:

Started GET "/projects/project-coordination/knowledgebase/categories/6" for my.ip.is.here at 2022-07-26 07:51:01 +0000
Processing by CategoriesController#show as HTML
  Parameters: {"project_id"=>"project-coordination", "id"=>"6"}
  Current user: myusername (id=8)
  Rendering plugins/redmine_knowledgebase/app/views/categories/show.html.erb within layouts/base
  Rendered plugins/redmine_knowledgebase/app/views/categories/_jump_box.html.erb (11.4ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_watchers.html.erb (6.3ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tree_row.html.erb (2.6ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tree_row.html.erb (2.6ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tree_row.html.erb (2.7ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tree.html.erb (9.7ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tags.html.erb (38.0ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/_tags_used.html.erb (0.0ms)
  Rendered plugins/redmine_knowledgebase/app/views/articles/_list_table.html.erb (247.7ms)
  Rendered plugins/redmine_knowledgebase/app/views/categories/show.html.erb within layouts/base (328.6ms)
Completed 500 Internal Server Error in 365ms (ActiveRecord: 42.3ms)

ActionView::Template::Error (undefined method `name' for nil:NilClass):
    51:
    52:       <% unless @author_id %>
    53:         <td class="author">
    54:           <%= link_to article.author.name, { :controller => 'articles',
    55:           :action => 'authored',
    56:           :author_id => article.author.id,
    57:           :project_id => @project} %>

plugins/redmine_knowledgebase/app/views/articles/_list_table.html.erb:54:in `block in _plugins_redmine_knowledgebase_app_views_articles__list_table_html_erb__2506762036978310885_70023877363260'
plugins/redmine_knowledgebase/app/views/articles/_list_table.html.erb:22:in `_plugins_redmine_knowledgebase_app_views_articles__list_table_html_erb__2506762036978310885_70023877363260'
plugins/redmine_knowledgebase/app/views/categories/show.html.erb:60:in `_plugins_redmine_knowledgebase_app_views_categories_show_html_erb___4293404571247143841_70023882057800'
plugins/redmine_knowledgebase/app/controllers/categories_controller.rb:37:in `block (2 levels) in show'
plugins/redmine_knowledgebase/app/controllers/categories_controller.rb:36:in `show'
lib/redmine/sudo_mode.rb:65:in `sudo_mode'
  1. Knowledgebase is used in multiple redmine projects. The "Jump Category" drop-down shows all categories over all projects. So if you are in project A and accidentally choose a category of project B you get an 404 error.

  2. At the same time it is possible to create an article in project A with the category B assigned to project B. This results in a 404 immediately after creating the article, which is now also assigned to project B.

  3. When editing the article of project B with category B and assigning e.g. category A again it becomes even more confusing. The article can be viewed in project Bs recent articles and it is linked in category A of project A, but clicking on it will result in 404, because the article itself is not part of project A.

  4. I also had a look at the Redmine MySQL database and viewed the articles and categories. It seems like since we did the upgrade almost every article has multiple occurrences in the database. Sometimes even with different category IDs, e.g.:

| id  | category_id | title                                  | author_id | project_id |
+-----+-------------+----------------------------------------+-----------+------------+
| 106 |           1 | My article about something important   |       101 |          5 |
| 107 |           1 | My article about something important   |       101 |          5 |
| 108 |           6 | My article about something important   |       101 |          1 |
| 109 |           5 | My article about something important   |       101 |          5 |
| 111 |           7 | My article about something important   |       101 |        101 |

Any help how to solve this issue would be appreciated. Is there any way to e.g. move all articles to a single project and clean up the categories somehow? Is there an option to delete or edit the category with the Internal Error?