Skip to content

Instantly share code, notes, and snippets.

@upsilon
Last active Jul 12, 2017
Embed
What would you like to do?
Doctrine_Record::free(true) を実行すると同一レコードを指す別のインスタンスまで解放されてしまう
<?php
include_once dirname(__FILE__) . '/../../bootstrap/unit.php';
include_once dirname(__FILE__) . '/../../bootstrap/database.php';
$t = new lime_test(3, new lime_output_color());
$community1 = Doctrine_Core::getTable('Community')->find(1);
$t->is($community1->id, '1');
$communityMember1 = Doctrine_Core::getTable('CommunityMember')
->findOneByCommunityIdAndMemberId(1, 1);
$t->is($communityMember1->Community->id, '1');
$community1->free(true);
// $communityMember1 や $communityMember1->Community に対しては free() を呼び出していないはず
$t->is($communityMember1->Community->id, '1'); // エラー
/*
Doctrine_Record_UnknownPropertyException: Unknown record property
/ related component "id" on "Community"
(in
lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record/Filter/Standard.php
on line 55)
Exception trace:
at lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record/Filter/Standard.php:55
Doctrine_Record_Filter_Standard->filterGet() at lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php:1395
Doctrine_Record->_get() at lib/util/opDoctrineRecord.class.php:180
opDoctrineRecord->_get() at lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php:1350
Doctrine_Record->get() at lib/util/opDoctrineRecord.class.php:161
opDoctrineRecord->get() at lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Access.php:72
Doctrine_Access->__get() at test/unit/model/gistfile1.php:19
*/
@upsilon

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment