r81025 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81024‎ | r81025 | r81026 >
Date:14:37, 26 January 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Drop pre-1.17 compat; this extensions requires 1.17+ since r79905
* Moved two hooks to LqtHooks class
* Removed efInsertIntoAssoc(), unused
Modified paths:
  • /trunk/extensions/LiquidThreads/LiquidThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/LqtFunctions.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Hooks.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Thread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/View.php (modified) (history)
  • /trunk/extensions/LiquidThreads/compat (deleted) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/LqtFunctions.php
@@ -14,46 +14,3 @@
1515 return $default;
1616 }
1717 }
18 -
19 -/**
20 - * Recreate the original associative array so that a new pair with the given key
21 - * and value is inserted before the given existing key. $original_array gets
22 - * modified in-place.
23 -*/
24 -function efInsertIntoAssoc( $new_key, $new_value, $before, &$original_array ) {
25 - $ordered = array();
26 - $i = 0;
27 - foreach ( $original_array as $key => $value ) {
28 - $ordered[$i] = array( $key, $value );
29 - $i += 1;
30 - }
31 - $new_assoc = array();
32 - foreach ( $ordered as $pair ) {
33 - if ( $pair[0] == $before ) {
34 - $new_assoc[$new_key] = $new_value;
35 - }
36 - $new_assoc[$pair[0]] = $pair[1];
37 - }
38 - $original_array = $new_assoc;
39 -}
40 -
41 -function lqtSetupParserFunctions( &$parser ) {
42 - $parser->setFunctionHook(
43 - 'useliquidthreads',
44 - array( 'LqtParserFunctions', 'useLiquidThreads' )
45 - );
46 -
47 - $parser->setFunctionHook(
48 - 'lqtpagelimit',
49 - array( 'LqtParserFunctions', 'lqtPageLimit' )
50 - );
51 -
52 - global $wgLiquidThreadsAllowEmbedding;
53 -
54 - if ($wgLiquidThreadsAllowEmbedding) {
55 - $parser->setHook( 'talkpage', array( 'LqtParserFunctions', 'lqtTalkPage' ) );
56 - $parser->setHook( 'thread', array( 'LqtParserFunctions', 'lqtThread' ) );
57 - }
58 -
59 - return true;
60 -}
Index: trunk/extensions/LiquidThreads/LiquidThreads.php
@@ -21,20 +21,6 @@
2222 define( 'LQT_NEWEST_THREADS', 'nt' );
2323 define( 'LQT_OLDEST_THREADS', 'ot' );
2424
25 -if ( version_compare( $wgVersion, '1.17alpha', '>=' ) ) {
26 - $wgHooks['CanonicalNamespaces'][] = 'wgLqtSetupCanonicalNamespaces';
27 -} else {
28 - wgLqtSetupCanonicalNamespaces( $wgExtraNamespaces );
29 -}
30 -
31 -function wgLqtSetupCanonicalNamespaces( &$list ) {
32 - $list[NS_LQT_THREAD] = 'Thread';
33 - $list[NS_LQT_THREAD_TALK] = 'Thread_talk';
34 - $list[NS_LQT_SUMMARY] = 'Summary';
35 - $list[NS_LQT_SUMMARY_TALK] = 'Summary_talk';
36 - return true;
37 -}
38 -
3925 // Localisation
4026 $dir = dirname( __FILE__ ) . '/';
4127 $wgExtensionMessagesFiles['LiquidThreads'] = $dir . 'i18n/Lqt.i18n.php';
@@ -94,10 +80,13 @@
9581 'dependencies' => array( 'ext.liquidThreads' )
9682 );
9783
 84+// Hooks
9885 // Parser Function Setup
99 -$wgHooks['ParserFirstCallInit'][] = 'lqtSetupParserFunctions';
 86+$wgHooks['ParserFirstCallInit'][] = 'LqtHooks::onParserFirstCallInit';
10087
101 -// Hooks
 88+// Namespaces
 89+$wgHooks['CanonicalNamespaces'][] = 'LqtHooks::onCanonicalNamespaces';
 90+
10291 // Main dispatch hook
10392 $wgHooks['MediaWikiPerformAction'][] = 'LqtDispatch::tryPage';
10493 $wgHooks['SkinTemplateTabs'][] = 'LqtDispatch::onSkinTemplateTabs';
@@ -226,13 +215,6 @@
227216 // Job queue
228217 $wgJobClasses['synchroniseThreadArticleData'] = 'SynchroniseThreadArticleDataJob';
229218
230 -// Backwards-compatibility
231 -$wgAutoloadClasses['Article_LQT_Compat'] = $dir . 'compat/LqtCompatArticle.php';
232 -if ( version_compare( $wgVersion, '1.16', '<' ) ) {
233 - $wgAutoloadClasses['HTMLForm'] = $dir . 'compat/HTMLForm.php';
234 - $wgExtensionMessagesFiles['Lqt-Compat'] = $dir . 'compat/Lqt-compat.i18n.php';
235 -}
236 -
237219 // Logging
238220 $wgLogTypes[] = 'liquidthreads';
239221 $wgLogNames['liquidthreads'] = 'lqt-log-name';
Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -1230,13 +1230,6 @@
12311231 function showPostBody( $post, $oldid = null ) {
12321232 global $wgOut;
12331233
1234 - // Load compatibility layer for older versions
1235 - if ( !( $post instanceof Article_LQT_Compat ) ) {
1236 - // Removed because it's annoying
1237 -// wfWarn( "No article compatibility layer loaded, inefficiently duplicating information." );
1238 - $post = new Article_LQT_Compat( $post->getTitle() );
1239 - }
1240 -
12411234 $parserOutput = $post->getParserOutput( $oldid );
12421235
12431236 // Remove title, so that it stays set correctly.
Index: trunk/extensions/LiquidThreads/classes/Hooks.php
@@ -814,4 +814,33 @@
815815 return false;
816816 }
817817 }
 818+
 819+ public static function onParserFirstCallInit( $parser ) {
 820+ $parser->setFunctionHook(
 821+ 'useliquidthreads',
 822+ array( 'LqtParserFunctions', 'useLiquidThreads' )
 823+ );
 824+
 825+ $parser->setFunctionHook(
 826+ 'lqtpagelimit',
 827+ array( 'LqtParserFunctions', 'lqtPageLimit' )
 828+ );
 829+
 830+ global $wgLiquidThreadsAllowEmbedding;
 831+
 832+ if ( $wgLiquidThreadsAllowEmbedding ) {
 833+ $parser->setHook( 'talkpage', array( 'LqtParserFunctions', 'lqtTalkPage' ) );
 834+ $parser->setHook( 'thread', array( 'LqtParserFunctions', 'lqtThread' ) );
 835+ }
 836+
 837+ return true;
 838+ }
 839+
 840+ public static function onCanonicalNamespaces( &$list ) {
 841+ $list[NS_LQT_THREAD] = 'Thread';
 842+ $list[NS_LQT_THREAD_TALK] = 'Thread_talk';
 843+ $list[NS_LQT_SUMMARY] = 'Summary';
 844+ $list[NS_LQT_SUMMARY_TALK] = 'Summary_talk';
 845+ return true;
 846+ }
818847 }
Index: trunk/extensions/LiquidThreads/classes/Thread.php
@@ -426,12 +426,12 @@
427427 ' [[' . $this->title()->getPrefixedText() . "]]\n";
428428
429429 // Make the article edit.
430 - $traceTitle = Threads::newThreadTitle( $this->subject(), new Article_LQT_Compat( $oldTitle ) );
431 - $redirectArticle = new Article_LQT_Compat( $traceTitle );
 430+ $traceTitle = Threads::newThreadTitle( $this->subject(), new Article( $oldTitle ) );
 431+ $redirectArticle = new Article( $traceTitle );
432432 $redirectArticle->doEdit( $redirectText, $reason, EDIT_NEW | EDIT_SUPPRESS_RC );
433433
434434 // Add the trace thread to the tracking table.
435 - $thread = Thread::create( $redirectArticle, new Article_LQT_Compat( $oldTitle ), null,
 435+ $thread = Thread::create( $redirectArticle, new Article( $oldTitle ), null,
436436 Threads::TYPE_MOVED, $this->subject() );
437437
438438 $thread->setSortkey( $this->sortkey() );
@@ -529,7 +529,7 @@
530530
531531 if ( isset( $line->page_namespace ) && isset( $line->page_title ) ) {
532532 $root_title = Title::makeTitle( $line->page_namespace, $line->page_title );
533 - $this->root = new Article_LQT_Compat( $root_title );
 533+ $this->root = new Article( $root_title );
534534 $this->root->loadPageData( $line );
535535 } else {
536536 if ( isset( self::$titleCacheById[$this->rootId] ) ) {
@@ -539,7 +539,7 @@
540540 }
541541
542542 if ( $root_title ) {
543 - $this->root = new Article_LQT_Compat( $root_title );
 543+ $this->root = new Article( $root_title );
544544 }
545545 }
546546
@@ -673,7 +673,7 @@
674674 $row->page_restrictions );
675675 }
676676
677 - $article = new Article_LQT_Compat( $t );
 677+ $article = new Article( $t );
678678 $article->loadPageData( $row );
679679
680680 self::$titleCacheById[$t->getArticleId()] = $t;
@@ -851,7 +851,7 @@
852852 $articleTitle->getNamespace() != NS_LQT_THREAD &&
853853 $wgLiquidThreadsMigrate ) {
854854 $newTitle = $articleTitle->getTalkPage();
855 - $newArticle = new Article_LQT_Compat( $newTitle );
 855+ $newArticle = new Article( $newTitle );
856856
857857 $set['thread_article_namespace'] = $newTitle->getNamespace();
858858 $set['thread_article_title'] = $newTitle->getDbKey();
@@ -883,7 +883,7 @@
884884 if ( $this->articleId && isset( self::$titleCacheById[$this->articleId] ) ) {
885885 // If it corresponds to a title, the article obviously exists.
886886 $articleTitle = self::$titleCacheById[$this->articleId];
887 - $this->article = new Article_LQT_Compat( $articleTitle );
 887+ $this->article = new Article( $articleTitle );
888888 } elseif ( $this->articleId ) {
889889 $articleTitle = Title::newFromID( $this->articleId );
890890 }
@@ -893,7 +893,7 @@
894894 if ( !$articleTitle && ( $this->articleId != 0 || $dbTitle->getArticleId() != 0 ) ) {
895895 $articleTitle = $dbTitle;
896896 $this->articleId = $articleTitle->getArticleId();
897 - $this->article = new Article_LQT_Compat( $dbTitle );
 897+ $this->article = new Article( $dbTitle );
898898
899899 $set['thread_article_id'] = $this->articleId;
900900 wfDebug( "Unfilled or non-existent thread_article_id, refilling to {$this->articleId}\n" );
@@ -1133,7 +1133,7 @@
11341134 }
11351135
11361136 if ( $title ) {
1137 - $article = new Article_LQT_Compat( $title );
 1137+ $article = new Article( $title );
11381138 self::$articleCacheById[$this->articleId] = $article;
11391139 }
11401140 }
@@ -1143,7 +1143,7 @@
11441144 return $article;
11451145 } else {
11461146 $title = Title::makeTitle( $this->articleNamespace, $this->articleTitle );
1147 - return new Article_LQT_Compat( $title );
 1147+ return new Article( $title );
11481148 }
11491149 }
11501150
@@ -1182,7 +1182,7 @@
11831183 return null;
11841184 }
11851185
1186 - $this->root = new Article_LQT_Compat( $title );
 1186+ $this->root = new Article( $title );
11871187 }
11881188 return $this->root;
11891189 }
@@ -1204,7 +1204,7 @@
12051205 return null;
12061206 }
12071207
1208 - $this->summary = new Article_LQT_Compat( $title );
 1208+ $this->summary = new Article( $title );
12091209
12101210 }
12111211
@@ -1296,7 +1296,7 @@
12971297 if ( !$rtitle ) return null;
12981298
12991299 $this->dieIfHistorical();
1300 - $rthread = Threads::withRoot( new Article_LQT_Compat( $rtitle ) );
 1300+ $rthread = Threads::withRoot( new Article( $rtitle ) );
13011301 return $rthread;
13021302 }
13031303

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79905Convert LQT to resource loader....hartman17:14, 9 January 2011

Comments

#Comment by Reedy (talk | contribs)   14:43, 26 January 2011

From memory, there are a few other version checking things against 1.15 that I removed but was reverted because it was deemed premature...

Will see if I can find them again later

#Comment by Reach Out to the Truth (talk | contribs)   15:24, 26 January 2011
#Comment by Reedy (talk | contribs)   16:40, 26 January 2011

Yup, cheers.

#Comment by Werdna (talk | contribs)   18:30, 26 January 2011

I don't want to drop pre-1.17 compatibility until a month or two after a 1.17 release.

If LiquidThreads has been converted to Resource Loader, I would like some back-compatibility code.

Status & tagging log