r24479 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24478‎ | r24479 | r24480 >
Date:08:15, 31 July 2007
Author:david
Status:old
Tags:
Comment:
leaveTrace works, has bugs.
Modified paths:
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtModel.php
@@ -268,15 +268,17 @@
269269 $this->articleId = $new_articleId;
270270 $this->articleNamespace = $new_articleNamespace;
271271 $this->articleTitle = $new_articleTitle;
 272+ $this->revisionNumber += 1;
272273 $this->commitRevision();
273274
274275 if($leave_trace) {
275 - // $this->leaveTrace();
 276+ $this->leaveTrace();
276277 }
277278 }
278279
279280 function leaveTrace() {
280281 /* Adapted from Title::moveToNewTitle. But now the new title exists on the old talkpage. */
 282+ $dbw =& wfGetDB( DB_MASTER );
281283
282284 $mwRedir = MagicWord::get( 'redirect' );
283285 $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $this->title()->getPrefixedText() . "]]\n";
@@ -285,30 +287,32 @@
286288 $newid = $redirectArticle->insertOn( $dbw );
287289 $redirectRevision = new Revision( array(
288290 'page' => $newid,
289 - 'comment' => $comment,
 291+ 'comment' => "page moved from here",
290292 'text' => $redirectText ) );
291293 $redirectRevision->insertOn( $dbw );
292294 $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
293 - $linkCache->clearLink( $this->getPrefixedDBkey() );
294295
295296 # Log the move
296297 $log = new LogPage( 'move' );
297 - $log->addEntry( 'move', $this, $reason, array( 1 => $nt->getPrefixedText()) );
 298+ $log->addEntry( 'move', $this->double->title(), "page moved from here", array( 1 => $this->title()->getPrefixedText()) );
298299
299300 # Purge caches as per article creation
300 - Article::onArticleCreate( $nt );
 301+ Article::onArticleCreate( $redirectArticle->getTitle() );
301302
302303 # Record the just-created redirect's linking to the page
303304 $dbw->insert( 'pagelinks',
304305 array(
305306 'pl_from' => $newid,
306 - 'pl_namespace' => $nt->getNamespace(),
307 - 'pl_title' => $nt->getDBkey() ),
308 - $fname );
 307+ 'pl_namespace' => $redirectArticle->getTitle()->getNamespace(),
 308+ 'pl_title' => $redirectArticle->getTitle()->getDBkey() ),
 309+ __METHOD__ );
309310
 311+ $thread = Threads::newThread( $redirectArticle, $this->double->article(), null,
 312+ Threads::TYPE_MOVED, $log);
 313+
310314 # Purge old title from squid
311315 # The new title, and links to the new title, are purged in Article::onArticleCreate()
312 - $this->purgeSquid();
 316+# $this-->purgeSquid();
313317 }
314318
315319
@@ -501,9 +505,14 @@
502506 /** Module of factory methods. */
503507 class Threads {
504508
 509+ const TYPE_NORMAL = 0;
 510+ const TYPE_MOVED = 1;
 511+
505512 static $loadedThreads = array();
506513
507 - static function newThread( $root, $article, $superthread = null ) {
 514+ static function newThread( $root, $article, $superthread = null,
 515+ $type = self::TYPE_NORMAL, $log = null ) {
 516+ /* TODO log is ignored. */
508517 $dbr =& wfGetDB( DB_MASTER );
509518
510519 if( $article->exists() ) {
@@ -515,7 +524,8 @@
516525
517526 $res = $dbr->insert('thread',
518527 array('thread_root' => $root->getID(),
519 - 'thread_timestamp' => wfTimestampNow()) + $aclause,
 528+ 'thread_timestamp' => wfTimestampNow(),
 529+ 'thread_type' => $type) + $aclause,
520530 __METHOD__);
521531
522532 $newid = $dbr->insertId();

Status & tagging log