Forums / Developer / Problems with related objects and 3.4.0

Problems with related objects and 3.4.0

Author Message

Roberto Cespa

Wednesday 16 June 2004 4:22:36 pm

Hi there,
I hope this is the right forum to write this post.
While using the new eZ3.4, I made a template that uses the reverse_related_object_list.

So, I've got a class called Diseases and one more class called Genes. While adding contents to one of them, I add related objects of the other one, eg: colon cancer type 1 <-> MSH2 gene.

Everything works fine, but if I delete one relation between the objects, it is only deleted from the one where I started the relation.
I'll try to explain it better: if I create a new relation from colon cancer type 1 (Disease) with another gene and then I trash it, while looking at the disease everything seems to work fine, if I view the gene page I'm still finding the wrong/deleted related object.

I've tried clearing all the caches, but it does not work.

This is my template code (gene_view_full.tpl):

{* Forward relation *}
{let related_objects=$node.object.related_contentobject_array}
{section show=$related_objects} 
<ul>
{section name=ContentObject loop=$related_objects show=$related_objects} 
        <li><a href={$ContentObject:item.main_node.url_alias|ezurl}>{$ContentObject:item.name}</a></li>
{/section}
</ul>
{/section}
{/let}

{* Reverse relation *}
{let reverse_related=$node.object.current.reverse_related_object_list}
<ul>
{section name=ReverseObject loop=$reverse_related show=$reverse_related}
<li><a href={$ReverseObject:item.main_node.url_alias|ezurl}>{$ReverseObject:item.name}</a></li>
{/section}
</ul>
{/let}

Any help is appreciated.
Thanx,
Roberto

P.S.: Really a great job, but there is a very strange behaviour: while EZP runs fine (maybe a little bit slowly) on a Linux Box (PIII@600MHz with 256Megs and UW2 disks), it really hangs on my Centrino 1.3 notebook with 512Megs and UDMA drive and.... yes... Windows XP! I've used the installers for both machines.

--
In 1968, computing power of two C64 took a rocket to the moon. In 2004 the computing power of an Athlon3000+ is barely enough to run Windows XP... Something has gone wrong!

Kåre Køhler Høvik

Monday 21 June 2004 8:00:36 am

The object relation list is not reflexive. To delete relation in both directions you need to delete both of them. Hope I understood your problem correctly.

--
Kåre Høvik

Kåre Høvik

Roberto Cespa

Wednesday 30 June 2004 3:37:14 pm

I apologize for the delay in this reply, but I spent a lot of time solving another problem with ez (&->&amp; conversion, still not solved, but this would be off topic here).

I'm sorry, but I cannot understand your reply.
I have three objects A, B and C.

In the template (the public one, not in the admin), as I wrote before, I use the reverse_related_object_list property.
So A and B are related. Then I want to link B to C. Quite simple! And it works, if I browse on the site looking for C, I can find a link backwards to B.

Now, I decide that the relation between B and C is not correct anymore. So, I go to the admin side, edit object B and trash the relation with C.

On the public side, I browse to B and the "forward link" B->C is not there any more. Good!
Always on the public side, I browse to C and I still find the backward link C->B. Ouch!

This backward link is not present in the admin side. If I try to edit C, there is no related object at all.

Just note that even with the relation B->C, I'm not able to see the backward B<-C in the admin side. At least not with the standard admin templates.

Ciao,
Roberto

Kåre Køhler Høvik

Thursday 01 July 2004 1:12:17 am

Hi

Checked it, and it's caused by a bug. I fixed it in:
stable/3.2 rev. 6982
stable/3.2 rev. 6983
stable/3.2 rev. 6984
trunk rev. 6985

Fix :

Index: kernel/classes/ezcontentobject.php
===================================================================
--- kernel/classes/ezcontentobject.php  (revision 6983)
+++ kernel/classes/ezcontentobject.php  (working copy)
@@ -1632,7 +1632,8 @@
                                             WHERE
                                               ezcontentobject.id=ezcontentobject_link.from_contentobject_id AND
                                               ezcontentobject.status=" . EZ_CONTENT_OBJECT_STATUS_PUBLISHED . " AND
-                                              ezcontentobject_link.to_contentobject_id='$objectID'" );
+                                              ezcontentobject_link.to_contentobject_id='$objectID' AND
+                                              ezcontentobject_link.from_contentobject_version='$version'" );

         $return = array();

Thanks for reporting it.

--
Kåre Høvik

Kåre Høvik

Roberto Cespa

Thursday 01 July 2004 4:32:03 am

Thanx Kåre,
I've tried to correct those lines by hand but the relation is still there.
Honestly I did not spend many time trying to understand what is done by that piece of code... maybe the code will work with newly created objects....

Ciao,
Roberto