Project

General

Profile

Actions

Bug(バグ) #3198

closed

opJsonApiActions 内で Content-Type の設定が2度呼び出されている

Added by Youichi Kimura over 12 years ago. Updated almost 8 years ago.

Status:
Won't fix(対応せず)
Priority:
Normal(通常)
Target version:
Start date:
2012-09-11
Due date:
% Done:

0%

Estimated time:
3.6 で発生するか:
Unknown (未調査)
3.8 で発生するか:
Yes (はい)

Description

Overview (現象)

opJsonApiActions クラス内で $this->getResponse()->setContentType('application/json') が execute() メソッドと renderJSON() メソッドで 2 度呼び出されている。また、これによって各 API のアクション内で Content-Type の設定を上書きすることが出来ない。

(現象補足)
apiを使用しているプラグインでは、使用しているjavascriptライブラリとの都合上、content-typeが「text/html」である必要があるものがあります。
(デフォルトでライブラリの中でstringをjsonオブジェクトに変換します。)
そのため、actionsのexecuteXxx()内でcontent-typeの書き換えを行っています。
その変更をopJsonApiActionsのrenderJSON()で「application/json」に再度置き換えられるために不具合発生となります。

Way to fix (修正内容)

opJsonApiActions::renderJSON() メソッド内の setContentType の呼び出しが不要なため除去する。


Related issues 1 (0 open1 closed)

Related to OpenPNE 3 - Backport(バックポート) #3330: opJsonApiActions 内で Content-Type の設定が2度呼び出されているFixed(完了)kaoru n2013-04-15

Actions
Actions #1

Updated by Youichi Kimura over 12 years ago

  • Status changed from New(新規) to Pending Review(レビュー待ち)
  • % Done changed from 0 to 50

更新履歴 942c53165420403f62211ee01f4f2f4000c95457 で適用されました。

Actions #2

Updated by Youichi Kimura over 12 years ago

  • Description updated (diff)
Actions #3

Updated by Youichi Kimura about 12 years ago

  • Status changed from Pending Review(レビュー待ち) to Accepted(着手)
  • % Done changed from 50 to 0

opJsonApiActions::execute() 内にある setContentType も不要な可能性があるため再度確認します。

https://redmine.openpne.jp/projects/op3/repository/revisions/942c53165420403f62211ee01f4f2f4000c95457/entry/lib/action/opJsonApiActions.class.php#L30

Actions #4

Updated by Mutsumi Imamura over 11 years ago

  • 3.8 で発生するか changed from Unknown (未調査) to Yes (はい)
Actions #5

Updated by kaoru n over 11 years ago

https://redmine.openpne.jp/projects/op3/repository/revisions/942c53165420403f62211ee01f4f2f4000c95457/entry/lib/action/opJsonApiActions.class.php#L30
の方を削除すると、content-typeが設定されなくなってしまうため、削除しないでください。

Actions #6

Updated by Yuya Watanabe over 11 years ago

具体的な処理の順番を簡単に書くと

  1. opJsonApiActions の execute() ( setContentType() が呼び出されている)
  2. sfActions の execute()
  3. actions の executeXxx()
  4. opJsonApiActions の renderJSON() ( setContentType() が呼び出されている)

となるため,直接の原因は setContentType() が二回呼び出されていることではなく, アクションの処理を行ったあとに renderJSON() のなかで setContentType() が書き換わってしまうためだと思います.

上記より,説明が不十分であると思います.「Content-Type の設定が2度呼び出されている」ことが原因である十分な説明か,原因が異なる場合はその説明をチケットに記載してください.

Actions #7

Updated by kaoru n over 11 years ago

  • Description updated (diff)
Actions #8

Updated by kaoru n over 11 years ago

原因について

note-6のとおりですが、少しだけ補足します。

apiを使用しているプラグインでは、使用しているjavascriptライブラリとの都合上、content-typeが「text/html」である必要があるものがあります。
(デフォルトでライブラリの中でstringをjsonオブジェクトに変換します。)
そのため、actionsのexecuteXxx()内でcontent-typeの書き換えを行っています。
その変更をopJsonApiActionsのrenderJSON()で「application/json」に再度置き換えられるために不具合発生となります。

上記についてチケット本文にも記載を行いました。

Actions #9

Updated by kaoru n over 11 years ago

  • Status changed from Accepted(着手) to Pending Review(レビュー待ち)
  • % Done changed from 0 to 50

note-3の内容は不要であるため、レビュー待ちに更新します。

Actions #10

Updated by Yuya Watanabe over 11 years ago

  • Status changed from Pending Review(レビュー待ち) to Pending Testing(テスト待ち)
  • % Done changed from 50 to 70
Actions #12

Updated by isao sano almost 8 years ago

  • Status changed from Pending Testing(テスト待ち) to Won't fix(対応せず)
  • % Done changed from 70 to 0

OpenPNE 3.8.6 にて対応済みであったため、対応せずとします。

Actions

Also available in: Atom PDF