jenkins-bot has submitted this change and it was merged.

Change subject: Add hook for custom difference engine (WikEdDiff)
......................................................................


Add hook for custom difference engine (WikEdDiff)

The new Extension:WikEdDiff is a custom inline difference engine.
There is currently no hook to integrate custom difference engines.
This patch adds a new hook called 'GetDifferenceEngine' in
/includes/content/ContentHandler.php in function
'createDifferenceEngine()'.

Passed variables:
$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

If the hook handler returns false, a valid difference engine object is
returned in the passed-by-reference variable $differenceEngine.
If the handler returns true, the default engine is used as fallback.

The specified diff engine class will typically be an extension of the
class DifferenceEngine (includes/diff/DifferenceEngine.php) with
modifications, e.g. of function generateTextDiffBody() and
__construct() (without deprecated parameter $rcid).

Also fixes a missing declaration in DifferenceEngine that is required for
extending this class.

Bug: 71916
Change-Id: I9da63c1ceb339bfeba7beddc712be51977b95f65
---
M docs/hooks.txt
M includes/content/ContentHandler.php
M includes/diff/DifferenceEngine.php
3 files changed, 21 insertions(+), 1 deletion(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/docs/hooks.txt b/docs/hooks.txt
index 7ec6ff5..5bf9ef2 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -989,6 +989,15 @@
 $old: the ?old= param value from the url
 $new: the ?new= param value from the url
 
+'GetDifferenceEngine': Called when getting a new difference engine interface 
object
+Return false for valid object in $differenceEngine or true for 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
+
 'DiffRevisionTools': Override or extend the revision tools available from the
 diff view, i.e. undo, etc.
 $newRev: Revision object of the "new" revision
diff --git a/includes/content/ContentHandler.php 
b/includes/content/ContentHandler.php
index ac41722..bcecefa 100644
--- a/includes/content/ContentHandler.php
+++ b/includes/content/ContentHandler.php
@@ -626,8 +626,15 @@
        public function createDifferenceEngine( IContextSource $context, $old = 
0, $new = 0,
                $rcid = 0, //FIXME: Deprecated, no longer used
                $refreshCache = false, $unhide = false ) {
-               $diffEngineClass = $this->getDiffEngineClass();
 
+               // hook: get difference engine
+               $differenceEngine = null;
+               if ( !wfRunHooks( 'GetDifferenceEngine',
+                       array( $context, $old, $new, $refreshCache, $unhide, 
&$differenceEngine )
+               ) ) {
+                       return $differenceEngine;
+               }
+               $diffEngineClass = $this->getDiffEngineClass();
                return new $diffEngineClass( $context, $old, $new, $rcid, 
$refreshCache, $unhide );
        }
 
diff --git a/includes/diff/DifferenceEngine.php 
b/includes/diff/DifferenceEngine.php
index dd5f3c7..ba9878f 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -94,6 +94,10 @@
 
        /** @var bool Show rev_deleted content if allowed */
        protected $unhide = false;
+
+       /** @var bool Refresh the diff cache */
+       protected $mRefreshCache = false;
+
        /**#@-*/
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/166143
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9da63c1ceb339bfeba7beddc712be51977b95f65
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Cacycle <cacycl...@gmail.com>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: BryanDavis <bda...@wikimedia.org>
Gerrit-Reviewer: Cacycle <cacycl...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: PleaseStand <pleasest...@live.com>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to