r107399 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107398‎ | r107399 | r107400 >
Date:18:02, 27 December 2011
Author:reedy
Status:ok
Tags:
Comment:
Documentation

Remove pre 1.17 compat by Removing non $updater usage in onLoadExtensionSchemaUpdates
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/Dispatch.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/Dispatch.php
@@ -90,6 +90,10 @@
9191 return $view->show();
9292 }
9393
 94+ /**
 95+ * @param $title Title
 96+ * @return bool|null
 97+ */
9498 static function isLqtPage( $title ) {
9599 // Ignore it if it's a thread or a summary, makes no sense to have LiquidThreads there.
96100 if ( $title->getNamespace() == NS_LQT_THREAD ||
Index: trunk/extensions/LiquidThreads/classes/Hooks.php
@@ -5,6 +5,10 @@
66 public static $editType = null;
77 public static $editThread = null;
88 public static $editAppliesTo = null;
 9+
 10+ /**
 11+ * @var Article
 12+ */
913 public static $editArticle = null;
1014 public static $editTalkpage = null;
1115 public static $scriptVariables = array();
@@ -21,6 +25,12 @@
2226 Threads::TYPE_DELETED => 'deleted'
2327 );
2428
 29+ /**
 30+ * @param $changeslist ChangesList
 31+ * @param $s string
 32+ * @param $rc RecentChange
 33+ * @return bool
 34+ */
2535 static function customizeOldChangesList( &$changeslist, &$s, $rc ) {
2636 if ( $rc->getTitle()->getNamespace() != NS_LQT_THREAD ) {
2737 return true;
@@ -158,15 +168,15 @@
159169 return true;
160170 }
161171
 172+ /**
 173+ * @param $article Article
 174+ * @return bool
 175+ */
162176 static function updateNewtalkOnEdit( $article ) {
163177 $title = $article->getTitle();
164178
165 - if ( LqtDispatch::isLqtPage( $title ) ) {
166 - // They're only editing the header, don't update newtalk.
167 - return false;
168 - }
169 -
170 - return true;
 179+ // They're only editing the header, don't update newtalk.
 180+ return !LqtDispatch::isLqtPage( $title );
171181 }
172182
173183 static function dumpThreadData( $writer, &$out, $row, $title ) {
@@ -259,6 +269,12 @@
260270 return true;
261271 }
262272
 273+ /**
 274+ * @param $editPage EditPage
 275+ * @param $checkboxes
 276+ * @param $tabIndex
 277+ * @return bool
 278+ */
263279 static function editCheckboxes( $editPage, &$checkboxes, &$tabIndex ) {
264280 global $wgRequest, $wgLiquidThreadsShowBumpCheckbox;
265281
@@ -317,60 +333,37 @@
318334 return true;
319335 }
320336
 337+ /**
 338+ * @param $updater DatabaseUpdater
 339+ * @return bool
 340+ */
321341 public static function onLoadExtensionSchemaUpdates( $updater = null ) {
322342 $dir = realpath( dirname( __FILE__ ) . '/..' );
323343
324 - if ( $updater === null ) {
325 - // DB updates
326 - $wgExtNewTables[] = array( 'thread', "$dir/lqt.sql" );
327 - $wgExtNewTables[] = array( 'user_message_state', "$dir/lqt.sql" );
328 - $wgExtNewTables[] = array( 'thread_history', "$dir/schema-changes/thread_history_table.sql" );
329 - $wgExtNewTables[] = array( 'thread_pending_relationship', "$dir/schema-changes/thread_pending_relationship.sql" );
330 - $wgExtNewTables[] = array( 'thread_reaction', "$dir/schema-changes/thread_reactions.sql" );
 344+ $updater->addExtensionUpdate( array( 'addTable', 'thread', "$dir/lqt.sql", true ) );
 345+ $updater->addExtensionUpdate( array( 'addTable', 'user_message_state', "$dir/lqt.sql", true ) );
 346+ $updater->addExtensionUpdate( array( 'addTable', 'thread_history', "$dir/schema-changes/thread_history_table.sql", true ) );
 347+ $updater->addExtensionUpdate( array( 'addTable', 'thread_pending_relationship', "$dir/schema-changes/thread_pending_relationship.sql", true ) );
 348+ $updater->addExtensionUpdate( array( 'addTable', 'thread_reaction', "$dir/schema-changes/thread_reactions.sql", true ) );
331349
332 - $wgExtNewFields[] = array( "thread", "thread_article_namespace", "$dir/schema-changes/split-thread_article.sql" );
333 - $wgExtNewFields[] = array( "thread", "thread_article_title", "$dir/schema-changes/split-thread_article.sql" );
334 - $wgExtNewFields[] = array( "thread", "thread_ancestor", "$dir/schema-changes/normalise-ancestry.sql" );
335 - $wgExtNewFields[] = array( "thread", "thread_parent", "$dir/schema-changes/normalise-ancestry.sql" );
336 - $wgExtNewFields[] = array( "thread", "thread_modified", "$dir/schema-changes/split-timestamps.sql" );
337 - $wgExtNewFields[] = array( "thread", "thread_created", "$dir/schema-changes/split-timestamps.sql" );
338 - $wgExtNewFields[] = array( "thread", "thread_editedness", "$dir/schema-changes/store-editedness.sql" );
339 - $wgExtNewFields[] = array( "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql" );
340 - $wgExtNewFields[] = array( "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql" );
341 - $wgExtNewFields[] = array( "thread", "thread_author_name", "$dir/schema-changes/store_subject-author.sql" );
342 - $wgExtNewFields[] = array( "thread", "thread_sortkey", "$dir/schema-changes/new-sortkey.sql" );
343 - $wgExtNewFields[] = array( 'thread', 'thread_replies', "$dir/schema-changes/store_reply_count.sql" );
344 - $wgExtNewFields[] = array( 'thread', 'thread_article_id', "$dir/schema-changes/store_article_id.sql" );
345 - $wgExtNewFields[] = array( 'thread', 'thread_signature', "$dir/schema-changes/thread_signature.sql" );
346 - $wgExtNewFields[] = array( 'user_message_state', 'ums_conversation', "$dir/schema-changes/ums_conversation.sql" );
 350+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_article_namespace", "$dir/schema-changes/split-thread_article.sql", true ) );
 351+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_article_title", "$dir/schema-changes/split-thread_article.sql", true ) );
 352+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_ancestor", "$dir/schema-changes/normalise-ancestry.sql", true ) );
 353+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_parent", "$dir/schema-changes/normalise-ancestry.sql", true ) );
 354+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_modified", "$dir/schema-changes/split-timestamps.sql", true ) );
 355+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_created", "$dir/schema-changes/split-timestamps.sql", true ) );
 356+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_editedness", "$dir/schema-changes/store-editedness.sql", true ) );
 357+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql", true ) );
 358+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql", true ) );
 359+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_author_name", "$dir/schema-changes/store_subject-author.sql", true ) );
 360+ $updater->addExtensionUpdate( array( 'addField', "thread", "thread_sortkey", "$dir/schema-changes/new-sortkey.sql", true ) );
 361+ $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_replies', "$dir/schema-changes/store_reply_count.sql", true ) );
 362+ $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_article_id', "$dir/schema-changes/store_article_id.sql", true ) );
 363+ $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_signature', "$dir/schema-changes/thread_signature.sql", true ) );
 364+ $updater->addExtensionUpdate( array( 'addField', 'user_message_state', 'ums_conversation', "$dir/schema-changes/ums_conversation.sql", true ) );
347365
348 - $wgExtNewIndexes[] = array( 'thread', 'thread_summary_page', '(thread_summary_page)' );
349 - } else {
350 - $updater->addExtensionUpdate( array( 'addTable', 'thread', "$dir/lqt.sql", true ) );
351 - $updater->addExtensionUpdate( array( 'addTable', 'user_message_state', "$dir/lqt.sql", true ) );
352 - $updater->addExtensionUpdate( array( 'addTable', 'thread_history', "$dir/schema-changes/thread_history_table.sql", true ) );
353 - $updater->addExtensionUpdate( array( 'addTable', 'thread_pending_relationship', "$dir/schema-changes/thread_pending_relationship.sql", true ) );
354 - $updater->addExtensionUpdate( array( 'addTable', 'thread_reaction', "$dir/schema-changes/thread_reactions.sql", true ) );
 366+ $updater->addExtensionUpdate( array( 'addIndex', 'thread', 'thread_summary_page', '(thread_summary_page)' ) );
355367
356 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_article_namespace", "$dir/schema-changes/split-thread_article.sql", true ) );
357 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_article_title", "$dir/schema-changes/split-thread_article.sql", true ) );
358 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_ancestor", "$dir/schema-changes/normalise-ancestry.sql", true ) );
359 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_parent", "$dir/schema-changes/normalise-ancestry.sql", true ) );
360 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_modified", "$dir/schema-changes/split-timestamps.sql", true ) );
361 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_created", "$dir/schema-changes/split-timestamps.sql", true ) );
362 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_editedness", "$dir/schema-changes/store-editedness.sql", true ) );
363 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql", true ) );
364 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql", true ) );
365 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_author_name", "$dir/schema-changes/store_subject-author.sql", true ) );
366 - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_sortkey", "$dir/schema-changes/new-sortkey.sql", true ) );
367 - $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_replies', "$dir/schema-changes/store_reply_count.sql", true ) );
368 - $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_article_id', "$dir/schema-changes/store_article_id.sql", true ) );
369 - $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_signature', "$dir/schema-changes/thread_signature.sql", true ) );
370 - $updater->addExtensionUpdate( array( 'addField', 'user_message_state', 'ums_conversation', "$dir/schema-changes/ums_conversation.sql", true ) );
371 -
372 - $updater->addExtensionUpdate( array( 'addIndex', 'thread', 'thread_summary_page', '(thread_summary_page)' ) );
373 - }
374 -
375368 return true;
376369 }
377370
@@ -395,6 +388,13 @@
396389 return true;
397390 }
398391
 392+ /**
 393+ * @param $user User
 394+ * @param $title Title
 395+ * @param $isBlocked bool
 396+ * @param $allowUserTalk bool
 397+ * @return bool
 398+ */
399399 static function userIsBlockedFrom( $user, $title, &$isBlocked, &$allowUserTalk ) {
400400 // Limit applicability
401401 if ( !( $isBlocked && $allowUserTalk && $title->getNamespace() == NS_LQT_THREAD ) ) {
@@ -473,6 +473,20 @@
474474 return true;
475475 }
476476
 477+ /**
 478+ * @param $article Article
 479+ * @param $user User
 480+ * @param $text
 481+ * @param $summary
 482+ * @param $minoredit
 483+ * @param $watchthis
 484+ * @param $sectionanchor
 485+ * @param $flags
 486+ * @param $revision
 487+ * @param $status Status
 488+ * @param $baseRevId
 489+ * @return bool
 490+ */
477491 static function onArticleSaveComplete( &$article, &$user, $text, $summary,
478492 $minoredit, $watchthis, $sectionanchor, &$flags, $revision,
479493 &$status, $baseRevId ) {
@@ -510,6 +524,11 @@
511525 return true;
512526 }
513527
 528+ /**
 529+ * @param $title Title
 530+ * @param $types
 531+ * @return bool
 532+ */
514533 static function getProtectionTypes( $title, &$types ) {
515534 $isLqtPage = LqtDispatch::isLqtPage( $title );
516535 $isThread = $title->getNamespace() == NS_LQT_THREAD;
@@ -530,6 +549,10 @@
531550 return true;
532551 }
533552
 553+ /**
 554+ * @param $vars sttsu
 555+ * @return bool
 556+ */
534557 public static function onMakeGlobalVariablesScript( &$vars ) {
535558 $vars += self::$scriptVariables;
536559
@@ -540,6 +563,7 @@
541564 * Returns the text contents of a template page set in given key contents
542565 * Returns empty string if no text could be retrieved.
543566 * @param $key String: message key that should contain a template page name
 567+ * @return String
544568 */
545569 private static function getTextForPageInKey( $key ) {
546570 $templateTitleText = wfMsgForContent( $key );
@@ -564,7 +588,6 @@
565589 /**
566590 * Handles tags in Page sections of XML dumps
567591 */
568 -
569592 public static function handlePageXMLTag( $reader, &$pageInfo ) {
570593 if ( !isset( $reader->nodeType ) || !( $reader->nodeType == XmlReader::ELEMENT &&
571594 $reader->name == 'DiscussionThreading' ) ) {
@@ -603,7 +626,16 @@
604627 return false;
605628 }
606629
607 - // Processes discussion threading data in XML dumps (extracted in handlePageXMLTag).
 630+ /**
 631+ * Processes discussion threading data in XML dumps (extracted in handlePageXMLTag).
 632+ *
 633+ * @param $title Title
 634+ * @param $origTitle Title
 635+ * @param $revCount
 636+ * @param $sRevCount
 637+ * @param $pageInfo
 638+ * @return bool
 639+ */
608640 public static function afterImportPage( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) {
609641 // in-process cache of pending thread relationships
610642 static $pendingRelationships = null;
@@ -695,6 +727,10 @@
696728 }
697729 }
698730
 731+ /**
 732+ * @param $pendingRelationship
 733+ * @param $title Title
 734+ */
699735 public static function applyPendingArticleRelationship( $pendingRelationship, $title ) {
700736 $articleID = $title->getArticleId();
701737
@@ -708,6 +744,9 @@
709745 array( 'tpr_title' => $pendingRelationship['title'] ), __METHOD__ );
710746 }
711747
 748+ /**
 749+ * @return array
 750+ */
712751 public static function loadPendingRelationships() {
713752 $dbr = wfGetDB( DB_MASTER );
714753 $arr = array();
@@ -756,7 +795,15 @@
757796 $array[$title][] = $entry;
758797 }
759798
760 - // Do not allow users to read threads on talkpages that they cannot read.
 799+ /**
 800+ * Do not allow users to read threads on talkpages that they cannot read.
 801+ *
 802+ * @param $title Title
 803+ * @param $user
 804+ * @param $action
 805+ * @param $result
 806+ * @return bool
 807+ */
761808 public static function onGetUserPermissionsErrors( $title, $user, $action, &$result ) {
762809 if ( $title->getNamespace() != NS_LQT_THREAD || $action != 'read' )
763810 return true;
@@ -779,6 +826,10 @@
780827 }
781828 }
782829
 830+ /**
 831+ * @param $parser Parser
 832+ * @return bool
 833+ */
783834 public static function onParserFirstCallInit( $parser ) {
784835 $parser->setFunctionHook(
785836 'useliquidthreads',
@@ -800,6 +851,10 @@
801852 return true;
802853 }
803854
 855+ /**
 856+ * @param $list array
 857+ * @return bool
 858+ */
804859 public static function onCanonicalNamespaces( &$list ) {
805860 $list[NS_LQT_THREAD] = 'Thread';
806861 $list[NS_LQT_THREAD_TALK] = 'Thread_talk';

Status & tagging log