Do not hack MediaWiki core/zh

虽然“骇入MediaWiki核心”通常是一个在其他MediaWiki支持论坛上提出的解决方案，但它并不是一个理想的解决方案. 通常，它会给您带来跟多的问题而不是解决问题，并且只会使将来的升级更加难以安装.

在本文中的“核心”指包含属于原始MediaWiki安装的所有文件，也就是说除了LocalSettings.php之外的所有文件、“extensions”文件夹中的文件以及其他您在安装过程中添加的其他文件夹.

为什么您不应该修改核心文件
无论修改核心文件是多么容易，能让MediaWiki做你想做的事，请抵制诱惑.


 * 这样做会使网站更新（如安全性和错误修复）变得复杂，困难或几乎不可能.
 * You will make it difficult for those that come after to maintain the site.
 * You could possibly leave your site vulnerable to exploits.
 * Other developers are less inclined to help you if you have hacked your core - if for no other reason than it is difficult for them to know what has been done.

The MediaWiki core has been designed to be modular, so there should be no reason to hack it. If there is a feature you want and it cannot be accomplished outside of modifying core, consider developing an extension or submitting your hack as a patch. Submit a bug report and tell the community the feature you want to accomplish. It will then be tested and your feature may become a part of the MediaWiki core.

Problems faced by wikis which hack their core

 * MediaWiki upgrade times go from 30 minutes to 6 hours or even 6 weeks if your  shows 13650 lines have been changed.
 * Increase in spam and other unwanted attacks due to security holes.
 * Missing out on new features due to conflicting hacks to core files.
 * Inability to use MediaWiki.org documentation - all of which has been written under the assumption that you have not hacked your core files (unless of course you write documentation specifically for how to operate MediaWiki when that particular hack is being used).
 * Repetition of the original problem - as a bug report is a far more reliable way to solve a problem than a core hack - if for no other reason than a group of developers will be looking into the problem and may discover necessary code changes you missed.
 * Complaining to developers about your core files not working - and not finding much sympathy - if you hack core files - effective technical support is all but impossible.

Exceptions
Are there exceptions to this rule?

Nope.

Okay, very very rarely. But this is generally for specific wikis or implementations by people who are extremely familiar with the MediaWiki code base, development practices and security model. Those who properly document their changes and practice proper revision control with their code. If you have to ask, chances are you shouldn't.

Extensions
Note that most of this page also applies to important extensions. It's a bad idea to directly start hacking the Semantic MediaWiki extensions, or any of the extensions used on Wikipedia and other Wikimedia sites.

An exception could be if an extension is mainly installed by copying its code from this wiki (instead of getting it from a software repository). It means it's not very seriously maintained.

What to do instead
Rather than hacking MediaWiki core, there are several alternative solutions to consider, more or less in this order:


 * 1) MediaWiki is a powerful beast out of the box, you can do a lot with MediaWiki's interface messages such as   and many many others, see also other pages on this wiki for e.g. JavaScript and CSS additions and changes.
 * 2) 开发扩展以实现您打算做到的事情，或者完全可以使用现有钩之一
 * 3) Submit a bug report
 * 4) Contribute your improvement to core to the code repository so others can benefit from your fix