Project

General

Profile

Bug(バグ) #1502

error at the application cascading of doctrine.(Doctrineのカスケーディングデリート 時にエラーになる)

Added by Masato Nagasawa about 9 years ago. Updated almost 4 years ago.

Status:
Fixed(完了)
Priority:
Normal(通常)
Target version:
Start date:
2010-08-03
Due date:
% Done:

100%

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

Description

Overview (現象)

Doctrine側でカスケーディングデリートを有効にした場合、日記を削除しようとするとエラーになります。

Causes (原因)

lib/behavior/opApplicationLevelCascadingListener.class.php の 32行目でエラーになっており、
$record が空の配列であるにも関わらずdelete()を呼んでいてメソッドが解決できずエラーとなっています。

Way to fix (修正内容)

$relations が Doctrine_Collection でない場合に array($relations) としているのが原因で、
この場合、$relationsが空の配列であった場合に要素数が1となってしまい、foreach で空の $record を処理してしまいます。

 22       if (!($relations instanceof Doctrine_Collection))
 23       {
 24         $relations = array($relations);
 25       }

以下のようにして配列の要素数が0であった場合、continue するように対処するのが良いのではと思います。

 22       if (!($relations instanceof Doctrine_Collection))
 23       {
            if (!count($relations))
            {
              continue;
            }
 24         $relations = array($relations);
 25       }


Related issues

Related to OpenPNE 3 - Backport(バックポート) #1475: error at the application cascading of doctrine.(Doctrineのカスケーディングデリート 時にエラーになる) Fixed(完了) 2010-08-03

Associated revisions

Revision 5a05e883 (diff)
Added by Masato Nagasawa about 9 years ago

