Migrating K2 to Joomla 4 – Why We Gave Up!

Note: Needless to say, it is important that you backup your website before migrating to Joomla 4.

Warning: Before migrating to Joomla 4 from Joomla 3, it is critical that K2 (as an extension) is completely disabled, otherwise, you will end up with a broken website and you will need to restart the migration from a backup.

Free Advice: K2 is just not compatible with Joomla 4 (at the time of writing, which is November 2022), so do not waste your time.

We love (or loved?) K2 – it is (was?) one of the most wonderful extensions out there, but, for some weird reason, the K2 developers haven’t created a Joomla 4 version yet (they are still promising they will eventually do it), and so we decided to do this ourselves for one of our clients. So, how did it go for us?

Well, we started working on a website which had about 50K articles – the content system was powered by K2, although none of the exclusive K2 features was used (so there was really no need for using K2). We did some research and discovered that no K2 compatible version was released for Joomla 4 yet. “Easy”, we thought – we’ll make it compatible ourselves – “Shouldn’t take long, right?”. Well, we couldn’t be more wrong.

We started working on a copy of the website, we disabled K2, performed the website migration to Joomla 4, and then re-enabled K2. We visited the frontend and we saw the first error:

Call to undefined method Joomla\CMS\Application\AdministratorApplication::isSite()

“Easy”, we said, we opened the k2.php file located under plugins/system/k2 folder and replaced:

if ($app->isSite()) {

with:

if ($app->isClient('site')) {

We refreshed the homepage and we saw another error, which was this one:

Class “JRequest” not found

“That’s a no-brainer”, we thought, and we replaced in the k2.php file which we had already opened before all occurrences of:

JRequest::getCmd, JRequest::getInt, and JRequest::get

with:

Joomla\CMS\Factory::getApplication()->getInput()->get

“That is fun”, we kept saying, but, as time went by and we saw our hairline slowly receding, it slowly became less and less fun and more and more like a torturous whack-a-mole game. Eventually, after a couple of weeks of fixing these errors (some of them were really insane to fix, as some Joomla 3 functions didn’t have a Joomla 4 equivalent, which we’re guessing is one major reason why the K2 developers were delaying the migration to Joomla 4) we had a working frontend, and we noticed, all of a sudden (it wasn’t really “all of a sudden”, but we’re trying to spice this post a bit), that our client uses the K2 backend to add content, which was much harder to work on because of the major template engine difference between Joomla 3 and Joomla 4. In other words, the backend work also had to consist of layout conversion work, which is outside of our realm for sanity reasons. So, while we’re known to have the tenacity of a hungry wild bear holding to the last salmon on a cold and slow fishing day, we gave up.

So, what did we do next?

We changed strategy altogether; instead of trying to adapt K2 to Joomla 4, we migrated the K2 content to Joomla 4’s core, which was not-a-straightforward process (we will talk about this in the near future), but infinitely less complex than getting K2 to work flawlessly on Joomla 4.

Is it worth waiting for the K2 team to develop a Joomla 4 version?

In all fairness, we wouldn’t hold our breath for it as there are several signs that tell us that it just won’t happen. We hope we’re wrong, and we hope it will happen, but for the moment, our only recommendation is to migrate to Joomla’s content system. This is sad, because, as we mentioned in the beginning of this article, and in all of our K2 articles, we love K2, and we really hate to see it being deserted en masse. Note that we may eventually do the migration ourselves, you never know! But for now, if you want to migrate your K2 content to Joomla 4, then you can always contact us. Our fees are reasonable, our work is quick and professional, and we’re in love with Joomla!

4 Responses to “Migrating K2 to Joomla 4 – Why We Gave Up!”
  1. Comment by Jorge — February 15, 2023 @ 11:41 pm

    Well, its a shame but its almost a fact they won’t be doing the upgrade to J4.

    Thanks for your time and input; really helped us save us a ton of time and work.

  2. Comment by Terry — August 29, 2023 @ 8:02 am

    Yes, it is a shame – we decided to move away from Joomla completely. The core dev’s are so disconnected from the real world, that keeping the sites updated is almost impossible and WordPress has a better model and extensions that are even better than what Joomla has to offer. Not because Joomla is bad, but because the core devs honestly are idiots that killed Joomla for any serious usage by giving a [edited] about downwards compatibility, having no clue about usability and so on. Joomla was fun while it lasted, but why invest 10 times the effort, if there is an easier to maintain solution available with WordPress.

  3. Comment by Fadi — August 29, 2023 @ 8:26 am

    The problem with WordPress is working with the code – it’s not well structured and it’s close to spaghetti code. The problem with Joomla is that it changes frameworks every few years (not necessarily for the better) which creates a lot of backwards compatibility as well as re-learning the system for current developers.

  4. Comment by Loopy — September 18, 2023 @ 7:50 am

    I bet on K2 since its inauguration more than a decade ago, for it provided everything one needs a website to do: integration with gallery/media systems developed by the same devs, extra fields, tags, attachments, modules and enormously powerful subtemplating system. And all that being maintained by 1 team, thus providing much more sustainable future than the jungle of 3rd party extensions being discontinued now and then. I read k2 was installed 4 million times. Where is that community and how come it can not push this project into sustainable future. Thank you for sharing this effort, it is a rare instance of shared experience what one can do in this miserable situation.

Leave a comment