From d9b00fc155c86eaca595871b5b2beca69dd418bd Mon Sep 17 00:00:00 2001 From: Jure Kajzer Date: Fri, 4 Nov 2011 11:35:10 +0000 Subject: [PATCH] * fixed ipblocks.ipb_by_text field, removed default blank not null (fixed install&update) * fixed Block->insert; ipblocks.ipb_id is autoincrement field (should use sequences for compatibility) --- includes/Block.php | 5 ++++- includes/installer/OracleUpdater.php | 11 +++++++++++ .../archives/patch_remove_not_null_empty_defs2.sql | 3 +++ maintenance/oracle/tables.sql | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 maintenance/oracle/archives/patch_remove_not_null_empty_defs2.sql diff --git a/includes/Block.php b/includes/Block.php index 3a2fa6eb96..7aa1bc1dc8 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -426,9 +426,12 @@ class Block { # Don't collide with expired blocks Block::purgeExpired(); + $row = $this->getDatabaseArray(); + $row['ipb_id'] = $dbw->nextSequenceValue("ipblocks_ipb_id_seq"); + $dbw->insert( 'ipblocks', - $this->getDatabaseArray(), + $row, __METHOD__, array( 'IGNORE' ) ); diff --git a/includes/installer/OracleUpdater.php b/includes/installer/OracleUpdater.php index 82031ad2cb..64188cb844 100644 --- a/includes/installer/OracleUpdater.php +++ b/includes/installer/OracleUpdater.php @@ -46,6 +46,7 @@ class OracleUpdater extends DatabaseUpdater { array( 'addTable', 'globalinterwiki', 'patch-globalinterwiki.sql' ), array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1_field.sql' ), array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1_field.sql' ), + array( 'doRemoveNotNullEmptyDefaults2' ), // till 2.0 i guess array( 'doRebuildDuplicateFunction' ), @@ -145,6 +146,16 @@ class OracleUpdater extends DatabaseUpdater { $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false ); $this->output( "ok\n" ); } + protected function doRemoveNotNullEmptyDefaults2() { + $this->output( "Removing not null empty constraints ... " ); + $meta = $this->db->fieldInfo( 'ipblocks' , 'ipb_by_text' ); + if ( $meta->isNullable() ) { + $this->output( "constraints seem to be removed\n" ); + return; + } + $this->applyPatch( 'patch_remove_not_null_empty_defs2.sql', false ); + $this->output( "ok\n" ); + } /** * rebuilding of the function that duplicates tables for tests diff --git a/maintenance/oracle/archives/patch_remove_not_null_empty_defs2.sql b/maintenance/oracle/archives/patch_remove_not_null_empty_defs2.sql new file mode 100644 index 0000000000..f7a38a05f0 --- /dev/null +++ b/maintenance/oracle/archives/patch_remove_not_null_empty_defs2.sql @@ -0,0 +1,3 @@ +define mw_prefix='{$wgDBprefix}'; + +ALTER TABLE &mw_prefix.ipblocks MODIFY ipb_by_text DEFAULT NULL NULL; diff --git a/maintenance/oracle/tables.sql b/maintenance/oracle/tables.sql index c9fc05f404..02488cd35e 100644 --- a/maintenance/oracle/tables.sql +++ b/maintenance/oracle/tables.sql @@ -259,7 +259,7 @@ CREATE TABLE &mw_prefix.ipblocks ( ipb_address VARCHAR2(255) NULL, ipb_user NUMBER DEFAULT 0 NOT NULL, ipb_by NUMBER DEFAULT 0 NOT NULL, - ipb_by_text VARCHAR2(255) NOT NULL, + ipb_by_text VARCHAR2(255) NULL, ipb_reason VARCHAR2(255) NOT NULL, ipb_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL, ipb_auto CHAR(1) DEFAULT '0' NOT NULL, -- 2.20.1