Yireo - Extensions, tutorials and blog for Magento and Joomla!

Blog Tags

MageBridge Standard

How serious are core hacks?

Tuesday, 05 October 2010

The definition of core hacks is that a file belonging to either the core application (Joomla!, Magento) or a third party application is modified directly, instead of overriding its behaviour by adding a new file. Those familiar with Joomla! or Magento know that core hacks are not done. By why?

It's about money and time

In case an application like Joomla! or Magento offers a way to prevent core hacks, it is better to use that method instead of modifying original files. But in some cases, this requires a lot of work. For instance, if you want to override a Magento class, you need to define this in XML-code and the only preferred way of introducing your own XML-code is by adding your own module. Before you know it, you are writing a complete Magento module just to modify something smallish.

You might be tempted to limit the amount of work, and just modify the responsible code directly. But such a core hack may cost you even more on the long run.

Watch out for upgrades

While a core hack might directly save you time (and therefor money), you need to keep an eye on the bigger picture: When the core of Magento is modified, this means that any Magento upgrade may override your changes. So every time you upgrade Magento, you need to check whether your changes still exist, and whether these changes need to applied again after the upgrade or not. A core hack brings along the requirement for comparing source files line-by-line.

With an official override (for instance, by adding a new Magento module) things are different. After an upgrade you don't need to check the source code at all - you only need to check whether your Magento module still functions. Ofcourse, this still brings along the chance that you need to modify your Magento module. But changes will be less frequent.

Good documentation

In general, if you don't have enough time to prevent core hacks, you will probably also lack the time for good documentation. But actually, in the case of core hacks, good documentation of what changes were made to the original code, is vital for maintaining that hack. Documentation could include some kind of changelog, with a per-codeline log of what has changed, but also inline commenting around the lines of the core hack.

Too many core hacks

We have seen Joomla! and Magento environments, where so many core hacks were applied to the application that searching for the actual changes alone already took us days. The only sensible alternative that we could offer to our customer was to redo all the work - but now properly. While this costed less than repairing all the core hacks, still the customer could have saved money when core hacks were prevented in the first place.

Know your application

To prevent core hacks, it is vital to understand the application you're working with. Any Joomla! expert should be familiar with things like plugins and template overrides, and if he/she is not, he/she is certainly not a Joomla! expert. With Magento being more complex, basic prevention of core hacks includes parent/child theming and copying core files to the local file-repository. More advanced methods include XML layout updates, class-overrides and routing changes. The tools are there: It just takes the right knowledge to use it.

About Yireo

Yireo tries to help webdevelopers build successful Joomla! and Magento sites.

More about Yireo