r66915 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66914‎ | r66915 | r66916 >
Date:13:33, 26 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Moved SMWSQLStore2Table to a seperate file to prevent code duplication
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2Table.php (added) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStoreLight.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStoreLight.php
@@ -17,53 +17,6 @@
1818 define( 'SMW_SQL2_SMWINTDEFIW', ':smw-intprop' ); // virtual "interwiki prefix" marking internal (invisible) predefined properties
1919
2020 /**
21 - * Simple data container for storing information about property tables. A
22 - * property table is a DB table that is used to store subject-property-value
23 - * records about data in SMW. Tables mostly differ in the composition of the
24 - * value, but also in whether the property is explicitly named (or fixed),
25 - * and in the way subject pages are referred to.
26 - * @ingroup SMWStore
27 - */
28 -class SMWSQLStore2Table {
29 - /// Name of the table in the DB.
30 - public $name;
31 - /// Array with entries "fieldname => typeid" where the types are as given
32 - /// for SMWSQLStore::getPropertyTables().
33 - public $objectfields;
34 - /// If the table is only for one property, this field holds its name.
35 - /// Empty otherwise. Tables without a fixed property have a column "p_id"
36 - /// for storing the SMW page id of the property.
37 - public $fixedproperty;
38 - /// Strings of the form "field1,...,fieldN" for extra indexes that are to
39 - /// be built for this table. All tables have indexes on subject column(s)
40 - /// and property column (if any).
41 - public $indexes;
42 - /// Boolean that states how subjects are stored. If true, a column "s_id"
43 - /// with an SMW page id is used. If false, two columns "s_title" and
44 - /// "s_namespace" are used. The latter de-normalized form cannot store
45 - /// sortkeys and interwiki prefixes, and is used only for the redirect
46 - /// table. New tables should really keep the default "true" here.
47 - public $idsubject = true;
48 - /// State if a table is reserved for "special properties" (properties that
49 - /// are pre-defined in SMW). This is mainly for optimization, since we do
50 - /// not want to join with the SMW page id table to find the property for an
51 - /// ID when it is likely that the ID is fixed and cached.
52 - public $specpropsonly = false;
53 -
54 - public function __construct( $name, $objectfields, $indexes = array(), $fixedproperty = false ) {
55 - $this->name = $name;
56 - $this->objectfields = $objectfields;
57 - $this->fixedproperty = $fixedproperty;
58 - $this->indexes = $indexes;
59 - }
60 -
61 - public function getFieldSignature() {
62 - return implode( $this->objectfields, '' );
63 - }
64 -}
65 -
66 -
67 -/**
6821 * Storage access class for using the standard MediaWiki SQL database
6922 * for keeping semantic data. This is a lightweight version of SMW's standard
7023 * storage implementation, providing only basic data storage and retrieval but
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2Table.php
@@ -0,0 +1,98 @@
 2+<?php
 3+
 4+/**
 5+ * File holding the SMWSQLStore2Table class
 6+ *
 7+ * @author Markus Krötzsch
 8+ * @author Jeroen De Dauw
 9+ *
 10+ * @file
 11+ * @ingroup SMWStore
 12+ */
 13+
 14+/**
 15+ * Simple data container for storing information about property tables. A
 16+ * property table is a DB table that is used to store subject-property-value
 17+ * records about data in SMW. Tables mostly differ in the composition of the
 18+ * value, but also in whether the property is explicitly named (or fixed),
 19+ * and in the way subject pages are referred to.
 20+ * @ingroup SMWStore
 21+ */
 22+class SMWSQLStore2Table {
 23+ /**
 24+ * Name of the table in the DB.
 25+ *
 26+ * @var string
 27+ */
 28+ public $name;
 29+
 30+ /**
 31+ * Array with entries "fieldname => typeid" where the types are as given
 32+ * for SMWSQLStore::getPropertyTables().
 33+ *
 34+ * @var array
 35+ */
 36+ public $objectfields;
 37+
 38+ /**
 39+ * If the table is only for one property, this field holds its name.
 40+ * Empty otherwise. Tables without a fixed property have a column "p_id"
 41+ * for storing the SMW page id of the property.
 42+ *
 43+ * @var mixed String or false
 44+ */
 45+ public $fixedproperty;
 46+
 47+ /**
 48+ * Strings of the form "field1,...,fieldN" for extra indexes that are to
 49+ * be built for this table. All tables have indexes on subject column(s)
 50+ * and property column (if any).
 51+ *
 52+ * @var array of string
 53+ */
 54+ public $indexes;
 55+
 56+ /**
 57+ * Boolean that states how subjects are stored. If true, a column "s_id"
 58+ * with an SMW page id is used. If false, two columns "s_title" and
 59+ * "s_namespace" are used. The latter de-normalized form cannot store
 60+ * sortkeys and interwiki prefixes, and is used only for the redirect
 61+ * table. New tables should really keep the default "true" here.
 62+ *
 63+ * @var boolean
 64+ */
 65+ public $idsubject = true;
 66+
 67+ /**
 68+ * State if a table is reserved for "special properties" (properties that
 69+ * are pre-defined in SMW). This is mainly for optimization, since we do
 70+ * not want to join with the SMW page id table to find the property for an
 71+ * ID when it is likely that the ID is fixed and cached.
 72+ *
 73+ * @var unknown_type
 74+ */
 75+ public $specpropsonly = false;
 76+
 77+ /**
 78+ * Constructor.
 79+ *
 80+ * @param string $name
 81+ * @param array $objectFields
 82+ * @param array $indexes
 83+ * @param mixed $fixedProperty string or false
 84+ */
 85+ public function __construct( $name, array $objectFields, array $indexes = array(), $fixedProperty = false ) {
 86+ $this->name = $name;
 87+ $this->objectfields = $objectFields;
 88+ $this->fixedproperty = $fixedProperty;
 89+ $this->indexes = $indexes;
 90+ }
 91+
 92+ /**
 93+ * @return string
 94+ */
 95+ public function getFieldSignature() {
 96+ // TODO: this was implode( $this->objectfields, '' ), which might indicate some error where this method is called.
 97+ return implode( '', $this->objectfields );
 98+ }
 99+}
