* Calendar: when trying to load new holidays overwrite existing ones to not accumulate old ones (slowing down calendar)

This commit is contained in:
Ralf Becker 2015-04-30 09:39:36 +00:00
parent 492c0be535
commit 1f2e12d6a0
2 changed files with 16 additions and 8 deletions

View File

@ -259,7 +259,7 @@
$total_year == $this->so->holiday_total($locale, '', 1901)))
{
//error_log(__METHOD__."('$locale', $year) attemption autoload ...");
egw_cache::setInstance(__CLASS__, $locale.'-'.$year, true, 86400); // do NOT try again for 1 day
egw_cache::setInstance(__CLASS__, $locale.'-'.$year, true, 864000); // do NOT try again for 10 days
@set_time_limit(0);
/* get the file that contains the calendar events for your locale */

View File

@ -45,7 +45,7 @@ class soholiday
{
if (!is_numeric($name))
{
$holiday['hol_'.$name] = $holiday[$name];
$holiday['hol_'.$name] = $val;
}
unset($holiday[$name]);
}
@ -68,6 +68,12 @@ class soholiday
{
echo "Inserting LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n";
}
// delete evtl. existing rules with same name, year (occurence) and local
$this->db->delete($this->table, array(
'hol_name' => $holiday['hol_name'],
'hol_occurence' => $holiday['hol_occurence'],
'hol_locale' => $holiday['hol_locale'],
), __LINE__, __FILES__, 'calendar');
$this->db->insert($this->table,$holiday,False,__LINE__,__FILE__,'calendar');
}
}
@ -174,9 +180,11 @@ class soholiday
if(!preg_match('/^[a-zA-Z0-9_,]+$/',$order))
{
$order = 'hol_local';
$order = 'hol_locale';
}
foreach($this->db->select($this->table,'DISTINCT hol_locale',$querymethod,__LINE__,__FILE__,false,$order,'calendar') as $row)
if (strtoupper($sort) != 'DESC') $sort = 'ASC';
if (strpos($order, ',') === false) $order .= ' '.$sort;
foreach($this->db->select($this->table,'DISTINCT hol_locale',$querymethod,__LINE__,__FILE__,false,'ORDER BY '.$order,'calendar') as $row)
{
$locale[] = $row['hol_locale'];
}