Changeset 180 for mods

Show
Ignore:
Timestamp:
01/17/07 09:02:44 (14 years ago)
Author:
exi
Message:

Copied potential fix for the sync error from devtree.

Location:
mods/Sync_Server
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • mods/Sync_Server/globals.php

    r161 r180  
    22// current version: major.minor.sub 
    33// unpair numbers for minor = development version 
    4 define('KB_VERSION', '1.2.2'); 
     4define('KB_VERSION', '1.4.1'); 
    55 
    66// set the running-server for id-syncs here 
  • mods/Sync_Server/sync_server.php

    r161 r180  
    9393        $qry->execute("replace into kb3_item_stats (itm_name,kb_host,itm_externalid,itm_value) VALUES ('".addslashes($matches[1][$i])."','".$hostid."','".addslashes($matches[2][$i])."','".addslashes($matches[3][$i])."')"); 
    9494    } 
     95    unset($matches); 
    9596} 
    9697unset($data); 
     
    129130 
    130131$data_array = $data_values = array(); 
     132$lastname = ''; 
    131133$qry->execute('select itm_name, itm_externalid, itm_value from kb3_item_stats order by itm_name asc, itm_value asc'); 
    132134while ($data = $qry->getRow()) 
    133135{ 
     136    // looks like we hit the memory limit so median extraction has to happen here 
     137    if ($lastname != $data['itm_name']) 
     138    { 
     139        // check for lastname due to initialisation 
     140        if ($lastname) 
     141        { 
     142            // get the median value for the item 
     143            $val_cnt = count($data_values[$lastname]); 
     144            $val_cnt = min(ceil($val_cnt/2), $val_cnt)-1; 
     145            $value = $data_values[$lastname][$val_cnt]; 
     146 
     147            $data_array[$lastname]['itm_value'] = $data; 
     148            unset($data_values[$lastname]); 
     149        } 
     150        $lastname = $data['itm_name']; 
     151    } 
    134152    $data_array[$data['itm_name']] = $data; 
    135153    $data_values[$data['itm_name']][] = $data['itm_value']; 
    136154} 
     155unset($data_values); 
    137156 
    138157$content_file .= 'ITEMS_START'; 
    139158foreach ($data_array as $data) 
    140159{ 
    141     // get the median value for every item 
    142     $val_cnt = count($data_values[$data['itm_name']]); 
    143     $val_cnt = min(ceil($val_cnt/2), $val_cnt)-1; 
    144     $value = $data_values[$data['itm_name']][$val_cnt]; 
    145  
    146     $content_file .= '§'.$data['itm_name'].'|'.$data['itm_externalid'].'|'.$value.'-'; 
     160    $content_file .= '§'.$data['itm_name'].'|'.$data['itm_externalid'].'|'.$data['itm_value'].'-'; 
    147161} 
     162unset($data_array); 
    148163 
    149164// return the compressed data back to the client