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.