Many to Many bug?

Many to Many bug?, a forum discussion on Jojo CMS. Join us for more discussions on Many to Many bug? on our General Discussion forum.

Back to Forum Index : Back to General Discussion   RSS
Jaijaz Jaijaz

8 Mar 2010
Posts: 215

I think I have found an issue with the many to many field that I have spent a lot of time trying to solve but haven't been able to find the cause. So will the bug tracking down for the time being, I thought I would post here to see if anyone can shed some light on it.

Basically every time you save a record for a table that is using a many to many field, a record is added to the link table linking the current record to linkid 1. This is regardless of whether there is a record id 1 in the Link Category Field. Of course if there is a record 1 in that Link category table then it is automatically ticked.

Any thoughts?
If you not living on the edge you taking up too much space.
Harvey

Core Developer

Harvey

8 Mar 2010
Posts: 327

Yeah, I had this recently. It was because the fielddata was setup the wrong way around.

IIRC it was the 'link item field' and link category field' values that needed swapping.

If you still aren't sure which way around it should go, post a structure dump of the relevant tables and we can let you know which way around it's supposed to go.
Jaijaz Jaijaz

9 Mar 2010
Posts: 215

Just got a chance to test that and it didn't change anything. It still auto tagged id 1.

In terms of structure dump, it is happening for me with the standard newsletter phplist plugin. So the fielddata setup for that as per the svn version and the one I'm using is:

'fd_m2m_linktable' => "phplist_listuser",
'fd_m2m_linkitemid' => "userid",
'fd_m2m_linkcatid' => "listid",
'fd_m2m_cattable' => "phplist_list",

So in this example you have in edit newsletter users, the newsletter group with id 1 will always get tagged. If you remove the group with id 1 or change the id to something else, the group won't get tagged but a link record linking this userid to groupid 1 still gets put into the link table.
If you not living on the edge you taking up too much space.
Jaijaz Jaijaz

14 Mar 2010
Posts: 215

I have just been doing some testing on this and it is doing it on the latest svn too.

Anyone else having troubles with this?
If you not living on the edge you taking up too much space.
Jaijaz Jaijaz

14 Mar 2010
Posts: 215

So after doing some further debugging, I have found the line that was changed to cause this problem. It is line 138 of Many2many.php

$output .= '<input type="hidden" name="fm_'.$this->fd_field.'" value="1" />'.$tree->printout_plain();

If I change the value to 3 then everything is linked to item 3 in the link table.

In older versions of Jojo the line used to read:
$output .= $tree->printout_plain();

Can anyone shed some light on why it was changed and/or what would be the harm of removing the extra bit?

Thanks.
If you not living on the edge you taking up too much space.
damien damien

17 May 2010
Posts: 24

Yeah I have experienced this on many sites.
For me, it seemed to be related to using a integer unique id for the LINK CAT ID
If you use a text unique ID instead, it seems to work...

I really hope you can fix, im trying to get another Many2Many going at the moment
But its using integers for the IDs, and i really dont want to change it..

;)
Jaijaz Jaijaz

17 May 2010
Posts: 215

Hey damien,

Hmm. I can't get my head around why text field type would fix it. When I get a chance I will look into it.

Anyway since posting that some time ago, I have found that taking the line back to previous version doesn't fix it properly. In fact it can stop anything from saving.

Instead I changed it to this:

$output .= '<input type="hidden" name="fom_'.$this->fd_field.'" value="1" />'.$tree->printout_plain();

Line 160 needs to also change to this, to ensure that it attempts to save:

if (Jojo::getPost('fom_'.$this->fd_field, false)) {

I haven't committed the change cause I am show that there is probably something I'm missing but it has now successfully been working across, all my sites for close on 2 months, with no complaints from any of my clients.

Hope that helps.
If you not living on the edge you taking up too much space.
damien damien

18 May 2010
Posts: 24

that totally works!

YEAH ^.^ thanks for the help
Back to Forum Index : Back to General Discussion   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.