jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/322039 )

Change subject: A few more hooks in DifferenceEngine
......................................................................


A few more hooks in DifferenceEngine

For mucking with the class member variable mNewContent and optionally
allowing the suppression of the "missing revision" message when revision
data is not found for a requested revision.

Originally implemented as the "GetUserMessagesDiffCurrent" hook (yes,
these three separate hooks in three separate places were essentially the
same) by Wikia for their SiteWideMessages extension.

Change-Id: Ie0c175af2af418d4ed3de28c94df918115312da3
---
M docs/hooks.txt
M includes/diff/DifferenceEngine.php
2 files changed, 24 insertions(+), 2 deletions(-)

Approvals:
  Reedy: Looks good to me, approved
  Florianschmidtwelzow: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/docs/hooks.txt b/docs/hooks.txt
index 7efd5d2..1ecc1f8 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -1190,6 +1190,18 @@
 $row: the DB row for this line
 &$classes: the classes to add to the surrounding <li>
 
+'DifferenceEngineAfterLoadNewText': called in DifferenceEngine::loadNewText()
+after the new revision's content has been loaded into the class member variable
+$differenceEngine->mNewContent but before returning true from this function.
+$differenceEngine: DifferenceEngine object
+
+'DifferenceEngineLoadTextAfterNewContentIsLoaded': called in
+DifferenceEngine::loadText() after the new revision's content has been loaded
+into the class member variable $differenceEngine->mNewContent but before
+checking if the variable's value is null.
+This hook can be used to inject content into said class member variable.
+$differenceEngine: DifferenceEngine object
+
 'DifferenceEngineMarkPatrolledLink': Allows extensions to change the "mark as 
patrolled" link
 which is shown both on the diff header as well as on the bottom of a page, 
usually
 wrapped in a span element which has class="patrollink".
@@ -1268,6 +1280,12 @@
 object into the diff view
 $out: OutputPage object
 
+'DifferenceEngineShowDiffPageMaybeShowMissingRevision': called in
+DifferenceEngine::showDiffPage() when revision data cannot be loaded.
+Return false in order to prevent displaying the missing revision message
+(i.e. to prevent DifferenceEngine::showMissingRevision() from being called).
+$differenceEngine: DifferenceEngine object
+
 '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/diff/DifferenceEngine.php 
b/includes/diff/DifferenceEngine.php
index bd65fb4..5e40f43 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -247,8 +247,9 @@
                Hooks::run( 'DifferenceEngineShowDiffPage', [ $out ] );
 
                if ( !$this->loadRevisionData() ) {
-                       $this->showMissingRevision();
-
+                       if ( Hooks::run( 
'DifferenceEngineShowDiffPageMaybeShowMissingRevision', [ $this ] ) ) {
+                               $this->showMissingRevision();
+                       }
                        return;
                }
 
@@ -1369,6 +1370,7 @@
 
                if ( $this->mNewRev ) {
                        $this->mNewContent = $this->mNewRev->getContent( 
Revision::FOR_THIS_USER, $this->getUser() );
+                       Hooks::run( 
'DifferenceEngineLoadTextAfterNewContentIsLoaded', [ $this ] );
                        if ( $this->mNewContent === null ) {
                                return false;
                        }
@@ -1395,6 +1397,8 @@
 
                $this->mNewContent = $this->mNewRev->getContent( 
Revision::FOR_THIS_USER, $this->getUser() );
 
+               Hooks::run( 'DifferenceEngineAfterLoadNewText', [ $this ] );
+
                return true;
        }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie0c175af2af418d4ed3de28c94df918115312da3
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Dereckson <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to