From 6e5dd5459a1b231c6e4b45ed1e60f86678b59dad Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Mon, 27 Jul 2009 17:57:51 +0000 Subject: [PATCH] Incremental enabling changes to allow searching of LiquidThreads by page and by thread: * Add three new hooks, XmlDumpWriterOpenPage, ModifyExportQuery and XmlDumpWriterWriteRevision, to WikiExporter class. * Hook two of these events to add a DiscussionThreading section to XML dumps, containing the parent, ancestor and discussion page to which a post belongs, if it is indeed a LiquidThreads post (as determined by joining on the thread table). * Deprecate old calling style for Thread constructor, the $children parameter has been unused for yonks. --- docs/hooks.txt | 21 +++++++++++++++++++++ includes/Export.php | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/docs/hooks.txt b/docs/hooks.txt index ece9e28e58..65048b5762 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1017,6 +1017,13 @@ Useful for updating caches. $title: name of the page changed. $text: new contents of the page. +'ModifyExportQuery': Modify the query used by the exporter. +$db: The database object to be queried. +&$tables: Tables in the query. +&$conds: Conditions in the query. +&$opts: Options for the query. +&$join_conds: Join conditions for the query. + 'MonoBookTemplateToolboxEnd': Called by Monobook skin after toolbox links have been rendered (useful for adding more) Note: this is only run for the Monobook skin. To add items to the toolbox @@ -1634,5 +1641,19 @@ One, and only one hook should set this, and return false. query pages to be updated with maintenance/updateSpecialPages.php $query: $wgQueryPages itself +'XmlDumpWriterOpenPage': Called at the end of XmlDumpWriter::openPage, to allow extra + metadata to be added. +$obj: The XmlDumpWriter object. +&$out: The output string. +$row: The database row for the page. +$title: The title of the page. + +'XmlDumpWriterWriteRevision': Called at the end of a revision in an XML dump, to add extra + metadata. +$obj: The XmlDumpWriter object. +&$out: The text being output. +$row: The database row for the revision. +$text: The revision text. + More hooks might be available but undocumented, you can execute ./maintenance/findhooks.php to find hidden one. diff --git a/includes/Export.php b/includes/Export.php index 3372cece4a..f05b660ec4 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -266,6 +266,9 @@ class WikiExporter { if( $this->buffer == WikiExporter::STREAM ) { $prev = $this->db->bufferResults( false ); } + + wfRunHooks( 'ModifyExportQuery', + array( $this->db, &$tables, &$cond, &$opts, &$join ) ); # Do the query! $result = $this->db->select( $tables, '*', $cond, __METHOD__, $opts, $join ); @@ -445,6 +448,9 @@ class XmlDumpWriter { $out .= ' ' . Xml::element( 'restrictions', array(), strval( $row->page_restrictions ) ) . "\n"; } + + wfRunHooks( 'XmlDumpWriterOpenPage', array( $this, &$out, $row, $title ) ); + return $out; } @@ -503,6 +509,8 @@ class XmlDumpWriter { array( 'id' => $row->rev_text_id ), "" ) . "\n"; } + + wfRunHooks( 'XmlDumpWriterWriteRevision', array( &$this, &$out, $row, $text ) ); $out .= " \n"; -- 2.20.1