Deprecation policy/Until 2017

Over time, the MediaWiki code base has changed quite a bit. It was originally written during the days of PHP4, which lacked some of the object-oriented niceties in PHP5. Also, as the code base matures, things naturally get refactored and moved around.

Sometimes in the course of writing the software, it is necessary to deprecate a particular function or hook from the software. The following guide is written for these times.

Things to consider when wanting to deprecate something

 * How used is it? Is it just 1 or 2 calls in core MediaWiki, or is it used in 30 different extensions?
 * Is there an acceptable alternative? If you're deprecating fooBar, is there a barFoo that accomplishes the same? Especially important if you're deprecating a still-used interface

Antipatterns

 * Sometimes deprecations are used as a way to shift the burden of coordination work on someone else's shoulders: T127233.

How to deprecate a method, function, etc.
There are two things that should be added to code when it is deprecated.
 * 1) First it needs to be marked as such in the source code with comments (typically, adding   to the function's docblock), and all callers should be fixed.
 * 2) It also should be marked with  . This will throw errors to any developers still using the code. All callers (in extensions and core) should have since been fixed, but this helps weed out stragglers over the next version. The first argument should be   to use the name of the method in the deprecation. Or more detailed text if you are deprecating just a small chunk of code. The second argument must be the version of MediaWiki you are deprecating the method in. This will allow deprecations to be filtered and also tracked.  For example:

In a future MediaWiki version (in this example 1.23 or later), the offending bit of code may be removed.

Deprecations of MediaWiki core functionality should be flagged for a minimum of two MediaWiki releases before removal (except in extreme circumstances). For example, if core is currently version 1.24alpha, then you can proposed deprecating it from MediaWiki 1.24, with removal scheduled for MediaWiki 1.26 or later. You must note breaking changes in the RELEASE_NOTES file, and should inform the  and.

Obviously, you should fix extensions and sample code to not use the functionality.

How to deprecate a hook
Deprecating a hook is different, because you want any code that handles the hook to issue a deprecation warning. So at the invocation of  (or the earlier form  :
 * Pass the MediaWiki version in which hook Foo is deprecated as the  parameter.
 * Add a comment afterwards

There is some other cleanup to do:
 * Document the hook Foo as "DEPRECATED"  in docs/hooks.txt, explain what to do instead.
 * Add  to the Manual:Hooks/Foo page.
 * Add "Note this hook is obsolete since MediaWiki 1.NN" to the Category:Foo_extensions page.
 * Update Manual:Hooks tables to indicate the hook is deprecated/obsolete since MediaWiki version 1.NN.