r94771 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94770‎ | r94771 | r94772 >
Date:16:33, 17 August 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Switch ContributionTracking to use newer updater
Modified paths:
  • /trunk/extensions/ContributionTracking/ContributionTracking.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionTracking/ContributionTracking.php
@@ -50,7 +50,7 @@
5151
5252 /**
5353 * The default 'return to' URL for a thank you page after posting to the contribution
54 - *
 54+ *
5555 * NO trailing slash, please
5656 */
5757 $wgContributionTrackingReturnToURLDefault = 'http://wikimediafoundation.org/wiki/Thank_You';
@@ -71,7 +71,7 @@
7272 $wgContributionTrackingPayPalRecurringIPN = 'https://civicrm.wikimedia.org/fundcore_gateway/paypal';
7373
7474 /**
75 - * 'Business' string for PayPal
 75+ * 'Business' string for PayPal
7676 */
7777 $wgContributionTrackingPayPalBusiness = 'donations@wikimedia.org';
7878
@@ -88,17 +88,30 @@
8989 // api modules
9090 $wgAPIModules['contributiontracking'] = 'ApiContributionTracking';
9191
92 -function efContributionTrackingLoadUpdates(){
93 - global $wgExtNewTables, $wgExtNewFields;
94 - $dir = dirname( __FILE__ ) . '/';
95 - $wgExtNewTables[] = array( 'contribution_tracking', $dir . 'ContributionTracking.sql' );
96 - $wgExtNewTables[] = array( 'contribution_tracking_owa_ref', $dir . 'ContributionTracking_OWA_ref.sql' );
97 -
98 - $wgExtNewFields[] = array(
99 - 'contribution_tracking',
100 - 'owa_session',
101 - $dir . 'patch-owa.sql',
102 - );
103 - return true;
104 -
 92+/**
 93+ * @param $updater DatabaseUpdater
 94+ * @return bool
 95+ */
 96+function efContributionTrackingLoadUpdates( $updater = null ){
 97+
 98+ $dir = dirname( __FILE__ ) . '/';
 99+ if ( $updater === null ) {
 100+ global $wgExtNewTables, $wgExtNewFields;
 101+
 102+ $wgExtNewTables[] = array( 'contribution_tracking', $dir . 'ContributionTracking.sql' );
 103+ $wgExtNewTables[] = array( 'contribution_tracking_owa_ref', $dir . 'ContributionTracking_OWA_ref.sql' );
 104+
 105+ $wgExtNewFields[] = array(
 106+ 'contribution_tracking',
 107+ 'owa_session',
 108+ $dir . 'patch-owa.sql',
 109+ );
 110+ } else {
 111+ $updater->addExtensionTable( 'contribution_tracking', $dir . 'ContributionTracking.sql' );
 112+ $updater->addExtensionTable( 'contribution_tracking_owa_ref', $dir . 'ContributionTracking_OWA_ref.sql' );
 113+ $updater->addExtensionUpdate( array( 'addField', 'contribution_tracking', 'owa_session',
 114+ $dir . 'patch-owa.sql', true ) );
 115+ }
 116+ return true;
 117+
105118 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r94809r94720 r94771...khorn20:09, 17 August 2011
r95254r94809: This will now use the updater object for schema changes only if the e...khorn21:12, 22 August 2011

Comments

#Comment by Khorn (WMF) (talk | contribs)   18:29, 17 August 2011

I see what you did there. :)

#Comment by Reedy (talk | contribs)   18:33, 17 August 2011

It's somewhat redundant though...

//this only works if contribution tracking is inside a mediawiki DB, which typically it isn't.
//$wgHooks['LoadExtensionSchemaUpdates'][] = 'efContributionTrackingLoadUpdates';
#Comment by Khorn (WMF) (talk | contribs)   18:45, 17 August 2011

Well, I removed those two columns from my local ContributionTracking db (which is, in my case, also my mediawiki db), uncommented the hook, and ran update.php. Everything tested OK for me.

#Comment by Reedy (talk | contribs)   19:03, 17 August 2011

You could commit it then uncommented

WMF etc don't use the updater, so won't use this function, so it isn't actually going to be an issue for the wikis with the tables elsewhere :)

Status & tagging log