/** Static: collects the objects to send to the neighbour node. */
 function getModifiedObjects($remoteNode, $objectsPerPage)
 {
     global $db, $config, $repository;
     // an ordering in which objects should be retrieved because of foreign keys
     $tableOrder = $repository->tableOrder;
     // select objects to send to neighbour
     $result = $db->limitQuery("SELECT no.* FROM sotf_node_objects no, sotf_object_status os WHERE no.id = os.id AND no.node_id != '{$remoteNode}' AND os.node_id = '{$remoteNode}' ORDER BY strpos('{$tableOrder}', substring(no.id, 4, 2)), no.id", 0, $objectsPerPage);
     while (DB_OK === $result->fetchInto($row)) {
         $objects1[] = $row;
     }
     //debug("OBJECTS1", $objects1);
     // collect object data for selected objects
     $objects = array();
     if (count($objects1) > 0) {
         reset($objects1);
         while (list(, $obj) = each($objects1)) {
             $tablename = $repository->getTable($obj['id']);
             if (empty($tablename)) {
                 logError("No tablename found for ", $obj['id']);
                 continue;
             }
             $data = $db->getRow("SELECT * FROM {$tablename} WHERE id = '" . $obj['id'] . "'");
             // don't send occasional empty records
             if (count($data) > 1) {
                 $obj['data'] = $data;
                 $objects[] = $obj;
                 debug("sending modified object", $obj['id']);
                 //debug("", $obj);
                 //if(is_array($data)) foreach($data as $k => $v) {if(is_null($v)) debug($k, "is_null"); if($v === NULL) debug($k, "is null"); }
                 if ($tablename == 'sotf_blobs') {
                     $size = $size + strlen($obj['data']['data']);
                     debug("blobsize", $size);
                 }
             } else {
                 logError("DELETED object with empty fields", $obj['id']);
                 $db->query("DELETE FROM sotf_node_objects WHERE id='" . $obj['id'] . "'");
             }
             // delete from refresh table (will roll back if failed)
             sotf_NodeObject::removeFromRefreshTable($obj['id'], $remoteNode);
             // we cannot send too many blobs, it will result in memory allocation problems on the other side (but why??)
             if ($size >= 90000) {
                 break;
             }
         }
     }
     //debug("OBJECTS__2", $objects);
     debug("sending " . count($objects) . " objects");
     return $objects;
 }