[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add 'WikiPageFactory' hook
jenkins-bot has submitted this change and it was merged. Change subject: Add 'WikiPageFactory' hook .. Add 'WikiPageFactory' hook This allows extension to consistently use their WikiPage subclasses. Currently the only way a subclass would be used is if Article::newPage() was called. Change-Id: I74cce5f9627c4bc4b92502aff74beb2daeb78d17 --- M docs/hooks.txt M includes/page/WikiPage.php 2 files changed, 9 insertions(+), 0 deletions(-) Approvals: Tim Starling: Looks good to me, approved jenkins-bot: Verified diff --git a/docs/hooks.txt b/docs/hooks.txt index 3b3741a..562d7b4 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -3791,6 +3791,10 @@ due to an error) &$updates: the array of DataUpdate objects. Hook function may want to add to it. +'WikiPageFactory': Override WikiPage class used for a title +$title: Title of the page +&$page: Variable to set the created WikiPage to. + 'XmlDumpWriterOpenPage': Called at the end of XmlDumpWriter::openPage, to allow extra metadata to be added. $obj: The XmlDumpWriter object. diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index c791587..3dc41fb 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -121,6 +121,11 @@ throw new MWException( "Invalid or virtual namespace $ns given." ); } + $page = null; + if ( !Hooks::run( 'WikiPageFactory', [ $title, &$page ] ) ) { + return $page; + } + switch ( $ns ) { case NS_FILE: $page = new WikiFilePage( $title ); -- To view, visit https://gerrit.wikimedia.org/r/311073 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I74cce5f9627c4bc4b92502aff74beb2daeb78d17 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Legoktm Gerrit-Reviewer: Tim Starling Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add 'WikiPageFactory' hook
Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/311073 Change subject: Add 'WikiPageFactory' hook .. Add 'WikiPageFactory' hook This allows extension to consistently use their WikiPage subclasses. Currently the only way a subclass would be used is if Article::newPage() was called. Change-Id: I74cce5f9627c4bc4b92502aff74beb2daeb78d17 --- M docs/hooks.txt M includes/page/WikiPage.php 2 files changed, 9 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/73/311073/1 diff --git a/docs/hooks.txt b/docs/hooks.txt index ae0770b..91e9409 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -3743,6 +3743,10 @@ due to an error) &$updates: the array of DataUpdate objects. Hook function may want to add to it. +'WikiPageFactory': Override WikiPage class used for a title +$title: Title of the page +&$page: Variable to set the created WikiPage to. + 'XmlDumpWriterOpenPage': Called at the end of XmlDumpWriter::openPage, to allow extra metadata to be added. $obj: The XmlDumpWriter object. diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 6c0c4a8..d997566 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -121,6 +121,11 @@ throw new MWException( "Invalid or virtual namespace $ns given." ); } + $page = null; + if ( !Hooks::run( 'WikiPageFactory', [ $title, &$page ] ) ) { + return $page; + } + switch ( $ns ) { case NS_FILE: $page = new WikiFilePage( $title ); -- To view, visit https://gerrit.wikimedia.org/r/311073 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I74cce5f9627c4bc4b92502aff74beb2daeb78d17 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Legoktm ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits