From: Kunal Mehta Date: Fri, 16 Sep 2016 00:40:03 +0000 (-0700) Subject: Add 'WikiPageFactory' hook X-Git-Tag: 1.31.0-rc.0~5110^2 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=4283bdfcfcdeb91bb03a22f542d497704edae4d3;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/docs/hooks.txt b/docs/hooks.txt index 3b3741a0da..562d7b4b2f 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -3791,6 +3791,10 @@ $content: the Content to generate updates for (or null, if the Content could not 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 c791587781..3dc41fba58 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -121,6 +121,11 @@ class WikiPage implements Page, IDBAccessObject { 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 );