ソフトウェアエンジニアリング - バグ #7 Redmine の Wiki 記法で thumbnail マクロを使うと 使用した添付ファイル画像のリンクが壊れる 2014/03/12 22:47 - 高橋徹 ステータス : フィードバック開始日 : 2014/03/12 優先度 : 通常期日 : 担当者 : 進捗率 : 50% カテゴリ : 予定工数 : 0.00 時間 対象バージョン : 作業時間 : 0.00 時間 重要度 : 説明 thumbnail マクロで指定した添付画像ファイルのリンクにコメントが結合してしまい リンクが 404 となる 例としてこのチケットに画像ファイルを添付し thumbnail マクロで指定した 144 関連するチケット : 関連しているバグ #82: Redmineで同じ添付ファイルを指すthumbnailマクロを新規 2つ記述すると2018/06/17 2つ目... 履歴 #1-2014/03/12 22:49 - 高橋徹 - 説明を更新 #2-2014/03/12 23:39 - 高橋徹 添付ファイルのリンクを生成していると思われる箇所 app/views/issues/show.html.erb 85 <%= link_to_attachments @issue, :thumbnails => true %> link_to_attachments を定義している箇所を捜索 app/helpers/attachments_helper.rb 25 def link_to_attachments(container, options = {}) 26 options.assert_valid_keys(:author, :thumbnails) 27 28 if container.attachments.any? 29 options = {:deletable => container.attachments_deletable?, :a 30 render :partial => 'attachments/links', 31 :locals => {:attachments => container.attachments, :options abled?)} 32 end 33 end 30 行目の render :partial で リンクのレンダリングは app/views/attachments/_links.html.erb に 1 <div class="attachments"> 2 <% for attachment in attachments %> 3 <p><%= link_to_attachment attachment, :class => 'icon icon-attachme 4 <% if attachment.is_text? %> 5 <%= link_to image_tag('magnifier.png'), 6 :controller => 'attachments', :action => 'show', 7 :id => attachment, :filename => attachment.filename 8 <% end %> 9 <%= h(" - #{attachment.description}") unless attachment.descripti 2018/12/06 1/5
10 <span class="size">(<%= number_to_human_size attachment.filesize 11 <% if options[:deletable] %> 12 <%= link_to image_tag('delete.png'), attachment_path(attachment 13 :data => {:confirm => l(:t 14 :method => :delete, 15 :class => 'delete', 16 :title => l(:button_delete 17 <% end %> 18 <% if options[:author] %> 19 <span class="author"><%= h(attachment.author) %>, <%= format_ti ment.created_on) %></span> 20 <% end %> 21 </p> 22 <% end %> 23 <% if defined?(thumbnails) && thumbnails %> 24 <% images = attachments.select(&:thumbnailable?) %> 25 <% if images.any? %> 26 <div class="thumbnails"> 27 <% images.each do attachment %> 28 <div><%= thumbnail_tag(attachment) %></div> 29 <% end %> 30 </div> 31 <% end %> 32 <% end %> 33 </div> このファイルの中で懸案のリンクを生成しているのは 3 <p><%= link_to_attachment attachment, :class => 'icon icon-attachme link_to_attachment を定義しているファイルを検索すると app/helpers/application_helper.rb であ 94 def link_to_attachment(attachment, options={}) 95 text = options.delete(:text) attachment.filename 96 route_method = options.delete(:download)? :download_named_att 97 html_options = options.slice!(:only_path) 98 url = send(route_method, attachment, attachment.filename, opti 99 link_to text, url, html_options 100 end 2018/12/06 2/5
#3-2014/03/12 23:46 - 高橋徹 app/helpers/application_helper.rb にデバッグ用の print を埋め込んだ 99 print("qqq)text=#{text}\n") 100 link_to text, url, html_options print 文の結果は次のとおり QQQ)text= 片倉小十郎.jpg ( 戦国 BASARA の片倉小十郎 伊達政宗の宰相 ) この時点で ファイル名がおかしい #4-2014/03/14 11:11 - 高橋徹 app/helpers/application_helper.rb 95 text = options.delete(:text) attachment.filename のところでデバッグプリントを埋め込み調べると QQQ)attachment.filename= 片倉小十郎.jpg ( 戦国 BASARA の片倉小十郎 伊達政宗の宰相 ) QQQ)options.delete(:text)= となった これは引数に渡されてくる attachment の問題だ 呼び出し元は app/views/attachments/_links.html.erb 1 <div class="attachments"> 2 <% for attachment in attachments %> 3 <p><%= link_to_attachment attachment, :class => 'icon icon-attach で さらにここを呼び出す元は app/helpers/attachments_helper.rb 30 render :partial => 'attachments/links', 31 :locals => {:attachments => container.attachments, :optio ls_enabled?)} と container.attachments が指定されている container をここの関数 link_to_attachments に渡している元は app/views/issues/show.html.erb 85 <%= link_to_attachments @issue, :thumbnails => true %> 2018/12/06 3/5
の @issue 部分である ここで container.attachments は モデルの attachment のリストであろうと検討をつけ app/models/atta うむ さっぱり分からん app/helpers/application_helper.rb の次のメソッドの引数 attachment を詳細に見る 94 def link_to_attachment(attachment, options={}) ++ print("qqq)attachment.inspect=#{attachment.inspect}\n") 実行結果は QQQ)attachment.inspect=#<Attachment id: 1, container_id: 2, container_t 伊達政宗の宰相 )", disk_filename: "140303000143_0606daee01577da6c199ba439c7ef40 964675bb6f3bb70a6c0fde40af4", downloads: 0, author_id: 1, created_on: " 達政宗の宰相 ", disk_directory: "2014/03"> となり filename が ファイル名 +' '+'('+description の内容 +')' となっている Wiki ページの thumbnail マクロを削除して実行すると QQQ)attachment.inspect=#<Attachment id: 1, container_id: 2, container_t 143_0606daee01577da6c199ba439c7ef40e.jpg", filesize: 74596, content_typ 0, author_id: 1, created_on: "2014-03-02 15:01:43", description: " 戦国 BA となり filename が ファイル名となっている MySQL のデータベースを調べても thumbnail マクロの有無に関わらず filename そこで これは実行時にフックか何か thumbnail の存在によって働きかけているのかと推測し 'thumbnail' の言葉を検索し app/c ments_controller.rb が怪しそうと目星をつけて調べてみる ちょっとわからない うむ #5-2014/03/16 13:32 - 高橋徹 - ステータスを新規から進行中に変更 - 進捗率を 0 から 50 に変更 2018/12/06 4/5
Powered by TCPDF (www.tcpdf.org) #6-2015/11/20 20:44 - 高橋徹 - ステータスを進行中から終了に変更 - 進捗率を 50 から 100 に変更 Redmine 3.0.3 ではこのバグが解消している #7-2018/06/17 20:48 - 高橋徹 redmine 3.4 ではこのバグが復活している #8-2018/06/17 20:49 - 高橋徹 - 関連しているバグ #82: Redmine で同じ添付ファイルを指す thumbnail マクロを 2 つ記述すると 2 つ目で not found エラ #9-2018/06/17 20:49 - 高橋徹 - ステータスを終了からフィードバックに変更 - 進捗率を 100 から 50 に変更 ファイル alos-1.png ( 陸域観測技術衛星 だいち (ALOS) 93.7 KB2014/03/12 高橋徹 2018/12/06 5/5