&$sortkey: Sortkey to use.
'GetDifferenceEngine': Called when getting a new difference engine interface
-object Return false for valid object in $differenceEngine or true for the
-default difference engine.
+object. Can be used to decorate or replace the default difference engine.
$context: IContextSource context to be used for diff
$old: Revision ID to show and diff with
$new: Either a revision ID or one of the strings 'cur', 'prev' or 'next'
$refreshCache: If set, refreshes the diff cache
$unhide: If set, allow viewing deleted revs
-&$differenceEngine: output parameter, difference engine object to be used for
- diff
+&$differenceEngine: The difference engine object to be used for the diff
'GetDoubleUnderscoreIDs': Modify the list of behavior switch (double
underscore) magic words. Called by MagicWord.
/**
* Factory for creating an appropriate DifferenceEngine for this content model.
*
+ * The DifferenceEngine subclass to use is selected in getDiffEngineClass(). The
+ * GetDifferenceEngine hook will receive the DifferenceEngine object and can replace or
+ * wrap it.
+ * (Note that in older versions of MediaWiki the hook documentation instructed extensions
+ * to return false from the hook; you should not rely on always being able to decorate
+ * the DifferenceEngine instance from the hook. If the owner of the content type wants to
+ * decorare the instance, overriding this method is a safer approach.)
+ *
* @since 1.21
*
* @param IContextSource $context Context to use, anything else will be ignored.
$rcid = 0, // FIXME: Deprecated, no longer used
$refreshCache = false, $unhide = false
) {
- // hook: get difference engine
- $differenceEngine = null;
- if ( !Hooks::run( 'GetDifferenceEngine',
- [ $context, $old, $new, $refreshCache, $unhide, &$differenceEngine ]
- ) ) {
- return $differenceEngine;
- }
$diffEngineClass = $this->getDiffEngineClass();
- return new $diffEngineClass( $context, $old, $new, $rcid, $refreshCache, $unhide );
+ $differenceEngine = new $diffEngineClass( $context, $old, $new, $rcid, $refreshCache, $unhide );
+ Hooks::run( 'GetDifferenceEngine', [ $context, $old, $new, $refreshCache, $unhide,
+ &$differenceEngine ] );
+ return $differenceEngine;
}
/**