r53818 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53817‎ | r53818 | r53819 >
Date:17:57, 27 July 2009
Author:werdna
Status:deferred
Tags:
Comment:
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.
Modified paths:
  • /trunk/extensions/LiquidThreads/LiquidThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/LqtFunctions.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Thread.php (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/Export.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1017,6 +1017,13 @@
10181018 $title: name of the page changed.
10191019 $text: new contents of the page.
10201020
 1021+'ModifyExportQuery': Modify the query used by the exporter.
 1022+$db: The database object to be queried.
 1023+&$tables: Tables in the query.
 1024+&$conds: Conditions in the query.
 1025+&$opts: Options for the query.
 1026+&$join_conds: Join conditions for the query.
 1027+
10211028 'MonoBookTemplateToolboxEnd': Called by Monobook skin after toolbox links have
10221029 been rendered (useful for adding more)
10231030 Note: this is only run for the Monobook skin. To add items to the toolbox
@@ -1634,5 +1641,19 @@
16351642 query pages to be updated with maintenance/updateSpecialPages.php
16361643 $query: $wgQueryPages itself
16371644
 1645+'XmlDumpWriterOpenPage': Called at the end of XmlDumpWriter::openPage, to allow extra
 1646+ metadata to be added.
 1647+$obj: The XmlDumpWriter object.
 1648+&$out: The output string.
 1649+$row: The database row for the page.
 1650+$title: The title of the page.
 1651+
 1652+'XmlDumpWriterWriteRevision': Called at the end of a revision in an XML dump, to add extra
 1653+ metadata.
 1654+$obj: The XmlDumpWriter object.
 1655+&$out: The text being output.
 1656+$row: The database row for the revision.
 1657+$text: The revision text.
 1658+
16381659 More hooks might be available but undocumented, you can execute
16391660 ./maintenance/findhooks.php to find hidden one.
Index: trunk/phase3/includes/Export.php
@@ -266,6 +266,9 @@
267267 if( $this->buffer == WikiExporter::STREAM ) {
268268 $prev = $this->db->bufferResults( false );
269269 }
 270+
 271+ wfRunHooks( 'ModifyExportQuery',
 272+ array( $this->db, &$tables, &$cond, &$opts, &$join ) );
270273
271274 # Do the query!
272275 $result = $this->db->select( $tables, '*', $cond, __METHOD__, $opts, $join );
@@ -445,6 +448,9 @@
446449 $out .= ' ' . Xml::element( 'restrictions', array(),
447450 strval( $row->page_restrictions ) ) . "\n";
448451 }
 452+
 453+ wfRunHooks( 'XmlDumpWriterOpenPage', array( $this, &$out, $row, $title ) );
 454+
449455 return $out;
450456 }
451457
@@ -503,6 +509,8 @@
504510 array( 'id' => $row->rev_text_id ),
505511 "" ) . "\n";
506512 }
 513+
 514+ wfRunHooks( 'XmlDumpWriterWriteRevision', array( &$this, &$out, $row, $text ) );
507515
508516 $out .= " </revision>\n";
509517
Index: trunk/extensions/LiquidThreads/LqtFunctions.php
@@ -138,3 +138,28 @@
139139 return true;
140140 }
141141
 142+function lqtDumpThreadData( $writer, &$out, $row, $title ) {
 143+ // Is it a thread
 144+ if ( $row->thread_id ) {
 145+ $thread = new Thread( $row );
 146+ $threadInfo = "\n";
 147+ $threadInfo .= Xml::element( 'ThreadSubject', null, $thread->subject() ) . "\n";
 148+ if ($thread->hasSuperThread()) {
 149+ $threadInfo .= Xml::element( 'ThreadParent', null, $thread->superThread()->id() ) . "\n";
 150+ }
 151+ $threadInfo .= Xml::element( 'ThreadAncestor', null, $thread->topmostThread()->id() ) . "\n";
 152+ $threadInfo .= Xml::element( 'ThreadPage', null, $thread->article()->getId() ) . "\n";
 153+
 154+ $out .= Xml::tags( 'DiscussionThreading', null, $threadInfo ) . "\n";
 155+ }
 156+
 157+ return true;
 158+}
 159+
 160+function lqtModifyExportQuery( $db, &$tables, &$cond, &$opts, &$join ) {
 161+ $tables[] = 'thread';
 162+
 163+ $join['thread'] = array( 'left join', array( 'thread_root=page_id' ) );
 164+
 165+ return true;
 166+}
Index: trunk/extensions/LiquidThreads/LiquidThreads.php
@@ -59,6 +59,8 @@
6060 $wgHooks['GetPreferences'][] = 'lqtGetPreferences';
6161 $wgHooks['ArticleEditUpdateNewTalk'][] = 'lqtUpdateNewtalkOnEdit';
6262 $wgHooks['LanguageGetMagic'][] = 'LiquidThreadsMagicWords::getMagicWords';
 63+$wgHooks['XmlDumpWriterOpenPage'][] = 'lqtDumpThreadData';
 64+$wgHooks['ModifyExportQuery'][] = 'lqtModifyExportQuery';
6365
6466 // Deletion
6567 $wgHooks['ArticleDeleteComplete'][] = 'LqtDeletionController::onArticleDeleteComplete';
Index: trunk/extensions/LiquidThreads/classes/Thread.php
@@ -297,7 +297,7 @@
298298
299299
300300
301 - function __construct( $line, $children ) {
 301+ function __construct( $line, $unused = null ) {
302302 /* SCHEMA changes must be reflected here. */
303303
304304 $dataLoads = array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r57747Fix PHP Notice: Undefined variable: text in /var/www/w/includes/Export.php on...raymond07:08, 15 October 2009

Status & tagging log