From d1a84bfbc15ec474e6c36ffbe1b22df55695f413 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Fri, 3 Sep 2010 21:42:37 +0000 Subject: [PATCH] #247 Missing query argument (CSV export failing, or Emailed URL not working for lists) SVN:trunk[758] --- core/dbobjectsearch.class.php | 44 +++++++++++++++++++++------------- core/valuesetdef.class.inc.php | 4 ++-- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/core/dbobjectsearch.class.php b/core/dbobjectsearch.class.php index e1cb27358..8011cff15 100644 --- a/core/dbobjectsearch.class.php +++ b/core/dbobjectsearch.class.php @@ -507,19 +507,21 @@ class DBObjectSearch return $this->m_oSearchCondition->Render($this->m_aParams, false); } - public function serialize() + public function serialize($bDevelopParams = false, $aContextParams = null) { - $sOql = $this->ToOql(); - return base64_encode($sOql); + $sOql = $this->ToOql($bDevelopParams, $aContextParams); + return base64_encode(serialize(array($sOql, $this->m_aParams))); } static public function unserialize($sValue) { - $sOql = base64_decode($sValue); + $aData = unserialize(base64_decode($sValue)); + $sOql = $aData[0]; + $aParams = $aData[1]; // We've tried to use gzcompress/gzuncompress, but for some specific queries // it was not working at all (See Trac #193) // gzuncompress was issuing a warning "data error" and the return object was null - return self::FromOQL($sOql); + return self::FromOQL($sOql, $aParams); } // SImple BUt Structured Query Languag - SubuSQL @@ -600,23 +602,28 @@ class DBObjectSearch return $aRes; } - public function ToOQL(&$aParams = null) + public function ToOQL($bDevelopParams = false, $aContextParams = null) { // Currently unused, but could be useful later $bRetrofitParams = false; - if (is_null($aParams)) + if ($bDevelopParams) { - // Leave it as is, the rendering will be made with parameters in clear + if (is_null($aContextParams)) + { + $aParams = array_merge($this->m_aParams); + } + else + { + $aParams = array_merge($aContextParams, $this->m_aParams); + } } else { - if (count($this->m_aParams) > 0) - { - $aParams = array_merge($aParams, $this->m_aParams); - } + // Leave it as is, the rendering will be made with parameters in clear + $aParams = null; } - + $sSelectedClasses = implode(', ', array_keys($this->m_aSelectedClasses)); $sRes = 'SELECT '.$sSelectedClasses.' FROM'; @@ -739,14 +746,14 @@ class DBObjectSearch // Do not filter out depending on user rights // In particular when we are currently in the process of evaluating the user rights... - static public function FromOQL_AllData($sQuery) + static public function FromOQL_AllData($sQuery, $aParams = null) { - $oRes = self::FromOQL($sQuery); + $oRes = self::FromOQL($sQuery, $aParams); $oRes->AllowAllData(); return $oRes; } - static public function FromOQL($sQuery) + static public function FromOQL($sQuery, $aParams = null) { if (empty($sQuery)) return null; @@ -861,6 +868,11 @@ class DBObjectSearch $oResultFilter->m_oSearchCondition = $oResultFilter->OQLExpressionToCondition($sQuery, $oConditionTree, $aAliases); } + if (!is_null($aParams)) + { + $oResultFilter->m_aParams = $aParams; + } + if ($bOQLCacheEnabled) { self::$m_aOQLQueries[$sQuery] = clone $oResultFilter; diff --git a/core/valuesetdef.class.inc.php b/core/valuesetdef.class.inc.php index 0797d185e..626489a90 100644 --- a/core/valuesetdef.class.inc.php +++ b/core/valuesetdef.class.inc.php @@ -109,11 +109,11 @@ class ValueSetObjects extends ValueSetDefinition if ($this->m_bAllowAllData) { - $oFilter = DBObjectSearch::FromOQL_AllData($this->m_sFilterExpr, $aArgs); + $oFilter = DBObjectSearch::FromOQL_AllData($this->m_sFilterExpr); } else { - $oFilter = DBObjectSearch::FromOQL($this->m_sFilterExpr, $aArgs); + $oFilter = DBObjectSearch::FromOQL($this->m_sFilterExpr); } if (!$oFilter) return false;