Selaa lähdekoodia

Bug of month: make sure that GetFilter returns a usable filter (i.e. with the parameters)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2326 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 12 vuotta sitten
vanhempi
commit
51d0c1140e

+ 5 - 17
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
 	}
 	
 	/**

+ 9 - 1
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))
 				{

+ 6 - 4
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);

+ 1 - 1
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 "<p>Debug trace: <pre>".print_r($e->getTrace(), true)."</pre></p>\n";
+	echo "<p>Debug trace: <pre>".$e->getTraceAsString()."</pre></p>\n";
 	IssueLog::Error($e->getMessage());
 }