aboutsummaryrefslogtreecommitdiffstats
path: root/includes/diff/Hook
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2020-03-04 09:50:34 +1100
committerTim Starling <tstarling@wikimedia.org>2020-04-20 13:31:05 +1000
commitf5aaf75ad15813bfeb93dcb4e5fbaaa52b23c7fe (patch)
tree1598e7d4c3d1e6d2914de4ae61ca01b2cbd3f470 /includes/diff/Hook
parentcedee2b62058a3834c2d883eeeecc2707eed9c93 (diff)
downloadmediawikicore-f5aaf75ad15813bfeb93dcb4e5fbaaa52b23c7fe.tar.gz
mediawikicore-f5aaf75ad15813bfeb93dcb4e5fbaaa52b23c7fe.zip
Automatically generated hook interfaces
Add hook interfaces which were generated by a script which parses hooks.txt and identifies caller namespaces and directories. Hook interfaces are mostly placed in a Hook/ subdirectory relative to the caller location. When there are callers in multiple directories, a "primary" caller was manually selected. The exceptions to this are: * The source root, maintenance and tests, which use includes/Hook. Test hooks need to be autoloadable in a non-test request so that implementing test interfaces in a generic handler will not fail. * resources uses includes/resourceloader/Hook * The following third-level subdirectories had their hooks placed in the parent ../Hook: * includes/filerepo/file * includes/search/searchwidgets * includes/specials/forms * includes/specials/helpers * includes/specials/pagers Parameters marked as legacy references in hooks.txt are passed by value in the interfaces. Bug: T240307 Change-Id: I6efe2e7dd1f0c6a3d0f4d100a4c34e41f8428720
Diffstat (limited to 'includes/diff/Hook')
-rw-r--r--includes/diff/Hook/AbortDiffCacheHook.php19
-rw-r--r--includes/diff/Hook/ArticleContentOnDiffHook.php21
-rw-r--r--includes/diff/Hook/DiffRevisionToolsHook.php23
-rw-r--r--includes/diff/Hook/DiffViewHeaderHook.php21
-rw-r--r--includes/diff/Hook/DifferenceEngineAfterLoadNewTextHook.php21
-rw-r--r--includes/diff/Hook/DifferenceEngineLoadTextAfterNewContentIsLoadedHook.php25
-rw-r--r--includes/diff/Hook/DifferenceEngineMarkPatrolledLinkHook.php25
-rw-r--r--includes/diff/Hook/DifferenceEngineMarkPatrolledRCIDHook.php27
-rw-r--r--includes/diff/Hook/DifferenceEngineNewHeaderHook.php40
-rw-r--r--includes/diff/Hook/DifferenceEngineOldHeaderHook.php35
-rw-r--r--includes/diff/Hook/DifferenceEngineOldHeaderNoOldRevHook.php20
-rw-r--r--includes/diff/Hook/DifferenceEngineRenderRevisionAddParserOutputHook.php26
-rw-r--r--includes/diff/Hook/DifferenceEngineRenderRevisionShowFinalPatrolLinkHook.php20
-rw-r--r--includes/diff/Hook/DifferenceEngineShowDiffHook.php20
-rw-r--r--includes/diff/Hook/DifferenceEngineShowDiffPageHook.php20
-rw-r--r--includes/diff/Hook/DifferenceEngineShowDiffPageMaybeShowMissingRevisionHook.php24
-rw-r--r--includes/diff/Hook/DifferenceEngineShowEmptyOldContentHook.php21
-rw-r--r--includes/diff/Hook/NewDifferenceEngineHook.php23
18 files changed, 431 insertions, 0 deletions
diff --git a/includes/diff/Hook/AbortDiffCacheHook.php b/includes/diff/Hook/AbortDiffCacheHook.php
new file mode 100644
index 000000000000..8bb28e84c815
--- /dev/null
+++ b/includes/diff/Hook/AbortDiffCacheHook.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface AbortDiffCacheHook {
+ /**
+ * Can be used to cancel the caching of a diff.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $diffEngine DifferenceEngine object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onAbortDiffCache( $diffEngine );
+}
diff --git a/includes/diff/Hook/ArticleContentOnDiffHook.php b/includes/diff/Hook/ArticleContentOnDiffHook.php
new file mode 100644
index 000000000000..7fe92877aaf2
--- /dev/null
+++ b/includes/diff/Hook/ArticleContentOnDiffHook.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface ArticleContentOnDiffHook {
+ /**
+ * Before showing the article content below a diff. Use
+ * this to change the content in this area or how it is loaded.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $diffEngine the DifferenceEngine
+ * @param ?mixed $output the OutputPage object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onArticleContentOnDiff( $diffEngine, $output );
+}
diff --git a/includes/diff/Hook/DiffRevisionToolsHook.php b/includes/diff/Hook/DiffRevisionToolsHook.php
new file mode 100644
index 000000000000..dc468bdf4895
--- /dev/null
+++ b/includes/diff/Hook/DiffRevisionToolsHook.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DiffRevisionToolsHook {
+ /**
+ * Override or extend the revision tools available from the
+ * diff view, i.e. undo, etc.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $newRev Revision object of the "new" revision
+ * @param ?mixed &$links Array of HTML links
+ * @param ?mixed $oldRev Revision object of the "old" revision (may be null)
+ * @param ?mixed $user Current user object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDiffRevisionTools( $newRev, &$links, $oldRev, $user );
+}
diff --git a/includes/diff/Hook/DiffViewHeaderHook.php b/includes/diff/Hook/DiffViewHeaderHook.php
new file mode 100644
index 000000000000..580a6106f120
--- /dev/null
+++ b/includes/diff/Hook/DiffViewHeaderHook.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DiffViewHeaderHook {
+ /**
+ * Called before diff display
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $diff DifferenceEngine object that's calling
+ * @param ?mixed $oldRev Revision object of the "old" revision (may be null/invalid)
+ * @param ?mixed $newRev Revision object of the "new" revision
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDiffViewHeader( $diff, $oldRev, $newRev );
+}
diff --git a/includes/diff/Hook/DifferenceEngineAfterLoadNewTextHook.php b/includes/diff/Hook/DifferenceEngineAfterLoadNewTextHook.php
new file mode 100644
index 000000000000..e79218cfe970
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineAfterLoadNewTextHook.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineAfterLoadNewTextHook {
+ /**
+ * 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.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $differenceEngine DifferenceEngine object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineAfterLoadNewText( $differenceEngine );
+}
diff --git a/includes/diff/Hook/DifferenceEngineLoadTextAfterNewContentIsLoadedHook.php b/includes/diff/Hook/DifferenceEngineLoadTextAfterNewContentIsLoadedHook.php
new file mode 100644
index 000000000000..051a2f49fe1b
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineLoadTextAfterNewContentIsLoadedHook.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineLoadTextAfterNewContentIsLoadedHook {
+ /**
+ * 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.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $differenceEngine DifferenceEngine object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineLoadTextAfterNewContentIsLoaded(
+ $differenceEngine
+ );
+}
diff --git a/includes/diff/Hook/DifferenceEngineMarkPatrolledLinkHook.php b/includes/diff/Hook/DifferenceEngineMarkPatrolledLinkHook.php
new file mode 100644
index 000000000000..296db56cf6c7
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineMarkPatrolledLinkHook.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineMarkPatrolledLinkHook {
+ /**
+ * 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".
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $differenceEngine DifferenceEngine object
+ * @param ?mixed &$markAsPatrolledLink The "mark as patrolled" link HTML (string)
+ * @param ?mixed $rcid Recent change ID (rc_id) for this change (int)
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineMarkPatrolledLink( $differenceEngine,
+ &$markAsPatrolledLink, $rcid
+ );
+}
diff --git a/includes/diff/Hook/DifferenceEngineMarkPatrolledRCIDHook.php b/includes/diff/Hook/DifferenceEngineMarkPatrolledRCIDHook.php
new file mode 100644
index 000000000000..1e828762fa10
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineMarkPatrolledRCIDHook.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineMarkPatrolledRCIDHook {
+ /**
+ * Allows extensions to possibly change the
+ * rcid parameter. For example the rcid might be set to zero due to the user being
+ * the same as the performer of the change but an extension might still want to
+ * show it under certain conditions.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed &$rcid rc_id (int) of the change or 0
+ * @param ?mixed $differenceEngine DifferenceEngine object
+ * @param ?mixed $change RecentChange object
+ * @param ?mixed $user User object representing the current user
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineMarkPatrolledRCID( &$rcid, $differenceEngine,
+ $change, $user
+ );
+}
diff --git a/includes/diff/Hook/DifferenceEngineNewHeaderHook.php b/includes/diff/Hook/DifferenceEngineNewHeaderHook.php
new file mode 100644
index 000000000000..68ed78aea706
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineNewHeaderHook.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineNewHeaderHook {
+ /**
+ * Allows extensions to change the $newHeader
+ * variable, which contains information about the new revision, such as the
+ * revision's author, whether the revision was marked as a minor edit or not, etc.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $differenceEngine DifferenceEngine object
+ * @param ?mixed &$newHeader The string containing the various #mw-diff-otitle[1-5] divs, which
+ * include things like revision author info, revision comment, RevisionDelete
+ * link and more
+ * @param ?mixed $formattedRevisionTools Array containing revision tools, some of which may have
+ * been injected with the DiffRevisionTools hook
+ * @param ?mixed $nextlink String containing the link to the next revision (if any); also
+ * included in $newHeader
+ * @param ?mixed $rollback Rollback link (string) to roll this revision back to the previous
+ * one, if any
+ * @param ?mixed $newminor String indicating if the new revision was marked as a minor edit
+ * @param ?mixed $diffOnly Boolean parameter passed to DifferenceEngine#showDiffPage, indicating
+ * whether we should show just the diff; passed in as a query string parameter to
+ * the various URLs constructed here (i.e. $nextlink)
+ * @param ?mixed $rdel RevisionDelete link for the new revision, if the current user is allowed
+ * to use the RevisionDelete feature
+ * @param ?mixed $unhide Boolean parameter indicating whether to show RevisionDeleted revisions
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineNewHeader( $differenceEngine, &$newHeader,
+ $formattedRevisionTools, $nextlink, $rollback, $newminor, $diffOnly, $rdel,
+ $unhide
+ );
+}
diff --git a/includes/diff/Hook/DifferenceEngineOldHeaderHook.php b/includes/diff/Hook/DifferenceEngineOldHeaderHook.php
new file mode 100644
index 000000000000..d00e8e1ccd66
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineOldHeaderHook.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineOldHeaderHook {
+ /**
+ * Allows extensions to change the $oldHeader
+ * variable, which contains information about the old revision, such as the
+ * revision's author, whether the revision was marked as a minor edit or not, etc.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $differenceEngine DifferenceEngine object
+ * @param ?mixed &$oldHeader The string containing the various #mw-diff-otitle[1-5] divs, which
+ * include things like revision author info, revision comment, RevisionDelete
+ * link and more
+ * @param ?mixed $prevlink String containing the link to the previous revision (if any); also
+ * included in $oldHeader
+ * @param ?mixed $oldminor String indicating if the old revision was marked as a minor edit
+ * @param ?mixed $diffOnly Boolean parameter passed to DifferenceEngine#showDiffPage, indicating
+ * whether we should show just the diff; passed in as a query string parameter to
+ * the various URLs constructed here (i.e. $prevlink)
+ * @param ?mixed $ldel RevisionDelete link for the old revision, if the current user is allowed
+ * to use the RevisionDelete feature
+ * @param ?mixed $unhide Boolean parameter indicating whether to show RevisionDeleted revisions
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineOldHeader( $differenceEngine, &$oldHeader,
+ $prevlink, $oldminor, $diffOnly, $ldel, $unhide
+ );
+}
diff --git a/includes/diff/Hook/DifferenceEngineOldHeaderNoOldRevHook.php b/includes/diff/Hook/DifferenceEngineOldHeaderNoOldRevHook.php
new file mode 100644
index 000000000000..8afe2533668d
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineOldHeaderNoOldRevHook.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineOldHeaderNoOldRevHook {
+ /**
+ * Change the $oldHeader variable in cases
+ * when there is no old revision
+ *
+ * @since 1.35
+ *
+ * @param ?mixed &$oldHeader empty string by default
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineOldHeaderNoOldRev( &$oldHeader );
+}
diff --git a/includes/diff/Hook/DifferenceEngineRenderRevisionAddParserOutputHook.php b/includes/diff/Hook/DifferenceEngineRenderRevisionAddParserOutputHook.php
new file mode 100644
index 000000000000..baae38a3cc88
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineRenderRevisionAddParserOutputHook.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineRenderRevisionAddParserOutputHook {
+ /**
+ * Allows extensions to change the
+ * parser output. Return false to not add parser output via OutputPage's
+ * addParserOutput method.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $differenceEngine DifferenceEngine object
+ * @param ?mixed $out OutputPage object
+ * @param ?mixed $parserOutput ParserOutput object
+ * @param ?mixed $wikiPage WikiPage object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineRenderRevisionAddParserOutput(
+ $differenceEngine, $out, $parserOutput, $wikiPage
+ );
+}
diff --git a/includes/diff/Hook/DifferenceEngineRenderRevisionShowFinalPatrolLinkHook.php b/includes/diff/Hook/DifferenceEngineRenderRevisionShowFinalPatrolLinkHook.php
new file mode 100644
index 000000000000..0b56979d0dbd
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineRenderRevisionShowFinalPatrolLinkHook.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineRenderRevisionShowFinalPatrolLinkHook {
+ /**
+ * An extension can hook into
+ * this hook point and return false to not show the final "mark as patrolled" link
+ * on the bottom of a page.
+ * This hook has no arguments.
+ *
+ * @since 1.35
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineRenderRevisionShowFinalPatrolLink();
+}
diff --git a/includes/diff/Hook/DifferenceEngineShowDiffHook.php b/includes/diff/Hook/DifferenceEngineShowDiffHook.php
new file mode 100644
index 000000000000..500be4e80f5d
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineShowDiffHook.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineShowDiffHook {
+ /**
+ * Allows extensions to affect the diff text which
+ * eventually gets sent to the OutputPage object.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $differenceEngine DifferenceEngine object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineShowDiff( $differenceEngine );
+}
diff --git a/includes/diff/Hook/DifferenceEngineShowDiffPageHook.php b/includes/diff/Hook/DifferenceEngineShowDiffPageHook.php
new file mode 100644
index 000000000000..7a6127b94b56
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineShowDiffPageHook.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineShowDiffPageHook {
+ /**
+ * Add additional output via the available
+ * OutputPage object into the diff view
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $out OutputPage object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineShowDiffPage( $out );
+}
diff --git a/includes/diff/Hook/DifferenceEngineShowDiffPageMaybeShowMissingRevisionHook.php b/includes/diff/Hook/DifferenceEngineShowDiffPageMaybeShowMissingRevisionHook.php
new file mode 100644
index 000000000000..0ccc3576437e
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineShowDiffPageMaybeShowMissingRevisionHook.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineShowDiffPageMaybeShowMissingRevisionHook {
+ /**
+ * 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).
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $differenceEngine DifferenceEngine object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineShowDiffPageMaybeShowMissingRevision(
+ $differenceEngine
+ );
+}
diff --git a/includes/diff/Hook/DifferenceEngineShowEmptyOldContentHook.php b/includes/diff/Hook/DifferenceEngineShowEmptyOldContentHook.php
new file mode 100644
index 000000000000..f9084ba1c98d
--- /dev/null
+++ b/includes/diff/Hook/DifferenceEngineShowEmptyOldContentHook.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface DifferenceEngineShowEmptyOldContentHook {
+ /**
+ * Allows extensions to change the diff
+ * table body (without header) in cases when there is no old revision or the old
+ * and new revisions are identical.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $differenceEngine DifferenceEngine object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onDifferenceEngineShowEmptyOldContent( $differenceEngine );
+}
diff --git a/includes/diff/Hook/NewDifferenceEngineHook.php b/includes/diff/Hook/NewDifferenceEngineHook.php
new file mode 100644
index 000000000000..111002833a22
--- /dev/null
+++ b/includes/diff/Hook/NewDifferenceEngineHook.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace MediaWiki\Diff\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface NewDifferenceEngineHook {
+ /**
+ * Called when a new DifferenceEngine object is made
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $title the diff page title (nullable)
+ * @param ?mixed &$oldId the actual old Id to use in the diff
+ * @param ?mixed &$newId the actual new Id to use in the diff (0 means current)
+ * @param ?mixed $old the ?old= param value from the url
+ * @param ?mixed $new the ?new= param value from the url
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onNewDifferenceEngine( $title, &$oldId, &$newId, $old, $new );
+}