forked from extern/egroupware
Revert "* Api - Avoid SQL errors caused by removed custom fields still in favorites"
This reverts commit a03931493f
.
This commit is contained in:
parent
747b3bb103
commit
f4081c1443
@ -351,21 +351,7 @@ class Nextmatch extends Etemplate\Widget
|
|||||||
{
|
{
|
||||||
$GLOBALS['egw_info']['flags']['currentapp'] = $app;
|
$GLOBALS['egw_info']['flags']['currentapp'] = $app;
|
||||||
Api\Translation::add_app($app);
|
Api\Translation::add_app($app);
|
||||||
|
|
||||||
// Avoid SQL errors from missing custom fields (deleted or no permission)
|
|
||||||
if(!Api\Storage\Customfields::get($app))
|
|
||||||
{
|
|
||||||
if(Api\Storage::remove_customfields($value['order']))
|
|
||||||
{
|
|
||||||
Api\Json\Response::get()->message(lang('Sort removed, given custom field is no longer available'));
|
|
||||||
}
|
|
||||||
if(Api\Storage::remove_customfields($value['col_filter']))
|
|
||||||
{
|
|
||||||
Api\Json\Response::get()->message(lang('Filter removed, given custom field is no longer available'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If specific data requested, just do that
|
// If specific data requested, just do that
|
||||||
if (($row_id = $value['row_id']) && $queriedRange['refresh'])
|
if (($row_id = $value['row_id']) && $queriedRange['refresh'])
|
||||||
{
|
{
|
||||||
|
@ -221,7 +221,7 @@ class Storage extends Storage\Base
|
|||||||
$id = isset($data[$this->autoinc_id]) ? $data[$this->autoinc_id] : $data[$this->db_key_cols[$this->autoinc_id]];
|
$id = isset($data[$this->autoinc_id]) ? $data[$this->autoinc_id] : $data[$this->db_key_cols[$this->autoinc_id]];
|
||||||
|
|
||||||
\EGroupware\Api\Storage\Customfields::handle_files($this->app, $id, $data, $this->customfields);
|
\EGroupware\Api\Storage\Customfields::handle_files($this->app, $id, $data, $this->customfields);
|
||||||
|
|
||||||
foreach (array_keys((array)$this->customfields) as $name)
|
foreach (array_keys((array)$this->customfields) as $name)
|
||||||
{
|
{
|
||||||
if (!isset($data[$field = $this->get_cf_field($name)])) continue;
|
if (!isset($data[$field = $this->get_cf_field($name)])) continue;
|
||||||
@ -431,11 +431,6 @@ class Storage extends Storage\Base
|
|||||||
//error_log(__METHOD__.'('.array2string(array_combine(array_slice(array('criteria','only_keys','order_by','extra_cols','wildcard','empty','op','start','filter','join','need_full_no_count'), 0, count(func_get_args())), func_get_args())).')');
|
//error_log(__METHOD__.'('.array2string(array_combine(array_slice(array('criteria','only_keys','order_by','extra_cols','wildcard','empty','op','start','filter','join','need_full_no_count'), 0, count(func_get_args())), func_get_args())).')');
|
||||||
if (!$this->customfields)
|
if (!$this->customfields)
|
||||||
{
|
{
|
||||||
$this->remove_customfields($criteria);
|
|
||||||
$this->remove_customfields($only_keys);
|
|
||||||
$this->remove_customfields($order_by);
|
|
||||||
$this->remove_customfields($extra_cols);
|
|
||||||
$this->remove_customfields($filter);
|
|
||||||
return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
|
return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
|
||||||
}
|
}
|
||||||
if ($only_keys === false)
|
if ($only_keys === false)
|
||||||
@ -688,52 +683,6 @@ class Storage extends Storage\Base
|
|||||||
return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
|
return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Make sure there are no custom fields referred to in the field
|
|
||||||
*
|
|
||||||
* Use this to prevent SQL errors caused by queries / favorites that refer to
|
|
||||||
* a custom field that is no longer available due to permission changes or
|
|
||||||
* deletion.
|
|
||||||
*
|
|
||||||
* @param Array|String $field
|
|
||||||
*
|
|
||||||
* @return Boolean True if any changes were made
|
|
||||||
*/
|
|
||||||
public static function remove_customfields(&$field)
|
|
||||||
{
|
|
||||||
$was_string = false;
|
|
||||||
$changed = false;
|
|
||||||
if(is_string($field) && strpos($field, self::CF_PREFIX) !== FALSE)
|
|
||||||
{
|
|
||||||
$was_string = true;
|
|
||||||
$field = explode(',',$field);
|
|
||||||
}
|
|
||||||
if(!is_array($field))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
foreach($field as $key => $value)
|
|
||||||
{
|
|
||||||
|
|
||||||
if($key[0] == self::CF_PREFIX || is_string($value) && strpos($value, self::CF_PREFIX) !== FALSE)
|
|
||||||
{
|
|
||||||
unset($field[$key]);
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
else if(is_array($value))
|
|
||||||
{
|
|
||||||
$changed = $changed || static::remove_customfields($value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($was_string)
|
|
||||||
{
|
|
||||||
$field = implode(',',$field);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a default list of columns to search
|
* Get a default list of columns to search
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user