Can somebody explain me the concept/idea of the remote id?

Author Message

Björn Dieding@xrow.de

Thursday 02 September 2004 7:20:53 pm

Hello coders,
I am currently coding something that will archive the sharing of eZContentobjects over databases (serializing/unserializing). I have one central db (content provider) and x amount of content receivers.

I am in the need of a value/constant that does not change when crossing borders.

At current point I wrote a new package handler, but I have problems with the concept of the remote_id.

Gurudutt Verma told me this:
----------------
The field remote_id/remoteID is never used in eZpublish. It is used while moving data from one database to another database. Also remote_id is generated by "md5( (string)mt_rand() . (string)mktime() )" so it depends on time.
----------------

If the remote_id would have a constant value for each object it would be perfect.

But I noticed the following with my installaion when I transfer one object.

Step 1:
created object in DB 1 with remote_id 4d311bd3122b02489a83e89d89cec058

Step 2:
serializing object in an package package info holds a new remote_id 4d5cd1bc69e1831c05a7f90ffec0164a

Step 3:
unserializing and and storeing the data in db2 with remote_id 4d5cd1bc69e1831c05a7f90ffec0164a

My problem is now that the id changed. Is this on purpose? Is the remote_id to be meant to never change once created?

Is there anybody that can give me hints?

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Björn Dieding@xrow.de

Thursday 02 September 2004 7:43:58 pm

this path will give you a constant id for serializing

Index: classes/ezcontentobject.php
===================================================================
--- classes/ezcontentobject.php	(revision 7803)
+++ classes/ezcontentobject.php	(working copy)
@@ -2529,11 +2529,15 @@
         $objectNode->appendAttribute( eZDOMDocument::createAttributeNode( 'class_id', $this->ClassID, 'ezremote' ) );
         $objectNode->appendAttribute( eZDOMDocument::createAttributeNode( 'published', eZDateUtils::rfc1123Date( $this->attribute( 'published' ) ), 'ezremote' ) );
         $objectNode->appendAttribute( eZDOMDocument::createAttributeNode( 'modified', eZDateUtils::rfc1123Date( $this->attribute( 'modified' ) ), 'ezremote' ) );
-        if ( !$this->attribute( 'remote_id' ) )
+
+        $db =& eZDB::instance();
+        $resultArray = $db->arrayQuery( 'SELECT remote_id FROM ezcontentobject WHERE id=\'' . $this->attribute( 'id' ) . '\'' );
+        if ( count( $resultArray ) )
         {
-            $this->setAttribute( 'remote_id', md5( (string)mt_rand() ) . (string)mktime() );
-            $this->store();
+            $this->setAttribute( 'remote_id', $resultArray[0]['remote_id'] );
         }
+
         $objectNode->appendAttribute( eZDOMDocument::createAttributeNode( 'remote_id', $this->attribute( 'remote_id' ) ) );
         $contentClass =& $this->attribute( 'content_class' );
         $objectNode->appendAttribute( eZDOMDocument::createAttributeNode( 'class_remote_id', $contentClass->attribute( 'remote_id' ) ) );

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Hans Melis

Friday 03 September 2004 3:03:18 am

I was surprised by Gurudutt Verma's reply. I too thought the remote_id was a constant value that never changed so that you could trace objects across different sites/databases.

The remote_id is based on a random value and the current timestamp. That in itself wouldn't be a problem if the id didn't change. But it's quite hard to trace objects across databases if their remote_id's don't match.

Hans
http://blog.hansmelis.be

Björn Dieding@xrow.de

Friday 03 September 2004 4:30:40 am

Y

So you would agree too that we need some real constant value, right?

Is there maybe another person from eZ that can throw in a comment?`

My current desision for the project is:
I make my own global remote_id and patch stuff here and there.

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Paul Borgermans

Friday 03 September 2004 10:09:40 am

Just my 0.02 ¤

A remote id indeed should be permanent and never be changed ... BUT ... by default there is no mechanism for having unique remote id's unless you cerate it yourself. I guess that's why it depends on time and a random number each time it is called. But this should be at least configurable to turn this randomness off in case you have a central registry of these remote-id's ... so Hans, we'll have to eternally remove the malicious code with each update or better, write a small extension which populates a real unique persistant 'remote id' table from our central registry server .... and use our own object transfer methods (outside of the import/export features).

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Ekkehard Dörre

Thursday 21 April 2005 12:55:59 am

Hi Björn,

is the remote_id in 3.5.1 now a constant value?
I saw you use it in your ezsvn.

Greetings, ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 00:26:54
Script start
Timing: Jan 19 2025 00:26:54
Module start 'layout'
Timing: Jan 19 2025 00:26:54
Module start 'content'
Timing: Jan 19 2025 00:26:54
Module end 'content'
Timing: Jan 19 2025 00:26:54
Script end

Main resources:

Total runtime0.7409 sec
Peak memory usage4,096.0000 KB
Database Queries70

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 588.1719152.6563
Module start 'layout' 0.00730.0026 740.828139.5078
Module start 'content' 0.00990.7295 780.3359682.5625
Module end 'content' 0.73940.0014 1,462.898420.0938
Script end 0.7408  1,482.9922 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4423160.0002
Check MTime0.00140.1844160.0001
Mysql Total
Database connection0.00170.226910.0017
Mysqli_queries0.669890.4047700.0096
Looping result0.00100.1322680.0000
Template Total0.708495.620.3542
Template load0.00230.305220.0011
Template processing0.706195.306420.3530
Template load and register function0.00010.015810.0001
states
state_id_array0.00130.174310.0013
state_identifier_array0.00090.127020.0005
Override
Cache load0.00200.2765480.0000
Sytem overhead
Fetch class attribute can translate value0.00070.092740.0002
Fetch class attribute name0.00150.2057100.0002
XML
Image XML parsing0.00180.236840.0004
class_abstraction
Instantiating content class attribute0.00000.0030120.0000
General
dbfile0.00110.1460340.0000
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs