r51021 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51020‎ | r51021 | r51022 >
Date:14:17, 26 May 2009
Author:werdna
Status:deferred
Tags:
Comment:
* Fix bizarre design choice in which the name of the SUBJECT page was stored in the thread table.
* Allow talkpage Lqt to be turned on and off for testing.
* Allow Lqt to be turned on for particular pages.
* Fix inconsistency between storage and interpretation of topmost threads.
Modified paths:
  • /trunk/extensions/LiquidThreads/LiquidThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/LqtDispatch.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/LqtThread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/LqtThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/SpecialDeleteThread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/SpecialMoveThread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/TalkpageArchiveView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/TalkpageView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/LiquidThreads.php
@@ -87,3 +87,10 @@
8888
8989 /* Number of days a thread needs to be inactive to be considered for summarizing and archival */
9090 $wgLqtThreadArchiveInactiveDays = 5;
 91+
 92+/* Allows activation of LiquidThreads on individual pages */
 93+$wgLqtPages = array();
 94+
 95+/* Allows switching LiquidThreads off for regular talk pages
 96+ (intended for testing and transition) */
 97+$wgLqtTalkPages = true;
Index: trunk/extensions/LiquidThreads/classes/LqtThreads.php
@@ -115,7 +115,7 @@
116116 * will show up blue instead of red. For use upon new thread creation.
117117 */
118118 protected static function createTalkpageIfNeeded( $subjectPage ) {
119 - $talkpage_t = $subjectPage->getTitle()->getTalkpage();
 119+ $talkpage_t = $subjectPage->getTitle();
120120 $talkpage = new Article( $talkpage_t );
121121 if ( ! $talkpage->exists() ) {
122122 try {
Index: trunk/extensions/LiquidThreads/classes/LqtDispatch.php
@@ -18,7 +18,7 @@
1919 static function talkpageMain( &$output, &$talk_article, &$title, &$user, &$request ) {
2020 // We are given a talkpage article and title. Find the associated
2121 // non-talk article and pass that to the view.
22 - $article = new Article( $title->getSubjectPage() );
 22+ $article = new Article( $title );
2323
2424 if ( $title->getSubjectPage()->getNamespace() == NS_LQT_THREAD ) {
2525 // Threads don't have talk pages; redirect to the thread page.
@@ -89,7 +89,12 @@
9090 * as needed and return True. If it's a normal, non-liquid page, return false.
9191 */
9292 static function tryPage( $output, $article, $title, $user, $request ) {
93 - if ( $title->isTalkPage() ) {
 93+ global $wgLqtPages, $wgLqtTalkPages;
 94+
 95+ $isTalkPage = ($title->isTalkPage() && $wgLqtTalkPages) ||
 96+ in_array( $title->getPrefixedText(), $wgLqtPages );
 97+
 98+ if ( $isTalkPage ) {
9499 return self::talkpageMain ( $output, $article, $title, $user, $request );
95100 } else if ( $title->getNamespace() == NS_LQT_THREAD ) {
96101 return self::threadPermalinkMain( $output, $article, $title, $user, $request );
@@ -121,7 +126,7 @@
122127 return true;
123128
124129 // Talkpages without headers -- check existance of threads.
125 - $article = new Article( $nt->getSubjectPage() );
 130+ $article = new Article( $nt );
126131 $threads = Threads::where( Threads::articleClause( $article ), "LIMIT 1" );
127132 if ( count( $threads ) == 0 ) {
128133 // We want it to look like a broken link, but not have action=edit, since that
@@ -152,7 +157,7 @@
153158 // It's a talkpage without a header. Get rid of action=edit always,
154159 // color as apropriate.
155160 $query = "";
156 - $article = new Article( $title->getSubjectPage() );
 161+ $article = new Article( $title );
157162 $threads = Threads::where( Threads::articleClause( $article ), "LIMIT 1" );
158163 if ( count( $threads ) != 0 ) {
159164 $i = array_search( 'new', $classes ); if ( $i !== false ) {
@@ -210,7 +215,7 @@
211216 array(), array(), array( 'known' ) );
212217
213218 $talkpage_link = $changeslist->skin->link(
214 - $thread->article()->getTitle()->getTalkPage(),
 219+ $thread->article()->getTitle(),
215220 null,
216221 array(), array(), array( 'known' ) );
217222
Index: trunk/extensions/LiquidThreads/classes/LqtThread.php
@@ -339,14 +339,15 @@
340340 // if we always use Threads::withId instead of returning $this,
341341 // the historical revision is not incremented and we get a
342342 // duplicate key.
343 - if ( $this->ancestorId == $this->id )
 343+ if ( $this->isTopmostThread() ) {
344344 return $this;
345 - else
 345+ } else {
346346 return Threads::withId( $this->ancestorId );
 347+ }
347348 }
348349
349350 function isTopmostThread() {
350 - return $this->ancestorId == $this->id;
 351+ return $this->ancestorId == $this->id || intval($this->ancestorId) === 0;
351352 }
352353
353354 function setArticle( $a ) {
@@ -563,7 +564,7 @@
564565 if ( $this->hasSuperthread() ) {
565566 $parent_restrictions = $this->superthread()->root()->getTitle()->getRestrictions( $action );
566567 } else {
567 - $parent_restrictions = $this->article()->getTitle()->getTalkPage()->getRestrictions( $action );
 568+ $parent_restrictions = $this->article()->getTitle()->getRestrictions( $action );
568569 }
569570
570571 // TODO this may not be the same as asking "are the parent restrictions more restrictive than
Index: trunk/extensions/LiquidThreads/pages/SpecialDeleteThread.php
@@ -25,7 +25,7 @@
2626
2727 $form_action = $this->title->getLocalURL() . '/' . $this->thread->title()->getPrefixedURL();
2828 $thread_name = $this->thread->title()->getPrefixedText();
29 - $article_name = $this->thread->article()->getTitle()->getTalkPage()->getPrefixedText();
 29+ $article_name = $this->thread->article()->getTitle()->getPrefixedText();
3030
3131 $deleting = $this->thread->type() != Threads::TYPE_DELETED;
3232
@@ -92,7 +92,7 @@
9393 function showSuccessMessage( $is_deleted_already ) {
9494 wfLoadExtensionMessages( 'LiquidThreads' );
9595 // TODO talkpageUrl should accept threads, and look up their talk pages.
96 - $talkpage_url = LqtView::talkpageUrl( $this->thread->article()->getTitle()->getTalkpage() );
 96+ $talkpage_url = LqtView::talkpageUrl( $this->thread->article()->getTitle() );
9797 $message = $is_deleted_already ? wfMsg( 'lqt_delete_undeleted' ) : wfMsg( 'lqt_delete_deleted' );
9898 $message .= wfMsg( 'word-separator' );
9999 $message .= wfMsg( 'lqt_delete_return', '<a href="' . $talkpage_url . '">' . wfMsg( 'lqt_delete_return_link' ) . '</a>' );
Index: trunk/extensions/LiquidThreads/pages/SpecialMoveThread.php
@@ -22,7 +22,7 @@
2323 wfLoadExtensionMessages( 'LiquidThreads' );
2424 $form_action = $this->getTitle()->getLocalURL() . '/' . $this->thread->title()->getPrefixedURL();
2525 $thread_name = $this->thread->title()->getPrefixedText();
26 - $article_name = $this->thread->article()->getTitle()->getTalkPage()->getPrefixedText();
 26+ $article_name = $this->thread->article()->getTitle()->getPrefixedText();
2727 $edit_url = LqtView::permalinkUrl( $this->thread, 'edit', $this->thread );
2828 $wfMsg = 'wfMsg'; // functions can only be called within string expansion by variable name.
2929 // FIXME: awkward message usage and fixed parameter formatting. Would be nicer if all formatting
@@ -84,14 +84,14 @@
8585 $this->redisplayForm( array( 'lqt_move_thread_target_title' ), wfMsg( 'lqt_move_nodestination' ) );
8686 return;
8787 }
88 - $newtitle = Title::newFromText( $tmp )->getSubjectPage();
 88+ $newtitle = Title::newFromText( $tmp );
8989
9090 $reason = $this->request->getVal( 'lqt_move_thread_reason', wfMsg( 'lqt_noreason' ) );
9191
9292 // TODO no status code from this method.
9393 $this->thread->moveToSubjectPage( $newtitle, $reason, true );
9494
95 - $this->showSuccessMessage( $newtitle->getTalkPage() );
 95+ $this->showSuccessMessage( $newtitle );
9696 }
9797
9898 function showSuccessMessage( $target_title ) {
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php
@@ -181,7 +181,7 @@
182182 // Why is a hook added here?
183183 $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
184184
185 - $this->output->setPageTitle( $this->title->getTalkpage()->getPrefixedText() );
 185+ $this->output->setPageTitle( $this->title->getPrefixedText() );
186186 self::addJSandCSS();
187187 $article = new Article( $this->title ); // Added in r29715 sorting. Why?
188188
Index: trunk/extensions/LiquidThreads/pages/TalkpageArchiveView.php
@@ -200,7 +200,7 @@
201201 global $wgHooks;
202202 $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
203203
204 - $this->output->setPageTitle( $this->title->getTalkpage()->getPrefixedText() );
 204+ $this->output->setPageTitle( $this->title->getPrefixedText() );
205205 self::addJSandCSS();
206206 wfLoadExtensionMessages( 'LiquidThreads' );
207207
Index: trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php
@@ -12,7 +12,7 @@
1313 // the access key for the talk tab doesn't work.
1414 if ($this->thread) {
1515 $article_t = $this->thread->article()->getTitle();
16 - $talk_t = $this->thread->article()->getTitle()->getTalkPage();
 16+ $talk_t = $this->thread->article()->getTitle();
1717 }
1818 efInsertIntoAssoc( 'article', array(
1919 'text' => wfMsg( $article_t->getNamespaceKey() ),
@@ -74,7 +74,7 @@
7575 $query = '';
7676 else
7777 $query = 'lqt_archive_month=' . substr( $this->thread->modified(), 0, 6 );
78 - $talkpage = $this->thread->article()->getTitle()->getTalkpage();
 78+ $talkpage = $this->thread->article()->getTitle();
7979 $talkpage_link = $this->user->getSkin()->makeKnownLinkObj( $talkpage, '', $query );
8080 if ( $this->thread->hasSuperthread() ) {
8181 return wfMsg( 'lqt_fragment', "<a href=\"{$this->permalinkUrl($this->thread->topmostThread())}\">" . wfMsg( 'lqt_discussion_link' ) . "</a>", $talkpage_link );

Status & tagging log