It was around 3 AM in the morning – we were working hard on a project to meet a deadline that was set for next week, but we were stuck. The project consisted of a migration of a Joomla website from version 1.5 to version 2.5 – something that we have done hundreds of times before! But, again, we were stuck. What’s even more embarrassing is that we were stuck on the migration of a very simple content plugin. We have migrated the plugin, ensured that all the code is correct, but the plugin just won’t execute. Mind you, the plugin was activated (or published, depending on the terminology you like to use, we prefer using activated for plugins and published for content items such as articles) and the plugin was loading properly (we added an echo statement in the function plgContent[OurPlugin] and it was displaying). We knew that the solution couldn’t be easier, but we just didn’t know what was the problem!
We finally decided to re-write the plugin from scratch – yes, it was inefficient, but it was a very simple plugin and re-writing it from scratch was an easy task. Around 5 AM, we finished re-writing the plugin (again, it was very simple and the logic was all defined for us in the original plugin!) for Joomla 2.5 – we tested it and it was working! As you have probably guessed, seeing the plugin working didn’t satiate our curiosity! We needed to know why the plugin wasn’t working before!
So we compared the two plugins together and we noticed something: The first plugin had the onPrepareContent function and the second plugin had the onContentPrepare function. Needless to say, the immediate reaction to this was the usual forehead slap! Of course, Joomla 1.5 uses the onPrepareContent while Joomla 2.5 uses the onContentPrepare! The engine just ignores the plugin if this function is named incorrectly.
But why did the core team at Joomla rename this function?
Nobody knows for sure! Perhaps consistency – but we seriously doubt it. Our best guess is that it was named this way to allow for developers to create plugins that will support Joomla 1.5 and Joomla 2.5 at the same time – this makes sense because the parameters of the two functions are different (there is an additional parameter called $context in the function onContentPrepare).
But aren’t we too much experienced to make that mistake?
We are – hence the forehead slap! The fact that it was 3 AM in the morning was also probably a contributing factor to this mistake! Everyone makes mistakes – and we don’t claim to be perfect! But you can always rest assured that we will find a solution to the problem, and the solution will always be elegant!
So, if you’re migrating some very old and/or discontinued extensions and you’re facing similar problems – then fear not, you are not alone! And if you ever need help, then you can always contact us! Our fees are very affordable, our reputation is immaculate, and we really really care about our clients!