r88154 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88153‎ | r88154 | r88155 >
Date:11:23, 15 May 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fixed pg bug and replaced eregi by preg_match
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php
@@ -61,12 +61,12 @@
6262 * @param DatabaseBase or Database $db
6363 * @param $reportTo Object to report back to.
6464 */
65 - public static function setupTable( $tableName, array $fields, $db, $reportTo = null ) {
66 - $tableName = $db->tableName( $tableName );
 65+ public static function setupTable( $rawTableName, array $fields, $db, $reportTo = null ) {
 66+ $tableName = $db->tableName( $rawTableName );
6767
6868 self::reportProgress( "Checking table $tableName ...\n", $reportTo );
6969
70 - if ( $db->tableExists( $tableName ) === false ) { // create new table
 70+ if ( $db->tableExists( $rawTableName ) === false ) { // create new table
7171 self::reportProgress( " Table not found, now creating...\n", $reportTo );
7272 self::createTable( $tableName, $fields, $db, $reportTo );
7373 self::reportProgress( " ... done.\n", $reportTo );
@@ -163,6 +163,7 @@
164164 global $wgDBtype;
165165
166166 if ( $wgDBtype == 'postgres' ) {
 167+ $tableName = str_replace( '"', '', $tableName );
167168 // Use the data dictionary in postgresql to get an output comparable to DESCRIBE.
168169 $sql = <<<EOT
169170 SELECT
@@ -193,9 +194,9 @@
194195
195196 foreach ( $res as $row ) {
196197 $type = strtoupper( $row->Type );
197 -
 198+
198199 if ( $wgDBtype == 'postgres' ) { // postgresql
199 - if ( eregi( '^nextval\\(.+\\)$', $row->Extra ) ) {
 200+ if ( preg_match( '/^nextval\\(.+\\)/i', $row->Extra ) ) {
200201 $type = 'SERIAL NOT NULL';
201202 } elseif ( $row->Null != 'YES' ) {
202203 $type .= ' NOT NULL';
@@ -220,7 +221,7 @@
221222
222223 $curfields[$row->Field] = $type;
223224 }
224 -
 225+
225226 return $curfields;
226227 }
227228

Status & tagging log