Jackmcbarn has uploaded a new change for review. https://gerrit.wikimedia.org/r/160570
Change subject: Add RevisionFromTitle hook ...................................................................... Add RevisionFromTitle hook Whenever Revision::newFromTitle or Revision::loadFromTitle is called, and no specific revision ID is given, call the new RevisionFromTitle hook to allow extensions to return their own revision in place of the actual one. Bug: 70495 Change-Id: I521f1f68ad819cf0f37e63240806f10c1cceef9c --- M docs/hooks.txt M includes/Revision.php 2 files changed, 14 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/70/160570/1 diff --git a/docs/hooks.txt b/docs/hooks.txt index 9ac2271..9a1fb2e 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2179,6 +2179,12 @@ For QUnit framework, the mediawiki.tests.qunit.testrunner dependency will be added to any module. +'RevisionFromTitle': Called when the latest revision of a title is being loaded +from a Title object. +$title: The title of the revision being fetched. +&$id: The revision ID to fetch. Always 0 when called, but can be changed. +&$revision: If the hook returns false, this is returned as the Revision object. + 'RevisionInsertComplete': Called after a revision is inserted into the database. &$revision: the Revision $data: the data stored in old_text. The meaning depends on $flags: if external diff --git a/includes/Revision.php b/includes/Revision.php index 28a825d..82729a9 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -114,6 +114,10 @@ * @return Revision|null */ public static function newFromTitle( $title, $id = 0, $flags = 0 ) { + $hookOutput = null; + if ( !$id && !wfRunHooks( 'RevisionFromTitle', array( &$title, &$id, &$hookOutput ) ) ) { + return $hookOutput; + } $conds = array( 'page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey() @@ -260,6 +264,10 @@ * @return Revision|null */ public static function loadFromTitle( $db, $title, $id = 0 ) { + $hookOutput = null; + if ( !$id && !wfRunHooks( 'RevisionFromTitle', array( &$title, &$id, &$hookOutput ) ) ) { + return $hookOutput; + } if ( $id ) { $matchId = intval( $id ); } else { -- To view, visit https://gerrit.wikimedia.org/r/160570 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I521f1f68ad819cf0f37e63240806f10c1cceef9c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jackmcbarn <jackmcb...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits