* Api - Fix redirect loop and use deep copy to keep initial nextmatch rows

This commit is contained in:
nathangray 2019-02-19 16:41:31 -07:00
parent 1d8f2a606b
commit eea03aa47c

View File

@ -201,6 +201,13 @@ class Etemplate extends Etemplate\Widget\Template
'currentapp' => $currentapp, 'currentapp' => $currentapp,
); );
if($data['content']['nm']['rows'] && is_array($data['content']['nm']['rows']))
{
// Deep copy rows so we don't lose them when request is set to null
// (some content by reference)
$data['content']['nm'] = self::deep_copy($data['content']['nm']);
}
// Info required to load the etemplate client-side // Info required to load the etemplate client-side
$dom_id = str_replace('.','-',$this->dom_id); $dom_id = str_replace('.','-',$this->dom_id);
$load_array = array( $load_array = array(
@ -241,6 +248,10 @@ class Etemplate extends Etemplate\Widget\Template
$GLOBALS['egw']->framework->response->generic("data", array($content)); $GLOBALS['egw']->framework->response->generic("data", array($content));
$GLOBALS['egw']->framework->response->generic('et2_load',$load_array+Framework::get_extra()); $GLOBALS['egw']->framework->response->generic('et2_load',$load_array+Framework::get_extra());
Framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view) Framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view)
// Really important to run this or weird things happen
// See https://help.egroupware.org/t/nextmatch-wert-im-header-ausgeben/73412/11
self::$request=null;
return; return;
} }
// let framework know, if we are a popup or not ('popup' not true, which is allways used by index.php!) // let framework know, if we are a popup or not ('popup' not true, which is allways used by index.php!)
@ -624,6 +635,36 @@ class Etemplate extends Etemplate\Widget\Template
return $old; return $old;
} }
/**
* Deep copy array to make sure there are no references
*
* @param Array $array
* @return Array
*/
public static function deep_copy($source)
{
$arr = array();
foreach ($source as $key => $element)
{
if (is_array($element))
{
$arr[$key] = static::deep_copy($element);
}
else if (is_object($element))
{
// make an object copy
$arr[$key] = clone $element;
}
else
{
$arr[$key] = $element;
}
}
return $arr;
}
/** /**
* Debug callback just outputting content * Debug callback just outputting content
* *