r53775 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53774‎ | r53775 | r53776 >
Date:08:53, 26 July 2009
Author:purodha
Status:deferred (Comments)
Tags:
Comment:
Allow to automatically create the database table `online`.
Modified paths:
  • /trunk/extensions/WhosOnline/WhosOnline.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WhosOnline/WhosOnline.php
@@ -55,3 +55,17 @@
5656
5757 return true;
5858 }
 59+
 60+// Register database operations
 61+$wgHooks['LoadExtensionSchemaUpdates'][] = 'wfWhosOnlineCheckSchema';
 62+
 63+function wfWhosOnlineCheckSchema() {
 64+ // Get a connection
 65+ $db = wfGetDB( DB_MASTER );
 66+ // Create table if it doesn't exist
 67+ if ( !$db->tableExists( 'online' ) ) {
 68+ $db->sourceFile( dirname( __FILE__ ) . '/whosonline.sql' );
 69+ }
 70+ // Continue
 71+ return true;
 72+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r53779Fix up r53775: use $wgExtNewTables in WhosOnline extensioncatrope12:45, 26 July 2009

Comments

#Comment by Catrope (talk | contribs)   09:38, 26 July 2009

You should use $wgExtNewTables instead of adding the table yourself, so update.php will add it and print a message.

#Comment by Purodha (talk | contribs)   11:16, 26 July 2009

update.php did add it, when I tried. Looks like your suggestion was using common code and thus is cheaper and more reliable - could you change it, and I see how it is done? I copied this code mainly from Extension:Drafts, which probably could be enhanced likewise.

#Comment by Catrope (talk | contribs)   12:47, 26 July 2009

Done in r53779. Yes, it uses common code, but it also causes update.php to print a message (as part of the common code). I probably should have phrased my first comment better; what I meant was that update.php should be the one adding it, not wfWhosOnlineCheckSchema().

Status & tagging log