From 9f47c09cdf03b98f7c60ccdc53f7520489deec0b Mon Sep 17 00:00:00 2001
From: Denis Flaven
Date: Mon, 22 Oct 2012 13:12:00 +0000
Subject: [PATCH] Bug of month: make sure that GetFilter returns a usable
filter (i.e. with the parameters)
SVN:trunk[2326]
---
application/ui.extkeywidget.class.inc.php | 22 +++++-----------------
application/utils.inc.php | 10 +++++++++-
core/dbobjectset.class.php | 10 ++++++----
pages/ajax.render.php | 2 +-
4 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php
index 166cf0255..20dacb6da 100644
--- a/application/ui.extkeywidget.class.inc.php
+++ b/application/ui.extkeywidget.class.inc.php
@@ -344,23 +344,11 @@ EOF
{
throw new Exception('Implementation: null value for allowed values definition');
}
- try
- {
- $oFilter = DBObjectSearch::FromOQL($sFilter);
- $oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
- $oBlock = new DisplayBlock($oFilter, 'list', false, array('query_params' => array('this' => $oObj)));
- $oBlock->Display($oP, $this->iId.'_results', array('this' => $oObj, 'cssCount'=> '#count_'.$this->iId, 'menu' => false, 'selection_mode' => true, 'selection_type' => 'single', 'table_id' => 'select_'.$this->sAttCode)); // Don't display the 'Actions' menu on the results
- }
- catch(MissingQueryArgument $e)
- {
- // When used in a search form the $this parameter may be missing, in this case return all possible values...
- // TODO check if we can improve this behavior...
- $sOQL = 'SELECT '.$sRemoteClass;
- $oFilter = DBObjectSearch::FromOQL($sOQL);
- $oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
- //$oBlock = new DisplayBlock($oFilter, 'list', false);
- //$oBlock->Display($oP, $this->iId.'_results', array('cssCount'=> '#count_'.$this->iId, 'menu' => false, 'selection_mode' => true, 'selection_type' => 'single')); // Don't display the 'Actions' menu on the results
- }
+
+ $oFilter = DBObjectSearch::FromOQL($sFilter);
+ $oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
+ $oBlock = new DisplayBlock($oFilter, 'list', false, array('query_params' => array('this' => $oObj)));
+ $oBlock->Display($oP, $this->iId.'_results', array('this' => $oObj, 'cssCount'=> '#count_'.$this->iId, 'menu' => false, 'selection_mode' => true, 'selection_type' => 'single', 'table_id' => 'select_'.$this->sAttCode)); // Don't display the 'Actions' menu on the results
}
/**
diff --git a/application/utils.inc.php b/application/utils.inc.php
index 2c2283855..9bc8413bc 100644
--- a/application/utils.inc.php
+++ b/application/utils.inc.php
@@ -775,7 +775,15 @@ class utils
{
foreach (MetaModel::EnumPlugins('iPopupMenuExtension') as $oExtensionInstance)
{
- foreach($oExtensionInstance->EnumItems($iMenuId, $param) as $oMenuItem)
+ if (is_object($param))
+ {
+ $tmpParam = clone $param; // In case the parameter is an object, clone it to prevent alterations
+ }
+ else
+ {
+ $tmpParam = $param;
+ }
+ foreach($oExtensionInstance->EnumItems($iMenuId, $tmpParam) as $oMenuItem)
{
if (is_object($oMenuItem))
{
diff --git a/core/dbobjectset.class.php b/core/dbobjectset.class.php
index cbd1cab21..323b5a8c1 100644
--- a/core/dbobjectset.class.php
+++ b/core/dbobjectset.class.php
@@ -41,7 +41,7 @@ class DBObjectSet
public function __construct(DBObjectSearch $oFilter, $aOrderBy = array(), $aArgs = array(), $aExtendedDataSpec = null, $iLimitCount = 0, $iLimitStart = 0)
{
- $this->m_oFilter = $oFilter;
+ $this->m_oFilter = clone $oFilter;
$this->m_aAddedIds = array();
$this->m_aOrderBy = $aOrderBy;
$this->m_aArgs = $aArgs;
@@ -269,14 +269,16 @@ class DBObjectSet
public function GetFilter()
{
+ // Make sure that we carry on the parameters of the set with the filter
+ $oFilter = clone $this->m_oFilter;
+ $oFilter->SetInternalParams(array_merge($oFilter->GetInternalParams(), $this->m_aArgs));
+
if (count($this->m_aAddedIds) == 0)
{
- return $this->m_oFilter;
+ return $oFilter;
}
else
{
- $oFilter = clone $this->m_oFilter;
-
$oIdListExpr = ListExpression::FromScalars(array_keys($this->m_aAddedIds));
$oIdExpr = new FieldExpression('id', $oFilter->GetClassAlias());
$oIdInList = new BinaryExpression($oIdExpr, 'IN', $oIdListExpr);
diff --git a/pages/ajax.render.php b/pages/ajax.render.php
index e586d4a29..a98cb8a9e 100644
--- a/pages/ajax.render.php
+++ b/pages/ajax.render.php
@@ -909,7 +909,7 @@ catch (Exception $e)
{
// note: transform to cope with XSS attacks
echo htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8');
- echo "Debug trace:
".print_r($e->getTrace(), true)."
\n";
+ echo "Debug trace:
".$e->getTraceAsString()."
\n";
IssueLog::Error($e->getMessage());
}