r77831 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77830‎ | r77831 | r77832 >
Date:20:57, 5 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Making use of the regular way of adding tables instead of the SMW way, which doesn't make much sense here. Will fix naming and other issues later on.
Modified paths:
  • /trunk/extensions/DSMW/DSMW.hooks.php (modified) (history)
  • /trunk/extensions/DSMW/DSMW.php (modified) (history)
  • /trunk/extensions/DSMW/DSMW.sql (added) (history)
  • /trunk/extensions/DSMW/db/DSMWDBHelpers.php (deleted) (history)
  • /trunk/extensions/DSMW/db/addedTables.sql (deleted) (history)
  • /trunk/extensions/DSMW/includes/Ajax/include.php (modified) (history)
  • /trunk/extensions/DSMW/includes/DSMWExhibits.php (modified) (history)
  • /trunk/extensions/DSMW/includes/DSMWSiteId.php (modified) (history)
  • /trunk/extensions/DSMW/jobs/DSMWPropertyTypeJob.php (modified) (history)
  • /trunk/extensions/DSMW/logootModel/manager.php (modified) (history)
  • /trunk/extensions/DSMW/specialPage/DSMWAdmin.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DSMW/DSMW.hooks.php
@@ -17,6 +17,27 @@
1818 /**
1919 * @since 1.1
2020 *
 21+ * @return true
 22+ */
 23+ public function onExtensionSchemaUpdates() {
 24+ global $wgExtNewTables;
 25+
 26+ $wgExtNewTables[] = array(
 27+ 'model',
 28+ dirname( __FILE__ ) . '/DSMW.sql'
 29+ );
 30+
 31+ $wgExtNewTables[] = array(
 32+ 'p2p_params',
 33+ dirname( __FILE__ ) . '/DSMW.sql'
 34+ );
 35+
 36+ return true;
 37+ }
 38+
 39+ /**
 40+ * @since 1.1
 41+ *
2142 * @param EditPage $editor
2243 * @param OutputPage &$out
2344 *
@@ -701,5 +722,4 @@
702723 return true;
703724 }
704725
705 -
706 -}
\ No newline at end of file
 726+}
Index: trunk/extensions/DSMW/logootModel/manager.php
@@ -4,6 +4,7 @@
55 * Used to seperated the data access layer
66 *
77 * @copyright INRIA-LORIA-ECOO project
 8+ *
89 * @author CUCUTEANU
910 */
1011 class manager {
@@ -23,6 +24,7 @@
2425 return new boModel();
2526 }
2627 } catch ( Exception $e ) {
 28+ die($e->getMessage());
2729 throw new MWException( __METHOD__ . ' db access problems,
2830 if this page existed before the DSMW installation,
2931 maybe it has not been processed by DSMW' );
@@ -47,4 +49,5 @@
4850 throw new MWException( __METHOD__ . ' db access problems' );
4951 }
5052 }
 53+
