Project

General

Profile

Actions

Backport(バックポート) #2247

closed

[api] 取得したアクティビティのフィールドに含まれるURLがおかしい

Added by Youichi Kimura over 13 years ago. Updated over 13 years ago.

Status:
Fixed(完了)
Priority:
Normal(通常)
Assignee:
-
Target version:
Start date:
2011-06-21
Due date:
% Done:

100%

Estimated time:

Description

Overview (現象)

下記のように activity_data.uri や activity_image.uri にabsolute URIが含まれる場合に、RESTful API や osapi などでアクティビティを取得した際にURLがおかしな値になる。

sqlite> select * from activity_data;
id|member_id|in_reply_to_activity_id|body|uri|public_flag|is_pc|is_mobile|source|source_uri|foreign_table|foreign_id|template|template_param|created_at|updated_at
1|1||test|http://sns.localhost/|1|1|1|||||||2011-06-02 21:29:57|2011-06-02 21:29:57

sqlite> select * from activity_image;
id|activity_data_id|mime_type|uri|file_id|created_at|updated_at
1|1|image/png|http://www.example.com/image.png||2011-06-02 21:29:58|2011-06-02 21:29:58

APIで取得されるアクティビティ:

{
  "id": "1",
  "userId": "1",
  "title": "test",
  "postedTime": "2011-06-02T21:29:57+09:00",
  "streamUrl": "http:\/\/sns.localhost\/sqlite\/http%3A\/",
  "mediaItems": [
    {
      "url": "http:\/\/sns.localhost\/sqlite\/http%3A\/",
      "type": "image\/png" 
    }
  ]
}

Causes (原因)

lib/util/opJsonDbOpensocialService.class.php にて、各 URL のフィールドに値を設定している箇所でURLがabsoluteであるかないかに関わらず app_url_for を通しているため間違った値に変換されている。

if ($activity->getUri())
{
  $a['streamUrl'] = app_url_for('pc_frontend', $activity->getUri(), true);
}
if ($image->getFileId())
{
  // (snip)
}
else
{
  $mediaItem['url'] = app_url_for('pc_frontend', $image->getUri(), true);
  $mediaItem['type'] = $image->getMimeType();
}

Way to fix (修正内容)

下記のいずれかの方法でこの問題を解決することが可能である。

  • absolute URIの場合には app_url_for を使わないようにopOpenSocialPlugin側で修正する
  • app_url_for にabsolute URIが渡された場合は何もせずにreturnするようにCore側で修正する

Related issues 1 (0 open1 closed)

Related to opOpenSocialPlugin - Bug(バグ) #2231: [api] 取得したアクティビティのフィールドに含まれるURLがおかしいFixed(完了)Youichi Kimura2011-06-21

Actions
Actions #1

Updated by Youichi Kimura over 13 years ago

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

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

Actions #2

Updated by Shogo Kawahara over 13 years ago

  • Status changed from Pending Review(レビュー待ち) to Fixed(完了)
  • % Done changed from 50 to 100
Actions

Also available in: Atom PDF