SEO Lite
ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4
Back to this add-on's main page
View Other Add-ons From Bjorn Borresen
fix for MSM-related bugs
Bug Report
Karen
|
Posted: 13 January 2012 02:00 PM |
|
|
|
We found that SEO Lite has an issue where it will not display metadata in the entry tab or on the website if the entry_id appears more than once in the seolite_content table. We noticed this because using the Multiple Site Manager migration tools can cause the same entry_id to appear with a different site_id (after entries are moved from one site to another). In order to work around this, we changed the following lines (plugin version 1.3.4):
tab.seo_lite.php line 32:
$q = $this->EE->db->get_where('seolite_content', array('entry_id' => $entry_id,'site_id' => $this->EE->config->item('site_id')));
mod.seo_lite.php line 89:
$where = array('channel_titles.site_id' => $site_id, 'seolite_content.site_id' => $site_id);
Please advise if this is a proper fix for this issue. It seems to work, from what I can see. To test, simply create a couple of rows in seolite_content with different site_ids but the same entry_id. On the entry with the higher site_id, you’ll find that the metadata fields clear after submission (though the data is saved) and that the website is not using the data.
Thanks for the free plugin! Hope this helps to pay you back some.
|
|
|
Bjørn Børresen
|
Posted: 15 January 2012 06:30 AM |
# 1
|
|
Developer
|
Thanks for the bugreport .. entry_id should always be unique though, as it has auto_increment on that row in the database .. so in this case your db seem to have been corrupted by the move.
It is however best practice to use site_id, so I’ll implement this just in case.
|
|
|
Karen
|
Posted: 16 January 2012 10:02 AM |
# 2
|
|
|
Our database shows that seolite_content_id has primary key and auto increment, but entry_id is just an int(10). I don’t know why entry_id would auto increment, as that would mess things up, because it’s related to the entry that the metadata is for. Thus you can have different seolite_content_id values with the same entry_id caused by copying entries with the Multiple Site Manager when moving a site.
|
|
|
Bjørn Børresen
|
Posted: 16 January 2012 10:13 AM |
# 3
|
|
Developer
|
Yes, I was referring to the entry_id in exp_channel_titles .. it’s auto-increment, so it should be unique.
|
|
|
Karen
|
Posted: 16 January 2012 10:22 AM |
# 4
|
|
|
Ah, I see what you mean. I think what’s happening here is actually that we had entries in let’s say SITE1 and then we MOVED them (not copied) so that the same entry_ids now had a different site_id. Then SEO Lite created data for the same entry_ids but under SITE2. Since SEO Lite doesn’t appear to remove or re-use the old data from exp_seolite_content, and it’s making the assumption that entry_id is a unique field when it calls the data, it’s possible to mess the plugin up by doing this. Does that make sense?
|
|
|
Bjørn Børresen
|
Posted: 16 January 2012 10:30 AM |
# 5
|
|
Developer
|
Yup,
I’m just saying that since entry_id in exp_channel_titles is auto_increment, having a db where entry_id is not unique means the db is corrupt. It just shouldn’t happen, AFAIK… so it might lead to other issues, not sure.
But yeah I’ll add site_id check in SEO Lite since it obv. can happen in cases like this.
|
|
|
Karen
|
Posted: 16 January 2012 10:45 AM |
# 6
|
|
|
No, our database is fine. I checked and you are correct - entry_id IS unique in exp_channel_titles. It’s not the entry_id in the exp_channel_titles table that’s a problem. The problem is that the plugin is assuming that there will only be one row returned when it calls exp_seolite_content to get the data for an entry. However, on line 100 of mod.seo_lite.plugin you are doing a join on entry_id which is I think where you are ending up getting two rows returned, because there are two rows in exp_seolite_content with the same entry_id even though there is only one in exp_channel_titles. The same thing happens in tab.seo_lite.php because it’s JUST calling exp_seolite_content by entry_id.
Again, this is a weird thing to have happen because normally it would be a totally fine assumption that exp_seolite_content only had one line for each entry_id but since there’s no cleanup of that table when you move a site’s entries, it’s possible for this to be untrue after SEO Lite saves data for ENTRY1 at SITE1 and then again for ENTRY1 at SITE2.
Not a big deal since you said you’ll make the change, but I just thought it would be better to clarify. I appreciate your help with this, and I really appreciate the plugin!
|
|
|
Karen
|
Posted: 16 January 2012 10:48 AM |
# 7
|
|
|
Technically, I suppose a better fix might have been to actually change the save routine so that it only saves data to exp_seolite_content using entry_id and actually overwrites the site_id each time it saves, thus preserving the assumption that entry_id is unique in the exp_seolite_content table. That would ensure that no duplicate entry_ids are present in the table. I have no idea if that would have unintended consequences, though.
|
|
|
Karen
|
Posted: 16 January 2012 10:52 AM |
# 8
|
|
|
So really, it’s line 122 in tab.seo_lite.php that’s the real culprit here I think, because that’s where it’s saving via site_id AND entry_id, which is causing my duplicate entry_ids in exp_seolite_content. However, DISCLAIMER: the original solution I gave is tested and working in production, and this idea is only speculation :)
|
|
|