5154 }
Index: trunk/extensions/DSMW/db/DSMWDBHelpers.php
@@ -1,63 +0,0 @@
2 -<?php
3 -/*
4 - * To change this template, choose Tools | Templates
5 - * and open the template in the editor.
6 - */
7 -
8 -/**
9 - * Description of DSMWDBHelpers
10 - *
11 - * @copyright INRIA-LORIA-SCORE Team
12 - * @author jean-Philippe Muller
13 - */
14 -class DSMWDBHelpers {
15 -
16 - public static function setup( $db ) {
17 - extract( $db->tableNames( 'model', 'p2p_params' ) );
18 - DSMWDBHelpers::reportProgress( "Setting up database configuration for DSMW ...\n\n" );
19 - DSMWDBHelpers::setupTable( $model, $db );
20 - DSMWDBHelpers::setupTable( $p2p_params, $db );
21 - DSMWDBHelpers::reportProgress( "Database initialised successfully.\n\n" );
22 - return true;
23 - }
24 -
25 - public static function setupTable( $table, $db ) {
26 - global $wgDBname, $wgDBprefix;
27 - $fname = 'DSMWDBHelpers::setupTable';
28 - DSMWDBHelpers::reportProgress( "Setting up table $table ...\n" );
29 - if ( $db->tableExists( $table ) === false ) {
30 - // creation
31 - if ( $table == "`{$wgDBprefix}model`" ) {
32 - $sql = 'CREATE TABLE ' . "`$wgDBname`." . $table . ' (
33 -`rev_id` INT( 10 ) NOT NULL ,
34 -`session_id` VARCHAR( 50 ) NOT NULL ,
35 -`blob_info` LONGBLOB NULL ,
36 -`causal_barrier` BLOB NULL ,
37 -PRIMARY KEY ( `rev_id` , `session_id` )
38 -) ENGINE = InnoDB CHARACTER SET binary;';
39 - $db->query( $sql, $fname );
40 - } elseif ( $table == "`{$wgDBprefix}p2p_params`" ) {
41 - $sql = 'CREATE TABLE ' . "`$wgDBname`." . $table . ' (
42 -`value` BIGINT( 18 ) NOT NULL DEFAULT \'0\',
43 - `server_id` VARCHAR( 40 ) NOT NULL DEFAULT \'0\'
44 -) ENGINE = InnoDB DEFAULT CHARSET = latin1;';
45 -$sql1 = 'INSERT INTO ' . "`$wgDBname`." . $table . ' (`value`, `server_id`) VALUES (\'0\', \'0\');';
46 - $db->query( $sql, $fname );
47 - $db->query( $sql1, $fname );
48 - }
49 -
50 - DSMWDBHelpers::reportProgress( " ... new table created\n" );
51 - } else {
52 - DSMWDBHelpers::reportProgress( " ... table exists already\n" );
53 - }
54 - }
55 -
56 - public static function reportProgress( $msg ) {
57 - if ( ob_get_level() == 0 ) {
58 - ob_start();
59 - }
60 - print $msg;
61 - ob_flush();
62 - flush();
63 - }
64 -}
Index: trunk/extensions/DSMW/db/addedTables.sql
@@ -1,18 +0,0 @@
2 -
3 -DROP TABLE IF EXISTS `wikidb`./*$wgDBprefix*/model;
4 -DROP TABLE IF EXISTS `wikidb`./*$wgDBprefix*/p2p_params;
5 -
6 -CREATE TABLE `wikidb`./*$wgDBprefix*/model (
7 -`rev_id` INT( 10 ) NOT NULL ,
8 -`session_id` VARCHAR( 50 ) NOT NULL ,
9 -`blob_info` LONGBLOB NULL ,
10 -`causal_barrier` BLOB NULL ,
11 -PRIMARY KEY ( `rev_id` , `session_id` )
12 -) ENGINE = InnoDB CHARACTER SET binary;
13 -
14 - CREATE TABLE `wikidb`./*$wgDBprefix*/p2p_params (
15 -`value` BIGINT( 18 ) NOT NULL DEFAULT '0',
16 - `server_id` VARCHAR( 40 ) NOT NULL DEFAULT '0'
17 -) ENGINE = InnoDB DEFAULT CHARSET = latin1;
18 -
19 -INSERT INTO `wikidb`./*$wgDBprefix*/p2p_params (`value`, `server_id`) VALUES ('0', '0');
\ No newline at end of file
Index: trunk/extensions/DSMW/jobs/DSMWPropertyTypeJob.php
@@ -1,6 +1,6 @@
22 <?php
33 /**
4 - * Job that assigns a type to some properties used in the DSMW ontology
 4+ * Job that assigns a type to some properties used in the DSMW ontology.
55 *
66 * @copyright 2009 INRIA-LORIA-Score Team
77 *
Index: trunk/extensions/DSMW/DSMW.php
@@ -99,6 +99,7 @@
100100
101101 $wgExtensionFunctions[] = 'dsmwgSetupFunction';
102102
 103+$wgHooks['LoadExtensionSchemaUpdates'][] = 'DSMWHooks::onExtensionSchemaUpdates';
103104 $wgHooks['UnknownAction'][] = 'DSMWHooks::onUnknownAction';
104105 $wgHooks['EditPage::attemptSave'][] = 'DSMWHooks::onAttemptSave';
105106 $wgHooks['EditPageBeforeConflictDiff'][] = 'DSMWHooks::onEditConflict';
Index: trunk/extensions/DSMW/includes/DSMWExhibits.php
@@ -10,7 +10,8 @@
1111 *
1212 */
1313 class DSMWExhibits {
14 -// Constructor
 14+
 15+ // Constructor
1516 public function DSMWExhibits() {
1617 global $wgHooks;
1718
@@ -80,8 +81,6 @@
8182
8283 $wgOut->addWikiText( $text );
8384
84 -
85 -
8685 return false;
8786 }
8887 else {
@@ -109,5 +108,4 @@
110109 return true;
111110 }
112111
113 -
114112 }
Index: trunk/extensions/DSMW/includes/DSMWSiteId.php
@@ -47,24 +47,25 @@
4848 return strtoupper( $serverId );
4949 }
5050
51 -/**
52 - * loads the siteId from the DB
53 - * @return <string> siteId
54 - */
 51+ /**
 52+ * loads the siteId from the DB
 53+ * @return <string> siteId
 54+ */
