Home

技術日記
Zend_Controller_Dispatcher_Standardのtrunk 247行目Edit

           if (!$this->getParam('useDefaultControllerAlways') && !empty($controller)) {

           if (!$this->getParam('useDefaultControllerAlways') && empty($controller)) {

のような気がするんだけど、いい花粉が飛んでいて頭がぼーっとするせいで、いまいち自分の判断が信用できない。ここは、useDefaultControllerAlwaysが無効な場合は、コントローラ名が解決できない→例外を発生させる処理だよな。

Published At2008-03-11 00:00Updated At2019-12-30 23:56

技術日記
Zend_Db_Select::where()メソッドの$typeEdit

trunkでは、

    * @param string   $cond  The WHERE condition.
* @param string   $value OPTIONAL A single value to quote into the condition.
* @param constant $type  OPTIONAL The type of the given value
* @return Zend_Db_Select This Zend_Db_Select object.
*/
public function where($cond, $value = null, $type = null)
{
if ((func_num_args() > 3) or (($type !== null) and ($type !== 0) and ($type !== 1) and ($type !== 2))) {
$value = func_get_args();
array_shift($value);
$type = null;
}
$this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, true);
return $this;
}

なんて感じになっているんだけど、この「(($type !== null) and ($type !== 0) and ($type !== 1) and ($type !== 2))」ってのはどこから現れたんだ?

where()メソッドでは、

    * @param constant $type  OPTIONAL The type of the given value

になっているけど、ここから呼ばれている_where()メソッドでは、

    * @param string   $type   optional

になっているし、実際PDO_MYSQLを使ったZend_Db_Tableのinfo()では、DATA_TYPEはstringで返ってくる("varchar"とか"int"とか)。

0、1、2という数値から、Zend_Db::INT_TYPE = 0、Zend_Db::BIGINT_TYPE = 1、Zend_Db::FLOAT_TYPE = 2あたりが怪しそうな気がするけど、この値ってZend_Db_Adapter_Abstract内で$_numericDataTypesとして定義されて以降、まったく使われていないし、意味的にも$typeが数値ではなかった場合に$valueを配列扱いするっていう意味がわからない。

これのせいで、trunkにしたらZend_Db_Tableのリレーション周り(findParentRow()とか)が動かなくなっちゃったんだよなー(Zend_Db_Table_Row_Abstract::findParentRow()内でZend_Db_Table_Abstract::info()で取得したDATA_TYPEをそのまま渡しているため)。自前で直そうにも、コードの意味がわからなくて直せないし。

3/13追記

昨日更新されたrevision 8783で、上記の怪しげな条件文はばっさり削除された。なんだったんだ……。

Published At2008-03-12 00:00Updated At2019-12-30 23:56