Note: This post assumes that you have migrated the K2 extension to the latest version on Joomla 1.5 prior to migrating to Joomla 2.5.
We are currently working on a large, a very large migration project from Joomla 1.5 to Joomla 2.5. A mini-project in this migration project is migrating K2 content to the new Joomla website. K2 migration is usually very easy and straightforward. Here’s what we did to migrate K2:
- We migrated the old version of K2 to the latest version of K2 on the old (Joomla 1.5) website.
-
We installed K2 on the new (Joomla 2.5) website.
-
We copied all the K2 tables (using phpMyAdmin) from the old website to the new website.
The above process was supposed to work seamlessly, since both websites have the latest version of K2 (which means that the K2 database structure is exactly the same), but for some reason, K2 items in the K2 content module (as well as other K2 modules) did not show up.
So, we opened the K2 content module and printed the query that was used to retrieve the rows from the database, and here’s what we got:
SELECT i.*, CASE WHEN i.modified = 0 THEN i.created ELSE i.modified END as lastChanged, c.name AS categoryname,c.id AS categoryid, c.alias AS categoryalias, c.params AS categoryparams FROM #__k2_items as i LEFT JOIN #__k2_categories c ON c.id = i.catid WHERE i.published = 1 AND i.access IN(1,1) AND i.trash = 0 AND c.published = 1 AND c.access IN(1,1) AND c.trash = 0 AND ( i.publish_up = '0000-00-00 00:00:00' OR i.publish_up <= '2013-02-21 17:38:03' ) AND ( i.publish_down = '0000-00-00 00:00:00' OR i.publish_down >= '2013-02-21 17:38:03' ) AND i.catid IN (1,2,3,4,5) ORDER BY i.created DESC
We ran the exact query on phpMyAdmin to see if there’s anything wrong, and while there was nothing wrong with it, it didn’t return any rows. So, we looked deeper into the issue and we started dissecting the above query by removing conditions, until we discovered the two conditions that were causing the problem. Both are highlighted in red below:
SELECT i.*, CASE WHEN i.modified = 0 THEN i.created ELSE i.modified END as lastChanged, c.name AS categoryname,c.id AS categoryid, c.alias AS categoryalias, c.params AS categoryparams FROM #__k2_items as i LEFT JOIN #__k2_categories c ON c.id = i.catid WHERE i.published = 1 AND i.access IN(1,1) AND i.trash = 0 AND c.published = 1 AND c.access IN(1,1) AND c.trash = 0 AND ( i.publish_up = '0000-00-00 00:00:00' OR i.publish_up <= '2013-02-21 17:38:03' ) AND ( i.publish_down = '0000-00-00 00:00:00' OR i.publish_down >= '2013-02-21 17:38:03' ) AND i.catid IN (1,2,3,4,5) ORDER BY i.created DESC
Aha! It was the access field which seems to be irrelevant in K2’s implementation in Joomla 1.5, but critical in that of Joomla 2.5. We looked at both the #__k2_categories and the #__k2_items tables, and sure enough, the access column was set to 0 across the board in both these tables.
So, what did we do to fix the problem?
Solving the problem was quite easy, all we needed to do was to issue the two following SQL queries in phpMyAdmin (of course, after changing #__ with the table prefix):
UPDATE `#__k2_categories` SET `access` =1;
UPDATE `#__k2_items` SET `access` =1;
That’s it! After we did that, all the K2 modules were properly populated. Problem solved!
If you’re having problems with K2 items not showing up in your modules, then try the above method, and if it works, then we’re glad we were able to help. If it doesn’t, then just contact us and we’ll fix it for you in no time and at a very affordable cost. We’re experts in Joomla, we’re professional, and we’re really nice to work with!
Thank you, very helpful, you saved me a lot of time! I had already set access=1 to k2_items, but I couldn’t access the articles…
Hi Michelangelo,
Please try to print the query in the affected modules and then run it on phpMyAdmin. See if it returns anything.
Works like charm.
Thanks
– Akki
[…] after migration – if not you will definitely experience what’s described here), your items and categories will appear as they should since all the settings will be […]
You’re literally a life safer. It’s not the first time I came across your site when googling about Joomla issues. I’m still on J2.5, and even though it’s not really related to this article, your query helped me find out the cause of my SLOW QUERY, which was the “access = 1” part of the query, which I didn’t need and caused a very slow query on my website, having dozen thousand articles.
Thanks again