http://redmine.openpne.jp/
http://redmine.openpne.jp/favicon.ico
2013-04-26T12:44:33Z
OpenPNE Issue Tracking System
OpenPNE 3 - Bug(バグ) #3135: サブクエリのWHERE節に「field IN ?」の形式のDQLがあると Invalid parameter number エラーが発生する
http://redmine.openpne.jp/issues/3135?journal_id=16482
2013-04-26T12:44:33Z
Yuya Watanabe
watanabe@openpne.jp
<ul><li><strong>3.8 で発生するか</strong> を <i>Unknown (未調査)</i> にセット</li></ul><a name="原因"></a>
<h3 >原因<a href="#原因" class="wiki-anchor">¶</a></h3>
<p>test/unit/util/opActivityQueryBuilderTest.php のテストを動かしたときに下記のようなクエリが MySQL で受け取られている.ここで WHERE NOT IN の部分を見ると 'Array' という値が入っていることがわかる.</p>
<pre>
SELECT a.id AS a__id, a.member_id AS a__member_id, a.in_reply_to_activity_id AS a__in_reply_to_activity_id, a
.body AS a__body, a.uri AS a__uri, a.public_flag AS a__public_flag, a.is_pc AS a__is_pc, a.is_mobile AS a__is_mobile, a.source AS a__source,
a.source_uri AS a__source_uri, a.foreign_table AS a__foreign_table, a.foreign_id AS a__foreign_id, a.template AS a__template, a.template_para
m AS a__template_param, a.created_at AS a__created_at, a.updated_at AS a__updated_at, m.id AS m__id, m.name AS m__name, m.invite_member_id AS
m__invite_member_id, m.is_login_rejected AS m__is_login_rejected, m.created_at AS m__created_at, m.updated_at AS m__updated_at, m.is_active
AS m__is_active FROM activity_data a LEFT JOIN member m ON a.member_id = m.id WHERE (a.member_id IN (SELECT m2.member_id_to AS m2__member_id_
to FROM member_relationship m2 WHERE (m2.member_id_from = '1' AND m2.is_friend = 1 AND m2.member_id_to NOT IN ('Array'))) AND a.public_flag $
= '2') AND (a.foreign_table IS NULL OR a.foreign_table <> "community") AND (m.is_active = '1' OR m.is_active IS NULL) ORDER BY a.id DESC
</pre>
<p>該当箇所をみてみると,配列かどうかについては特に確認していない.</p>
<pre>
178 public function andWhereIn($expr, $params = array(), $not = false)
179 {
180 if (isset($params) && (count($params) == 0))
181 {
182 if (!$not)
183 {
184 return $this->andWhere('0 = 1');
185 }
186 else
187 {
188 return parent::andWhereIn($expr, $params, $not);
189 }
190 }
192 $this->addWhereInCount(count($params));
193
194 if ($not)
195 {
196 $this->andWhere($expr.' NOT IN ?', array($params));
197 }
198 else
199 {
200 $this->andWhere($expr.' IN ?', array($params));
201 }
202
203 return $this;
204 }
</pre>
<p>原因としては,おそらく Doctrine_Query の andWhereIn() に渡される際にネストされない配列であるべきものがネストされて渡されていたためとおもわれる.<br />実際に下記のような修正を適用し, <a class="changeset" title="fixed getting 500 error responce from activity/community.json if any inactive members exist (fixe..." href="http://redmine.openpne.jp/projects/op3/repository/revisions/f9eaaaf97258be8b38d4b6e9e36d79195481d5fc">f9eaaaf97258be8b38d4b6e9e36d79195481d5fc</a> の修正のみを revert したコードでテストを実行した場合にすべてのテストケースをパスした.</p>
<pre>
diff --git a/lib/util/opDoctrineQuery.class.php b/lib/util/opDoctrineQuery.class.php
index 7e5db73..fc9757e 100644
--- a/lib/util/opDoctrineQuery.class.php
+++ b/lib/util/opDoctrineQuery.class.php
@@ -191,13 +191,18 @@ class opDoctrineQuery extends Doctrine_Query
$this->addWhereInCount(count($params));
+ if (!is_array($params))
+ {
+ $params = array($params);
+ }
+
if ($not)
{
- $this->andWhere($expr.' NOT IN ?', array($params));
+ $this->andWhere($expr.' NOT IN ?', $params);
}
else
{
- $this->andWhere($expr.' IN ?', array($params));
+ $this->andWhere($expr.' IN ?', $params);
}
return $this;
</pre>
<p>追記)</p>
<p>これでもいいらしい</p>
<pre>
diff --git a/lib/util/opDoctrineQuery.class.php b/lib/util/opDoctrineQuery.class.php
index 7e5db73..106c051 100644
--- a/lib/util/opDoctrineQuery.class.php
+++ b/lib/util/opDoctrineQuery.class.php
@@ -193,11 +193,11 @@ class opDoctrineQuery extends Doctrine_Query
if ($not)
{
- $this->andWhere($expr.' NOT IN ?', array($params));
+ $this->andWhere($expr.' NOT IN ?', (array)$params);
}
else
{
- $this->andWhere($expr.' IN ?', array($params));
+ $this->andWhere($expr.' IN ?', (array)$params);
}
return $this;
</pre>
OpenPNE 3 - Bug(バグ) #3135: サブクエリのWHERE節に「field IN ?」の形式のDQLがあると Invalid parameter number エラーが発生する
http://redmine.openpne.jp/issues/3135?journal_id=16494
2013-05-02T04:16:49Z
Yuya Watanabe
watanabe@openpne.jp
<ul></ul><p>note-1 の内容は例1や例2の修正としては不適切のようです.</p>
OpenPNE 3 - Bug(バグ) #3135: サブクエリのWHERE節に「field IN ?」の形式のDQLがあると Invalid parameter number エラーが発生する
http://redmine.openpne.jp/issues/3135?journal_id=16495
2013-05-07T00:16:48Z
Yuya Watanabe
watanabe@openpne.jp
<ul></ul><p>調査中に別のバグっぽい挙動を見つけたので報告しました.</p>
<p>Bug(バグ) <a class="issue tracker-1 status-1 priority-4 priority-default" title="Bug(バグ): Doctrine のサブクエリの中でエイリアスを指定した場合に正しくないSQLが発行される場合がある (New(新規))" href="http://redmine.openpne.jp/issues/3338">#3338</a>: Doctrine のサブクエリの中でエイリアスを指定した場合に正しくないSQLが発行される場合がある<br /><a class="external" href="https://redmine.openpne.jp/issues/3338">https://redmine.openpne.jp/issues/3338</a></p>
OpenPNE 3 - Bug(バグ) #3135: サブクエリのWHERE節に「field IN ?」の形式のDQLがあると Invalid parameter number エラーが発生する
http://redmine.openpne.jp/issues/3135?journal_id=16496
2013-05-07T01:58:55Z
Yuya Watanabe
watanabe@openpne.jp
<ul></ul><p>調査中に別のバグっぽい挙動を見つけたので報告しました.</p>
<p>Bug(バグ) <a class="issue tracker-1 status-1 priority-4 priority-default" title="Bug(バグ): Doctrine で WHERE IN を用いたサブクエリの場合に配列が正しく展開されない (New(新規))" href="http://redmine.openpne.jp/issues/3339">#3339</a>: Doctrine で WHERE IN を用いたサブクエリの場合に配列が正しく展開されない<br /><a class="external" href="https://redmine.openpne.jp/issues/3339">https://redmine.openpne.jp/issues/3339</a></p>
OpenPNE 3 - Bug(バグ) #3135: サブクエリのWHERE節に「field IN ?」の形式のDQLがあると Invalid parameter number エラーが発生する
http://redmine.openpne.jp/issues/3135?journal_id=16760
2013-09-19T07:31:54Z
Youichi Kimura
kim.upsilon@bucyou.net
<ul><li><strong>説明</strong> を更新 (<a title="差分を表示" href="/journals/16760/diff?detail_id=21957">diff</a>)</li></ul><p>Doctrineに対して下記の修正を施すことで、概要に書かれているコードは動作するようになりました。他のSNS機能に影響がないかどうかは未確認です。<br /><a class="external" href="https://github.com/upsilon/doctrine1/compare/op3135_subquery-where-in-bug">https://github.com/upsilon/doctrine1/compare/op3135_subquery-where-in-bug</a></p>
OpenPNE 3 - Bug(バグ) #3135: サブクエリのWHERE節に「field IN ?」の形式のDQLがあると Invalid parameter number エラーが発生する
http://redmine.openpne.jp/issues/3135?journal_id=16962
2013-10-28T08:05:36Z
Youichi Kimura
kim.upsilon@bucyou.net
<ul></ul><p>OpenPNE で独自に note-5 のような修正を施すことは問題ありませんが、Doctrine1 は LGPL なのでプロプライエタリな利用で先行して note-5 の修正を取り込むことは避けた方が良いかもしれません。</p>
OpenPNE 3 - Bug(バグ) #3135: サブクエリのWHERE節に「field IN ?」の形式のDQLがあると Invalid parameter number エラーが発生する
http://redmine.openpne.jp/issues/3135?journal_id=17190
2013-12-24T11:09:10Z
Yuya Watanabe
watanabe@openpne.jp
<ul></ul><p>いろいろなところに影響が出ているので <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug(バグ): [Optimization] Doctrine_Query::andWhereIn() add inefficient conditions to a DQL (Doctrine_Query::... (Fixed(完了))" href="http://redmine.openpne.jp/issues/991">#991</a> の修正として追加されている opDoctrineQuqyer の andWhereIn() 自体を一旦削除してしまうというのも手かもしれない.</p>
OpenPNE 3 - Bug(バグ) #3135: サブクエリのWHERE節に「field IN ?」の形式のDQLがあると Invalid parameter number エラーが発生する
http://redmine.openpne.jp/issues/3135?journal_id=24443
2020-01-29T08:44:28Z
kaoru n
<ul><li><strong>対象バージョン</strong> を <i>OpenPNE 3.10.x</i> にセット</li></ul>