プロジェクト

全般

プロフィール

Vote #81902

完了

Handle nil return of Redmine::Themes.theme(Setting.ui_theme) in Redmine::Info.environment

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Administration_8
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
8
version_id:
178
issue_org_id:
36932
author_id:
1565
assigned_to_id:
107353
comments:
3
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
155
ステータス-->[Closed]

説明

The code introduced in r21308 for #32116 can trigger an undefined method error in some edge-case(s). See message#67123.
It turns out that it can happen that @Setting.ui_theme.blank?@ returns @false@ while @Redmine::Themes.theme(Setting.ui_theme)@ returns @nil@. This is not expected while sending a message to @Redmine::Themes.theme(Setting.ui_theme).javascripts.include?@ in source:/trunk/lib/redmine/info.rb@21529#L25.

The error can be reproduced (manually) on the console by setting a non-existing value for @Setting.ui_theme@ like e.g. @Setting.ui_theme = 'foo'@ and subsequently sending a message to @Redmine::Info.environment@. This effectively simulates the edge-case that is reported in the forum thread by "Greg G":/users/584287.

This can be solved by changing lines 23-32 in source:/trunk/lib/redmine/info.rb@21529#L23 from:


        theme = Setting.ui_theme.blank? ? 'Default' : Setting.ui_theme.capitalize
        unless Setting.ui_theme.blank?
          theme_js  = (if Redmine::Themes.theme(Setting.ui_theme).javascripts.include?('theme')
                         ' (includes JavaScript)'
                       else
                         ''
                       end
                      )
        end
        theme_string = (theme + theme_js.to_s).to_s
to:

        theme_string = ''
        theme_string += (Setting.ui_theme.blank? ? 'Default' : Setting.ui_theme.capitalize)
        unless Setting.ui_theme.blank? ||
               Redmine::Themes.theme(Setting.ui_theme).nil? ||
               !Redmine::Themes.theme(Setting.ui_theme).javascripts.include?('theme')
          theme_string += ' (includes JavaScript)'
        end

This change also fixes the issue that the @theme_js@ variable is defined conditionally but is unconditionally "used", which I feel is bad practice.

This issue affects 5.0.0 and current source:/trunk@21529.


journals

--------------------------------------------------------------------------------
Committed the patch with a test.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,32116,Add configured theme to Redmine::Info

Admin Redmine さんが約4年前に更新

  • カテゴリAdministration_8 にセット
  • 対象バージョン5.0.1_178 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0