\ No newline at end of file
Property changes on: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2Table.php
___________________________________________________________________
Name: svn:eol-style
1100 + native
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -1,4 +1,5 @@
22 <?php
 3+
34 /**
45 * New SQL implementation of SMW's storage abstraction layer.
56 *
@@ -17,93 +18,6 @@
1819 define( 'SMW_SQL2_SMWINTDEFIW', ':smw-intprop' ); // virtual "interwiki prefix" marking internal (invisible) predefined properties
1920
2021 /**
21 - * Simple data container for storing information about property tables. A
22 - * property table is a DB table that is used to store subject-property-value
23 - * records about data in SMW. Tables mostly differ in the composition of the
24 - * value, but also in whether the property is explicitly named (or fixed),
25 - * and in the way subject pages are referred to.
26 - * @ingroup SMWStore
27 - */
28 -class SMWSQLStore2Table {
29 - /**
30 - * Name of the table in the DB.
31 - *
32 - * @var string
33 - */
34 - public $name;
35 -
36 - /**
37 - * Array with entries "fieldname => typeid" where the types are as given
38 - * for SMWSQLStore::getPropertyTables().
39 - *
40 - * @var array
41 - */
42 - public $objectfields;
43 -
44 - /**
45 - * If the table is only for one property, this field holds its name.
46 - * Empty otherwise. Tables without a fixed property have a column "p_id"
47 - * for storing the SMW page id of the property.
48 - *
49 - * @var mixed String or false
50 - */
51 - public $fixedproperty;
52 -
53 - /**
54 - * Strings of the form "field1,...,fieldN" for extra indexes that are to
55 - * be built for this table. All tables have indexes on subject column(s)
56 - * and property column (if any).
57 - *
58 - * @var array of string
59 - */
60 - public $indexes;
61 -
62 - /**
63 - * Boolean that states how subjects are stored. If true, a column "s_id"
64 - * with an SMW page id is used. If false, two columns "s_title" and
65 - * "s_namespace" are used. The latter de-normalized form cannot store
66 - * sortkeys and interwiki prefixes, and is used only for the redirect
67 - * table. New tables should really keep the default "true" here.
68 - *
69 - * @var boolean
70 - */
71 - public $idsubject = true;
72 -
73 - /**
74 - * State if a table is reserved for "special properties" (properties that
75 - * are pre-defined in SMW). This is mainly for optimization, since we do
76 - * not want to join with the SMW page id table to find the property for an
77 - * ID when it is likely that the ID is fixed and cached.
78 - *
79 - * @var unknown_type
80 - */
81 - public $specpropsonly = false;
82 -
83 - /**
84 - * Constructor.
85 - *
86 - * @param string $name
87 - * @param array $objectFields
88 - * @param array $indexes
89 - * @param mixed $fixedProperty string or false
90 - */
91 - public function __construct( $name, array $objectFields, array $indexes = array(), $fixedProperty = false ) {
92 - $this->name = $name;
93 - $this->objectfields = $objectFields;
94 - $this->fixedproperty = $fixedProperty;
95 - $this->indexes = $indexes;
96 - }
97 -
98 - /**
99 - * @return string
100 - */
101 - public function getFieldSignature() {
102 - // TODO: this was implode( $this->objectfields, '' ), which might indicate some error where this method is called.
103 - return implode( '', $this->objectfields );
104 - }
105 -}
106 -
107 -/**
10822 * Storage access class for using the standard MediaWiki SQL database
10923 * for keeping semantic data.
11024 *
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php
@@ -134,6 +134,7 @@
135135 // $wgAutoloadClasses['SMWRecordFieldDescription'] = $smwgIP . 'includes/SMW_Record_Descriptions.php';
136136 // $wgAutoloadClasses['SMWSQLStore2'] = $smwgIP . 'includes/storage/SMW_SQLStore2.php';
137137 $wgAutoloadClasses['SMWSQLStoreLight'] = $smwgIP . 'includes/storage/SMW_SQLStoreLight.php';
 138+ $wgAutoloadClasses['SMWSQLStore2Table'] = $smwgIP . 'includes/storage/SMW_SQLStore2Table.php';
138139 $wgAutoloadClasses['SMWSQLHelpers'] = $smwgIP . 'includes/storage/SMW_SQLHelpers.php';
139140 // Do not autoload RAPStore, since some special pages load all autoloaded classes, which causes
140141 // troubles with RAP store if RAP is not installed (require_once fails).
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php
@@ -112,6 +112,7 @@
113113 $wgAutoloadClasses['SMWRecordDescription'] = $smwgIP . 'includes/SMW_Record_Descriptions.php';
114114 $wgAutoloadClasses['SMWRecordFieldDescription'] = $smwgIP . 'includes/SMW_Record_Descriptions.php';
115115 $wgAutoloadClasses['SMWSQLStore2'] = $smwgIP . 'includes/storage/SMW_SQLStore2.php';
 116+ $wgAutoloadClasses['SMWSQLStore2Table'] = $smwgIP . 'includes/storage/SMW_SQLStore2Table.php';
116117 $wgAutoloadClasses['SMWSQLHelpers'] = $smwgIP . 'includes/storage/SMW_SQLHelpers.php';
117118 // Do not autoload RAPStore, since some special pages load all autoloaded classes, which causes
118119 // troubles with RAP store if RAP is not installed (require_once fails).

Status & tagging log