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

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

eZ debug

Timing: Jan 19 2025 15:15:16
Script start
Timing: Jan 19 2025 15:15:16
Module start 'content'
Timing: Jan 19 2025 15:15:17
Module end 'content'
Timing: Jan 19 2025 15:15:17
Script end

Main resources:

Total runtime0.8801 sec
Peak memory usage4,096.0000 KB
Database Queries207

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 589.2109180.7969
Module start 'content' 0.00520.7811 770.0078687.6719
Module end 'content' 0.78630.0937 1,457.6797345.0234
Script end 0.8800  1,802.7031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.4236210.0002
Check MTime0.00130.1465210.0001
Mysql Total
Database connection0.00060.073110.0006
Mysqli_queries0.807291.71482070.0039
Looping result0.00170.19392050.0000
Template Total0.852796.920.4263
Template load0.00280.321720.0014
Template processing0.849896.562820.4249
Template load and register function0.00010.010810.0001
states
state_id_array0.00100.118110.0010
state_identifier_array0.00080.089820.0004
Override
Cache load0.00230.2605480.0000
Sytem overhead
Fetch class attribute can translate value0.00110.124850.0002
Fetch class attribute name0.00110.1198100.0001
XML
Image XML parsing0.00200.223050.0004
class_abstraction
Instantiating content class attribute0.00000.0020120.0000
General
dbfile0.00280.3158450.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs