MyBB Community Forums

Full Version: Reasons Not To Make Core Edits
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Before I begin, I want to emphasize the fact that I am not condemning the use of core edits on any level. This is simply my take on things.

Why Do People Edit The Core Files?

The obvious answer is that the changes they wish to make cannot be achieved through the provided API. In other words, the official channels do not provide a method to accomplish the goal of the custom feature or plugin that is coveted.

So admins sometimes just edit the PHP files to attain the functionality they desire. Sometime it is as simple as adding a hook so that an external plugin can take advantage of it and complete the task. Other times the edits can be as drastic as replacing entire core files.

So What Is The Problem?

There are many issue, but at the top of the list is maintenance.

Lets say that you make a few (or a lot of) core edits and accomplish your goal. Then another version of MyBB comes out, replacing the files to the original state and undoing your changes. So you then have to make the edits again-- remember even if you back up your old files, you can't just overwrite them with the new files because this could cause you to miss bug fixes/enhancements/security issue-- you have to redo your edits every time the affected file is included in an update.

Also, there is always the possibility that existing plugins depend on the MyBB source files to be intact; for the routines to function as advertised; and for the data to be as expected. If you are an experienced developer, this shouldn't be an issue, but for those simply following advice from a forum post, be very careful making edits that you don't understand.

So What Is The Alternative?

First and foremost, try to avoid directly editing core files. Sometimes the answer is to think outside the box. Can you hook into an earlier point in the code and perform the task? Can you hook in later and amend/update the DB? In some situations it is simply easier, in terms of work hours, to edit the core-- but that is only in the short term. In the big picture, maintenance for the life of your forum is always more work.

Other resources include the community. Follow smart posting guidelines; title the thread informatively; and be patient. Perhaps another member of the community has already solved your problem.

What If Core Edits Cannot Be Avoided?

Then I would suggest using Patches. I have used it for years and maintained a few small patches to my forum code for years without a single issue. Even when upgrading 1.6->1.8 re-patching was done in a matter of minutes.

But I admonish you not to download the patches plugin and start editing all kinds of things into the code. Go back to the earlier portion of this document and try all of the other methods before making the decision to edit the core files-- even with the Patches plugin.

A Note About Plugins and Themes

I have seen a few themes that completely replaced forumdisplay.php and other files. This is a horrible idea. As a designer/developer, we have enough to do just to maintain our work across MyBB updates without having to watch a particular file with eagle eyes for the foreseeable future to be sure nothing changes that would endanger users in our obsolete copy.

Please, just integrate a plugin into the theme if you find behavior modification is necessary.

And many of the best plugins have used PluginLibrary to handle core edits-- I have no problem with that whatsoever. I am confident that as responsible devs, they tried everything within their power to avoid making core edits-- and in many cases I know for a fact that they did because I helped them try to figure it out.

In Conclusion

Don't do it Toungue
Agreed.

Even you will lose all file changes into updates to make your forum up to date.

Sometimes many code parts would change and we as developers must find out a way to our modd works fine without several changes/editions.

I prefer to find a way to use some hook or if hook does not exist is more easy to make a new one and write that in a paper in wich part have to add it and use it in your plugin.

U never try to change core files, only if is absolutely necessary.

But imo i have to agree with not change the core files.