プロジェクト

全般

プロフィール

Backport(バックポート) #3712

opDoctrineQueryTest が APC のない環境で失敗する.

isao sano9年以上前に追加. 9年以上前に更新.

ステータス:
New(新規)
優先度:
Low(低め)
担当者:
対象バージョン:
開始日:
2013-04-30
期日:
進捗率:

0%


説明

概要

opDoctrineQueryTest が APC のない環境で失敗する.

概要

例えば下記のように lastQueryCacheHash を取得してきているが,両方とも空文字列を返すため値が等しくなり,テストが失敗する.

test/unit/util/opDoctrineQueryTest.php
 31 Doctrine::getTable('AdminUser')->find(1);
 32 $keys['find'] = myQuery::$lastQueryCacheHash;
...
 55 $t->isnt($keys['find'], $keys['find_all'], '->find() and ->findAll() generates different query cache keys');

$lastQueryCacheHash は calculateQueryCacheHash() を呼び出す.

test/unit/util/opDoctrineQueryTest.php
  5 class myQuery extends opDoctrineQuery
  6 {
  7   public static $lastQueryCacheHash = '';
  8 
  9   public function calculateQueryCacheHash()
 10   {
 11     self::$lastQueryCacheHash = parent::calculateQueryCacheHash();
 12 
 13     return self::$lastQueryCacheHash;
 14   }
 15 }

calculateQueryCacheHash() が呼ばれるのは find() や findAll() など, おおまかに言うと execute() を呼び出している部分.932 行目の $this->conn->getAttribute(Doctrine_Core::ATTR_QUERY_CACHE) が偽になる.

lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Abstract.php
 932             if ($this->_queryCache !== false && ($this->_queryCache || $this->conn->getAttribute(Doctrine_Core::ATTR_QUERY_CACHE))) {
 933                 $queryCacheDriver = $this->getQueryCacheDriver();
 934                 $hash = $this->calculateQueryCacheHash();
 935                 $cached = $queryCacheDriver->fetch($hash);

932 行目の Doctrine::ATTR_QUERY_CACHE は OpenPNE では下記部分で定義されている.見て分かる通り apc が有効でないと設定されない.

lib/config/opProjectConfiguration.class.php
118     if (extension_loaded('apc'))
119     {    
...
129       $cacheDriver = new Doctrine_Cache_Apc($options);
130       $manager->setAttribute(Doctrine::ATTR_QUERY_CACHE, $cacheDriver);

修正案

キャッシュされた場合,そのハッシュが等しくないかどうかを確認したいという内容のテストであると思われるため, APC が入っていない環境でもテストは実行されるべき.そのために Doctrine::ATTR_QUERY_CACHE に new Doctrine_Cache_Array() をセットすることで環境に依存しないテストの実行ができるものと考えられる.

diff --git a/test/unit/util/opDoctrineQueryTest.php b/test/unit/util/opDoctrineQueryTest.php
index fc02677..9de61f6 100644
--- a/test/unit/util/opDoctrineQueryTest.php
+++ b/test/unit/util/opDoctrineQueryTest.php
@@ -21,6 +21,7 @@ $configuration = ProjectConfiguration::getApplicationConfiguration($_app, $_env,
 new sfDatabaseManager($configuration);

 Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_QUERY_CLASS, 'myQuery');
+Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_QUERY_CACHE, new Doctrine_Cache_Array());

 $t = new lime_test(null, new lime_output_color());


関連するチケット

コピー元 OpenPNE 3 - Bug(バグ) #3336: opDoctrineQueryTest が APC のない環境で失敗する. New(新規) 2013-04-30

履歴

#1 isao sano9年以上前に更新

  • コピー元 Bug(バグ) #3336: opDoctrineQueryTest が APC のない環境で失敗する. を追加

#2 isao sano9年以上前に更新

  • 担当者isao sano にセット

#3 isao sano9年以上前に更新

  • 対象バージョンOpenPNE 3.8.14 から OpenPNE 3.8.x に変更

#4 Chiharu Nakajima9年以上前に更新

  • 優先度Normal(通常) から Low(低め) に変更

#5 Chiharu Nakajima9年以上前に更新

このチケットの内容は下記の項目に該当する不具合であるため、一旦優先度を下げます。
・一部の特殊なサーバー環境のみで発生する不具合

他の形式にエクスポート: Atom PDF