5555 private function loadServerId() {
5656 $db = wfGetDB( DB_SLAVE );
5757 $res = $db->selectField( 'p2p_params', 'server_id' );
5858 return $res;
5959 }
6060
61 -/**
62 - * stores the siteId to the DB
63 - * @param <type> $ServerId
64 - */
 61+ /**
 62+ * stores the siteId to the DB
 63+ * @param <type> $ServerId
 64+ */
6565 private function store( $ServerId ) {
6666 $dbw = wfGetDB( DB_MASTER );
6767 $dbw->update( 'p2p_params', array(
6868 'server_id' => $ServerId,
6969 ), '*', __METHOD__ );
7070 }
 71+
7172 }
Index: trunk/extensions/DSMW/includes/Ajax/include.php
@@ -1,4 +1,5 @@
22 <?php
 3+
34 /**
45 * JavaScript extension - Includes all *.js files in the directory containing this script
56 *
@@ -34,4 +35,3 @@
3536 }
3637 return true;
3738 }
38 -?>
\ No newline at end of file
Index: trunk/extensions/DSMW/DSMW.sql
@@ -0,0 +1,16 @@
 2+-- MySQL version of the database schema for the DSMW extension.
 3+
 4+CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/model (
 5+ rev_id INT( 10 ) NOT NULL,
 6+ session_id VARCHAR( 50 ) NOT NULL,
 7+ blob_info LONGBLOB NULL,
 8+ causal_barrier BLOB NULL,
 9+ PRIMARY KEY ( `rev_id` , `session_id` )
 10+) ENGINE = InnoDB CHARACTER SET binary;
 11+
 12+CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/p2p_params (
 13+ value BIGINT( 18 ) NOT NULL DEFAULT '0',
 14+ server_id VARCHAR( 40 ) NOT NULL DEFAULT '0'
 15+) ENGINE = InnoDB DEFAULT CHARSET = latin1;
 16+
 17+INSERT INTO /*$wgDBprefix*/p2p_params (value, server_id) VALUES ('0', '0');
\ No newline at end of file
Property changes on: trunk/extensions/DSMW/DSMW.sql
___________________________________________________________________
Added: svn:eol-style
118 + native
Index: trunk/extensions/DSMW/specialPage/DSMWAdmin.php
@@ -4,11 +4,10 @@
55 * DSMW Special page
66 *
77 * @copyright INRIA-LORIA-ECOO project
 8+ *
89 * @author jean-Philippe Muller
910 */
1011
11 -require_once "$IP/includes/SpecialPage.php";
12 -
1312 class DSMWAdmin extends SpecialPage {
1413
1514 public function __construct() {
@@ -35,10 +34,9 @@
3635 * @return <bool>
3736 */
3837 public function execute() {
39 - global $wgOut, $wgRequest, $wgServerName, $wgScriptPath, $wgDSMWIP, $wgServerName, $wgScriptPath; /*, $wgSitename, $wgCachePages, $wgUser, $wgTitle, $wgDenyAccessMessage, $wgAllowAnonUsers, $wgRequest, $wgMessageCache, $wgWatchingMessages, $wgDBtype, $namespace_titles;*/
 38+ global $wgOut, $wgRequest, $wgServerName, $wgScriptPath, $wgDSMWIP, $wgServerName, $wgScriptPath;
4039 $urlServer = 'http://' . $wgServerName . $wgScriptPath;
4140
42 -
4341 /**** Get status of refresh job, if any ****/
4442 $dbr =& wfGetDB( DB_SLAVE );
4543 $row = $dbr->selectRow( 'job', '*', array( 'job_cmd' => 'DSMWUpdateJob' ), __METHOD__ );
@@ -104,17 +102,10 @@
105103
106104 }
107105
108 -
109106 $wgOut->setPagetitle( "DSMW Settings" );
110107
111108 $output = '<p>This page helps you during installation of Distributed Semantic MediaWiki.</p>';
112109
113 - // creating tables
114 - $output .= '<form name="buildtables" action="" method="POST">' .
115 - '<input type="hidden" name="action" value="updatetables">';
116 - $output .= '<br /><h2>Database: DSMW tables installation</h2>' .
117 - '<p>Distributed Semantic MediaWiki requires some tables to be created in the database.</p>';
118 - $output .= '<input type="submit" value="Initialise tables"/></form>';
119110 // creating properties
120111 $output .= '<form name="properties" action="" method="POST">' .
121112 '<input type="hidden" name="action" value="addProperties">';

Status & tagging log