Project

General

Profile

Bug(バグ) #2133

プロフィール編集時の値が未入力かどうかの判定処理が適切ではない

Added by Shingo Yamada over 11 years ago. Updated almost 3 years ago.

Status:
New(新規)
Priority:
Low(低め)
Assignee:
-
Target version:
Start date:
2011-05-24
Due date:
% Done:

0%

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

Description

Overview (現象)

プロフィール編集時の値が未入力かどうかの判定処理が適切ではない

確認環境
  • master
  • 2c52d99ee4f105148a125f2be8b189800bb634fe

Causes (原因)

  • 70b3170834b16721c77364173f29d0dfbcf68f83 で、「値が未入力の場合、登録済みのプロフィール項目は削除する」処理の記述が書きなおされている
  • 上記リビジョンで「値が未入力」の判定処理が「if (null === $value['value'])」に変更された
  • 値が未入力の場合でも $value['value'] が NULL になることはないので、下記の if文 の中の処理が実施されることはない
     57       if (null === $value['value'])
     58       {
     59         if ($memberProfile)
     60         {
     61           if ($profile->isMultipleSelect())
     62           {
     63             $memberProfile->clearChildren();
     64           }
     65           $memberProfile->delete();
     66         }
     67         continue;
     68       }
    

現状のソースで「自己紹介」に空文字列を登録した場合のDBの値の変移

before
mysql> select member_profile.id, profile.name, member_profile.value, member_profile.profile_option_id, member_profile.updated_At, member_profile.member_id from member_profile left join profile on profile.id=member_profile.profile_id where member_id=1;
+----+-----------------------------+------------+-------------------+---------------------+-----------+
| id | name                        | value      | profile_option_id | updated_At          | member_id |
+----+-----------------------------+------------+-------------------+---------------------+-----------+
|  1 | op_preset_sex               | Man        |              NULL | 2010-12-23 22:32:20 |         1 |
|  2 | op_preset_birthday          | 1988-04-23 |              NULL | 2010-12-23 22:32:20 |         1 |
|  3 | op_preset_region            | Tokyo      |              NULL | 2010-12-23 22:32:20 |         1 |
|  9 | op_preset_self_introduction | 0          |              NULL | 2011-05-24 20:35:25 |         1 |
| 11 | ニックネーム          | 0          |              NULL | 2011-05-24 20:08:30 |         1 |
+----+-----------------------------+------------+-------------------+---------------------+-----------+
5 rows in set (0.00 sec)
after
mysql> select member_profile.id, profile.name, member_profile.value, member_profile.profile_option_id, member_profile.updated_At, member_profile.member_id from member_profile left join profile on profile.id=member_profile.profile_id where member_id=1;
+----+-----------------------------+------------+-------------------+---------------------+-----------+
| id | name                        | value      | profile_option_id | updated_At          | member_id |
+----+-----------------------------+------------+-------------------+---------------------+-----------+
|  1 | op_preset_sex               | Man        |              NULL | 2010-12-23 22:32:20 |         1 |
|  2 | op_preset_birthday          | 1988-04-23 |              NULL | 2010-12-23 22:32:20 |         1 |
|  3 | op_preset_region            | Tokyo      |              NULL | 2010-12-23 22:32:20 |         1 |
|  9 | op_preset_self_introduction |            |              NULL | 2011-05-24 20:35:44 |         1 |
| 11 | ニックネーム          | 0          |              NULL | 2011-05-24 20:08:30 |         1 |
+----+-----------------------------+------------+-------------------+---------------------+-----------+

Way to fix (修正内容)

理想とするレコードの状態
mysql> select member_profile.id, profile.name, member_profile.value, member_profile.profile_option_id, member_profile.updated_At, member_profile.member_id from member_profile left join profile on profile.id=member_profile.profile_id where member_id=1;
+----+-----------------------------+------------+-------------------+---------------------+-----------+
| id | name                        | value      | profile_option_id | updated_At          | member_id |
+----+-----------------------------+------------+-------------------+---------------------+-----------+
|  1 | op_preset_sex               | Man        |              NULL | 2010-12-23 22:32:20 |         1 |
|  2 | op_preset_birthday          | 1988-04-23 |              NULL | 2010-12-23 22:32:20 |         1 |
|  3 | op_preset_region            | Tokyo      |              NULL | 2010-12-23 22:32:20 |         1 |
| 11 | ニックネーム          | 0          |              NULL | 2011-05-24 20:08:30 |         1 |
+----+-----------------------------+------------+-------------------+---------------------+-----------+

未入力に変更した場合、レコードが削除される状態が理想であると思われる
(現状のソースコードより推察)

修正案

「未入力」の判定を下記に変更する

if (null === $value['value'] || '' === $value['value'])

History

#1 Updated by Shingo Yamada over 11 years ago

現状の実装でも特に問題は発生していないので、優先度は「Low」とする。

#2 Updated by Yuma Sakata almost 11 years ago

  • 3.6 で発生するか set to Yes (はい)
  • 3.4 で発生するか set to Yes (はい)

再現確認

以下バージョンで再現確認できました。

  • OpenPNE3.6.1
  • OpenPNE3.4.18

調査結果

  • 3.6.1
mysql> select member_profile.id, profile.name, member_profile.value, member_profile.profile_option_id, member_profile.updated_At, member_profile.member_id from member_profile left join profile on profile.id=member_profile.profile_id where member_id=1;
+----+-----------------------------+------------+-------------------+---------------------+-----------+
| id | name                        | value      | profile_option_id | updated_At          | member_id |
+----+-----------------------------+------------+-------------------+---------------------+-----------+
|  1 | op_preset_sex               | Man        |              NULL | 2011-12-08 17:24:55 |         1 |
|  2 | op_preset_birthday          | 0001-04-23 |              NULL | 2011-12-16 17:01:27 |         1 |
|  3 | op_preset_region            | Tokyo      |              NULL | 2011-12-08 17:24:55 |         1 |
|  4 | op_preset_self_introduction |            |              NULL | 2011-12-16 17:26:12 |         1 |
+----+-----------------------------+------------+-------------------+---------------------+-----------+
  • 3.4.18
mysql> select member_profile.id, profile.name, member_profile.value, member_profile.profile_option_id, member_profile.updated_At, member_profile.member_id from member_profile left join profile on profile.id=member_profile.profile_id where member_id=1;
+----+-----------------------------+------------+-------------------+---------------------+-----------+
| id | name                        | value      | profile_option_id | updated_At          | member_id |
+----+-----------------------------+------------+-------------------+---------------------+-----------+
|  1 | op_preset_sex               | Man        |              NULL | 2011-12-16 16:16:03 |         1 |
|  2 | op_preset_birthday          | 0001-04-23 |              NULL | 2011-12-16 17:10:54 |         1 |
|  3 | op_preset_region            | Tokyo      |              NULL | 2011-12-16 16:16:03 |         1 |
|  4 | op_preset_self_introduction |            |              NULL | 2011-12-16 17:26:30 |         1 |
+----+-----------------------------+------------+-------------------+---------------------+-----------+

#3 Updated by kaoru n almost 3 years ago

  • Target version set to OpenPNE 3.10.x

Also available in: Atom PDF