fixed cascading delete in the application level cascading.(fixes #1502, BP from #1475)

Revision d27379ad (diff)
Added by Masato Nagasawa about 9 years ago

fixed check instance of class. (fixes #1502, BP from #1475)

Revision a9d76027 (diff)
Added by Masato Nagasawa almost 9 years ago

fixed instance name (fixes #1502 BP from #1475)

History

#1 Updated by Masato Nagasawa about 9 years ago

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

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

#2 Updated by Masato Nagasawa about 9 years ago

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

#3 Updated by Masato Nagasawa about 9 years ago

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

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

#4 Updated by Masato Nagasawa almost 9 years ago

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

#5 Updated by isao sano about 8 years ago

  • Tracker changed from Backport(バックポート) to Bug(バグ)

#6 Updated by isao sano about 8 years ago

  • 3.6 で発生するか set to Yes

#7 Updated by Yuya Watanabe over 7 years ago

  • 3.6 で発生するか changed from Yes to Unknown (未調査)
  • 3.4 で発生するか set to Unknown (未調査)

メモ

アプリケーションレベルで delete をカスケーディングする場合は以下のような手順を踏む.

config/ProjectConfiguration.class.php 27行目をアンコメント

 21   public function setupProjectOpenPNEDoctrine($manager)
 22   {
 23     // You can write your own configurations.
 24 
 25     // In default, OpenPNE uses foreign key.
 26     // If you want not to use foreign key, comment out the following configuration:
 27     $manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL ^ Doctrine::EXPORT_CONSTRAINTS);
 28   }

データ初期化時にエラーが発生するので下記のようにして インストールタスク時にデータ初期化を行わないようにする.

diff --git a/lib/task/openpneInstallTask.class.php b/lib/task/openpneInstallTask.class.php
index 4e64c7e..bf401fb 100644
--- a/lib/task/openpneInstallTask.class.php
+++ b/lib/task/openpneInstallTask.class.php
@@ -143,7 +143,7 @@ EOF;
     {
       $this->configureDatabase($dbms, $username, $password, $hostname, $port, $dbname, $sock, $options);
     }
-    $this->buildDb($options);
+    //$this->buildDb($options);
   }

   protected function createDSN($dbms, $hostname, $port, $dbname, $sock)

通常通りインストールを行い,完了後に下記のようなSQLを用いてデータを流し込む.(下記のものは OpenPNE + opAuthMailAddressPlugin + opDiaryPlugin をインストールしたときのDBからダンプしてテーブルを再構築しないように加工したもの)

LOCK TABLES `admin_user` WRITE;
INSERT INTO `admin_user` VALUES (1,'admin','5f4dcc3b5aa765d61d8327deb882cf99','2012-03-16 23:09:35','2012-03-16 23:09:35');
UNLOCK TABLES;

LOCK TABLES `banner` WRITE;
INSERT INTO `banner` VALUES (1,'top_before',NULL,0),(2,'side_before',NULL,0),(3,'top_after',NULL,0),(4,'side_after',NULL,0);
UNLOCK TABLES;

LOCK TABLES `banner_translation` WRITE;
INSERT INTO `banner_translation` VALUES (1,'Top banner(before login)','en'),(1,'トップバナー(ログイン前)','ja_JP'),(2,'Side banner(before login)','en'),(2,'サイドバナー(ログイン前)','ja_JP'),(3,'Top banner (after login)','en'),(3,'ト>ップバナー(ログイン後)','ja_JP'),(4,'Side banner (after login)','en'),(4,'サイドバナー(ログイン後)','ja_JP');
UNLOCK TABLES;

LOCK TABLES `community_category` WRITE;
INSERT INTO `community_category` VALUES (1,'コミュニティカテゴリ',1,1,NULL,1,8,0,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(2,'地域',1,1,NULL,2,3,1,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(3,'グルメ',1,1,NULL,4,5,1,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(4,'スポーツ',1,1,NULL,6,7,1,'2012-03-16 23:09:36','2012-03-16 23:09:36');
UNLOCK TABLES;

LOCK TABLES `gadget` WRITE;
INSERT INTO `gadget` VALUES (1,'top','birthdayBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(2,'top','searchBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(3,'top','informationBox',20,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(4,'sideMenu','memberImageBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(5,'sideMenu','friendListBox',20,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(6,'sideMenu','communityJoinListBox',30,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(7,'sideBannerContents','languageSelecterBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(8,'sideBannerContents','sideBanner',20,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(9,'mobileTop','birthdayBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(10,'mobileTop','informationBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(11,'loginTop','loginForm',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(12,'mobileLoginContents','loginForm',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(13,'profileTop','birthdayBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(14,'profileSideMenu','memberImageBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(15,'profileSideMenu','friendListBox',20,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(16,'profileSideMenu','communityJoinListBox',30,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(17,'profileContents','profileListBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(18,'mobileProfileTop','birthdayBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(19,'mobileProfileBottom','friendListBox',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(20,'mobileProfileBottom','communityJoinListBox',20,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(21,'contents','diaryFriendList',101,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(22,'contents','diaryList',102,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(23,'contents','diaryCommentHistory',103,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(24,'contents','diaryMyList',104,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(25,'profileContents','diaryMemberList',101,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(26,'mobileContents','diaryFriendList',101,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(27,'mobileContents','diaryList',102,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(28,'mobileContents','diaryCommentHistory',103,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(29,'mobileContents','diaryMyList',104,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(30,'mobileProfileContents','diaryMemberList',101,'2012-03-16 23:09:36','2012-03-16 23:09:36');UNLOCK TABLES;
LOCK TABLES `member` WRITE;
INSERT INTO `member` VALUES (1,'OpenPNE君',NULL,0,'2012-03-16 23:09:35','2012-03-16 23:09:35',1);UNLOCK TABLES;LOCK TABLES `member_config` WRITE;INSERT INTO `member_config` VALUES (1,1,'pc_address','sns@example.com',NULL,'885654aa381dfadbc6ea2c47a4a30f6a','2012-03-16 23:09:35','2012-03-16 23:09:35'),(2,1,'password','5f4dcc3b5aa765d61d8327deb882cf99',NULL,'927246e0e2492bb1c4334e89edfa252f','2012-03-16 23:09:35','2012-03-16 23:09:35'),(3,1,'secret_question','5',NULL,'0ca0709b3ef4d5c7bde5e0f67c2021e1','2012-03-16 23:09:35','2012-03-16 23:09:35'),(4,1,'secret_answer','c81c00cad27aa757b313626c3c02094f',NULL,'8e460ad7facdeae96bfb1871f5d7a5b3','2012-03-16 23:09:35','2012-03-16 23:09:35');
UNLOCK TABLES;

LOCK TABLES `member_profile` WRITE;
INSERT INTO `member_profile` VALUES (1,1,1,NULL,'Man',NULL,NULL,1,1,2,0,'2012-03-16 23:09:35','2012-03-16 23:09:35'),(2,1,2,NULL,'1988-04-23','1988-04-23 00:00:00',NULL,2,1,2,0,'2012-03-16 23:09:35','2012-03-16 23:09:35'),(3,1,3,NULL,'Tok
yo',NULL,NULL,3,1,2,0,'2012-03-16 23:09:35','2012-03-16 23:09:35'),(4,1,4,NULL,'よろしくお願いします。',NULL,NULL,4,1,2,0,'2012-03-16 23:09:35','2012-03-16 23:09:35');
UNLOCK TABLES;

LOCK TABLES `navigation` WRITE;
INSERT INTO `navigation` VALUES (1,'secure_global','@homepage',0,'2012-03-16 23:09:35','2012-03-16 23:09:35'),(2,'secure_global','@member_search',10,'2012-03-16 23:09:35','2012-03-16 23:09:35'),(3,'secure_global','@community_search',20,'2
012-03-16 23:09:35','2012-03-16 23:09:35'),(4,'secure_global','@member_config',30,'2012-03-16 23:09:35','2012-03-16 23:09:35'),(5,'secure_global','@member_invite',40,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(6,'secure_global','@member
_logout',50,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(7,'default','@homepage',0,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(8,'default','@friend_list',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(9,'default','@member_profile_min
e',20,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(10,'default','@member_editProfile',30,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(11,'friend','@member_profile',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(12,'friend','@friend_li
st',20,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(13,'community','@community_home',0,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(14,'community','@community_join',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(15,'community','@commu
nity_quit',20,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(16,'mobile_home_side','@member_invite',0,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(17,'mobile_home','@friend_list',0,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(18,'mobile_
home','@community_joinlist',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(19,'mobile_home_center','@member_profile_mine',0,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(20,'backend_side','member/index',10,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(21,'backend_side','monitoring/index',20,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(22,'backend_side','community/index',30,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(23,'backend_side','sns/config',40,'2012-03-16 23:09
:36','2012-03-16 23:09:36'),(24,'backend_side','@mail_config',35,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(25,'backend_side','design/index',50,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(26,'backend_side','navigation/index',60,'2012
-03-16 23:09:36','2012-03-16 23:09:36'),(27,'backend_side','profile/list',70,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(28,'backend_side','plugin/list',80,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(29,'backend_side','admin/index',90
,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(30,'secure_global','diary/index',25,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(31,'default','diary/listMember',15,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(32,'friend','diary/listMembe
r',15,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(33,'mobile_home_side','@diary_new',15,'2012-03-16 23:09:36','2012-03-16 23:09:36'),(34,'mobile_home_side','@diary_list',16,'2012-03-16 23:09:36','2012-03-16 23:09:36');
UNLOCK TABLES;

LOCK TABLES `navigation_translation` WRITE;
INSERT INTO `navigation_translation` VALUES (1,'My Home','en'),(1,'マイホーム','ja_JP'),(2,'Search Members','en'),(2,'メンバー検索','ja_JP'),(3,'Search Communities','en'),(3,'コミュニティ検索','ja_JP'),(4,'Settings','en'),(4,'設定変更','ja_JP'),(5,'Invite','en'),(5,'友人を招待する','ja_JP'),(6,'Logout','en'),(6,'ログアウト','ja_JP'),(7,'Home','en'),(7,'ホーム','ja_JP'),(8,'My Friends','en'),(8,'マイフレンド','ja_JP'),(9,'Profile','en'),(9,'プロフィール確認','ja_JP'),(10,'Edit Profile','en'),(10,'プロフィール編集','ja_JP'),(11,'Home','en'),(11,'ホーム','ja_JP'),(12,'Friends','en'),(12,'フレンドリスト','ja_JP'),(13,'Community Top','en'),(13,'コミュニティトップ','ja_JP'),(14,'Join Community','en'),(14,'コミ>ュニティに参加','ja_JP'),(15,'Leave Community','en'),(15,'コミュニティを退会','ja_JP'),(16,'Invite','en'),(16,'[i:140]友人を誘う','ja_JP'),(17,'My Friends','en'),(17,'[i:140]マイフレンド','ja_JP'),(18,'Communities','en'),(18,'[i:155]参加コミュニティ','ja_JP'),(19,'Profile','en'),(19,'[i:140]プロフィール','ja_JP'),(20,'Members','en'),(20,'メンバー管理','ja_JP'),(21,'Media','en'),(21,'画像・書き込み管理','ja_JP'),(22,'Communities','en'),(22,'コミュニティ管理','ja_JP'),(23,'SNS','en'),(23,'SNS設定','ja_JP'),(24,'Email','en'),(24,'メール設定','ja_JP'),(25,'Appearance','en'),(25,'デザイン設定','ja_JP'),(26,'Navigations','en'),(26,'ナビゲーション設定','ja_JP'),(27,'Profile','en'),(27,'プロフィール項目設定','ja_JP'),(28,'Plugins','en'),(28,'プラグイン設定','ja_JP'),(29,'Administration settings','en'),(29,'管理画面設定','ja_JP'),(30,'Diary','en'),(30,'日記','ja_JP'),(31,'Diary','en'),(31,'日記','ja_JP'),(32,'Diary','en'),(32,'日記','ja_JP'),(33,'Post a Diary','en'),(33,'日記を書く','ja_JP'),(34,'Recently Posted Diaries','en'),(34,'最新日記','ja_JP');
UNLOCK TABLES;

LOCK TABLES `profile` WRITE;
INSERT INTO `profile` VALUES (1,'op_preset_sex',1,0,0,1,'select','string',1,1,1,0,NULL,NULL,NULL,110,'2012-03-16 23:09:35','2012-03-16 23:09:35'),(2,'op_preset_birthday',0,0,0,1,'date','string',1,1,1,0,NULL,NULL,NULL,120,'2012-03-16 23:09:35','2012-03-16 23:09:35'),(3,'op_preset_region',0,0,0,1,'region_select','JP',1,1,1,0,NULL,NULL,NULL,125,'2012-03-16 23:09:35','2012-03-16 23:09:35'),(4,'op_preset_self_introduction',0,0,0,1,'textarea','string',1,1,1,0,NULL,NULL,NULL,130,'2012-03-16 23:09:35','2012-03-16 23:09:35');
UNLOCK TABLES;

LOCK TABLES `sns_config` WRITE;
INSERT INTO `sns_config` VALUES (1,'OpenPNE_revision','46'),(2,'opDiaryPlugin_revision','9');
UNLOCK TABLES;

LOCK TABLES `sns_term` WRITE;
INSERT INTO `sns_term` VALUES (1,'friend','pc_frontend'),(2,'friend','mobile_frontend'),(3,'my_friend','pc_frontend'),(4,'my_friend','mobile_frontend'),(5,'community','pc_frontend'),(6,'community','mobile_frontend'),(7,'nickname','pc_frontend'),(8,'nickname','mobile_frontend'),(9,'activity','pc_frontend'),(10,'activity','mobile_frontend'),(11,'post_activity','pc_frontend'),(12,'post_activity','mobile_frontend');
UNLOCK TABLES;

LOCK TABLES `sns_term_translation` WRITE;
INSERT INTO `sns_term_translation` VALUES (1,'friend','en'),(1,'フレンド','ja_JP'),(2,'friend','en'),(2,'フレンド','ja_JP'),(3,'my friend','en'),(3,'マイフレンド','ja_JP'),(4,'my friend','en'),(4,'マイフレンド','ja_JP'),(5,'community','en'),(5,'>コミュニティ','ja_JP'),(6,'community','en'),(6,'コミュニティ','ja_JP'),(7,'nickname','en'),(7,'ニックネーム','ja_JP'),(8,'nickname','en'),(8,'ニックネーム','ja_JP'),(9,'activity','en'),(9,'アクティビティ','ja_JP'),(10,'activity','en'),(10,'アクティビティ','ja_JP'),(11,'Post Activity','en'),(11,'アクティビティ投稿','ja_JP'),(12,'Post Activity','en'),(12,'投稿','ja_JP');
UNLOCK TABLES;

#8 Updated by Yuya Watanabe over 7 years ago

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

#9 Updated by Shouta Kashiwagi over 7 years ago

  • Status changed from Pending Testing(テスト待ち) to Fixed(完了)
  • % Done changed from 70 to 100

テストOKです。

#10 Updated by kaoru n almost 4 years ago

  • 3.8 で発生するか set to Unknown (未調査)

Also available in: Atom PDF