r77527 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77526‎ | r77527 | r77528 >
Date:11:31, 1 December 2010
Author:ialex
Status:deferred
Tags:
Comment:
Converted Poll extension to use the new version of the LoadExtensionSchemaUpdates hook
Modified paths:
  • /trunk/extensions/Poll/Poll.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Poll/Poll.php
@@ -71,25 +71,45 @@
7272 // Schema changes
7373 $wgHooks['LoadExtensionSchemaUpdates'][] = 'efPollSchemaUpdates';
7474
75 -function efPollSchemaUpdates() {
76 - global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewIndexes, $wgExtNewTables;
77 - $base = dirname(__FILE__);
78 - if( $wgDBtype == 'mysql' ) {
79 - // "poll"-Table: All infomation about the polls
80 - $wgExtNewTables[] = array( 'poll', "$base/archives/Poll.sql" ); // Initial install tables
81 - $wgExtNewFields[] = array( 'poll', 'creater', "$base/archives/patch-creater.sql" ); // Add creater
82 - $wgExtNewFields[] = array( 'poll', 'dis', "$base/archives/patch-dis.sql" ); // Add dis
83 - $wgExtNewFields[] = array( 'poll', 'multi', "$base/archives/patch-multi.sql" ); // Add multi
84 - $wgExtNewFields[] = array( 'poll', 'ip', "$base/archives/patch-ip.sql" ); // Add ip
 75+function efPollSchemaUpdates( $updater = null ) {
 76+ $base = dirname( __FILE__ );
 77+ if ( $updater === null ) {
 78+ global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewIndexes, $wgExtNewTables;
 79+ if( $wgDBtype == 'mysql' ) {
 80+ // "poll"-Table: All infomation about the polls
 81+ $wgExtNewTables[] = array( 'poll', "$base/archives/Poll.sql" ); // Initial install tables
 82+ $wgExtNewFields[] = array( 'poll', 'creater', "$base/archives/patch-creater.sql" ); // Add creater
 83+ $wgExtNewFields[] = array( 'poll', 'dis', "$base/archives/patch-dis.sql" ); // Add dis
 84+ $wgExtNewFields[] = array( 'poll', 'multi', "$base/archives/patch-multi.sql" ); // Add multi
 85+ $wgExtNewFields[] = array( 'poll', 'ip', "$base/archives/patch-ip.sql" ); // Add ip
8586
86 - // "poll_answer"-Table: The answer of the users
87 - $wgExtNewTables[] = array( 'poll_answer', "$base/archives/Poll-answer.sql" ); // Initial answer tables
88 - $wgExtNewFields[] = array( 'poll_answer', 'user', "$base/archives/patch-user.sql" ); // Add user
89 - $wgExtNewFields[] = array( 'poll_answer', 'vote_other', "$base/archives/patch-vote_other.sql" ); // Add vote_other
90 - $wgExtNewFields[] = array( 'poll_answer', 'ip', "$base/archives/patch-answer-ip.sql" ); // Add ip
 87+ // "poll_answer"-Table: The answer of the users
 88+ $wgExtNewTables[] = array( 'poll_answer', "$base/archives/Poll-answer.sql" ); // Initial answer tables
 89+ $wgExtNewFields[] = array( 'poll_answer', 'user', "$base/archives/patch-user.sql" ); // Add user
 90+ $wgExtNewFields[] = array( 'poll_answer', 'vote_other', "$base/archives/patch-vote_other.sql" ); // Add vote_other
 91+ $wgExtNewFields[] = array( 'poll_answer', 'ip', "$base/archives/patch-answer-ip.sql" ); // Add ip
9192
92 - // "poll_start_log"-Table: Time with last run of Poll::start()
93 - $wgExtNewTables[] = array( 'poll_start_log', "$base/archives/Poll-start-log.sql" ); // Initial start_log tables
 93+ // "poll_start_log"-Table: Time with last run of Poll::start()
 94+ $wgExtNewTables[] = array( 'poll_start_log', "$base/archives/Poll-start-log.sql" ); // Initial start_log tables
 95+ }
 96+ } else {
 97+ if( $updater->getDB()->getType() == 'mysql' ) {
 98+ // "poll"-Table: All infomation about the polls
 99+ $updater->addExtensionUpdate( array( 'addTable', 'poll', "$base/archives/Poll.sql", true ) ); // Initial install tables
 100+ $updater->addExtensionUpdate( array( 'addField', 'poll', 'creater', "$base/archives/patch-creater.sql", true ) ); // Add creater
 101+ $updater->addExtensionUpdate( array( 'addField', 'poll', 'dis', "$base/archives/patch-dis.sql", true ) ); // Add dis
 102+ $updater->addExtensionUpdate( array( 'addField', 'poll', 'multi', "$base/archives/patch-multi.sql", true ) ); // Add multi
 103+ $updater->addExtensionUpdate( array( 'addField', 'poll', 'ip', "$base/archives/patch-ip.sql", true ) ); // Add ip
 104+
 105+ // "poll_answer"-Table: The answer of the users
 106+ $updater->addExtensionUpdate( array( 'addTable', 'poll_answer', "$base/archives/Poll-answer.sql", true ) ); // Initial answer tables
 107+ $updater->addExtensionUpdate( array( 'addField', 'poll_answer', 'user', "$base/archives/patch-user.sql", true ) ); // Add user
 108+ $updater->addExtensionUpdate( array( 'addField', 'poll_answer', 'vote_other', "$base/archives/patch-vote_other.sql", true ) ); // Add vote_other
 109+ $updater->addExtensionUpdate( array( 'addField', 'poll_answer', 'ip', "$base/archives/patch-answer-ip.sql", true ) ); // Add ip
 110+
 111+ // "poll_start_log"-Table: Time with last run of Poll::start()
 112+ $updater->addExtensionUpdate( array( 'addTable', 'poll_start_log', "$base/archives/Poll-start-log.sql", true ) ); // Initial start_log tables
 113+ }
94114 }
95115 return true;
96116 }

Status & tagging log