r40517 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40516‎ | r40517 | r40518 >
Date:07:14, 6 September 2008
Author:tstarling
Status:old
Tags:
Comment:
Fixed bug 15148, Special:BlockIP broken for PostgreSQL. Backport of r40515.
Modified paths:
  • /branches/REL1_13/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_13/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /branches/REL1_13/phase3/maintenance/postgres/archives/patch-ipb_address_unique.sql (added) (history)
  • /branches/REL1_13/phase3/maintenance/postgres/archives/patch-ipb_address_unique.sql (added) (history)
  • /branches/REL1_13/phase3/maintenance/postgres/tables.sql (modified) (history)
  • /branches/REL1_13/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: branches/REL1_13/phase3/maintenance/postgres/archives/patch-ipb_address_unique.sql
@@ -0,0 +1,2 @@
 2+DROP INDEX IF EXISTS ipb_address;
 3+CREATE UNIQUE INDEX ipb_address_unique ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only);
Property changes on: branches/REL1_13/phase3/maintenance/postgres/archives/patch-ipb_address_unique.sql
___________________________________________________________________
Added: svn:eol-style
14 + native
Index: branches/REL1_13/phase3/maintenance/postgres/tables.sql
@@ -240,9 +240,8 @@
241241 ipb_range_end TEXT,
242242 ipb_deleted SMALLINT NOT NULL DEFAULT 0,
243243 ipb_block_email SMALLINT NOT NULL DEFAULT 0
244 -
245244 );
246 -CREATE INDEX ipb_address ON ipblocks (ipb_address);
 245+CREATE UNIQUE INDEX ipb_address_unique ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only);
247246 CREATE INDEX ipb_user ON ipblocks (ipb_user);
248247 CREATE INDEX ipb_range ON ipblocks (ipb_range_start,ipb_range_end);
249248
Index: branches/REL1_13/phase3/maintenance/updaters.inc
@@ -1663,7 +1663,7 @@
16641664 $wgDatabase->query("CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)");
16651665 }
16661666 else
1667 - echo "... index \"pagelink_unique_index\" aready exists\n";
 1667+ echo "... index \"pagelink_unique_index\" already exists\n";
16681668
16691669 if (pg_fkey_deltype("revision_rev_user_fkey") == 'r') {
16701670 echo "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n";
@@ -1673,6 +1673,14 @@
16741674 dbsource(archive('patch-revision_rev_user_fkey.sql'));
16751675 }
16761676
 1677+ # Fix ipb_address index
 1678+ if (pg_index_exists('ipblocks', 'ipb_address_unique' )) {
 1679+ echo "... have ipb_address_unique\n";
 1680+ } else {
 1681+ echo "Adding ipb_address_unique index\n";
 1682+ dbsource(archive('patch-ipb_address_unique.sql'));
 1683+ }
 1684+
16771685 global $wgExtNewTables, $wgExtPGNewFields, $wgExtNewIndexes;
16781686 # Add missing extension tables
16791687 foreach ( $wgExtNewTables as $nt ) {
Index: branches/REL1_13/phase3/includes/db/DatabasePostgres.php
@@ -72,6 +72,7 @@
7373 var $mInsertId = NULL;
7474 var $mLastResult = NULL;
7575 var $numeric_version = NULL;
 76+ var $mAffectedRows = NULL;
7677
7778 function DatabasePostgres($server = false, $user = false, $password = false, $dbName = false,
7879 $failFunction = false, $flags = 0 )
@@ -546,9 +547,11 @@
547548
548549 function doQuery( $sql ) {
549550 if (function_exists('mb_convert_encoding')) {
550 - return $this->mLastResult=pg_query( $this->mConn , mb_convert_encoding($sql,'UTF-8') );
 551+ $sql = mb_convert_encoding($sql,'UTF-8');
551552 }
552 - return $this->mLastResult=pg_query( $this->mConn , $sql);
 553+ $this->mLastResult = pg_query( $this->mConn, $sql);
 554+ $this->mAffectedRows = NULL; // use pg_affected_rows(mLastResult)
 555+ return $this->mLastResult;
553556 }
554557
555558 function queryIgnore( $sql, $fname = '' ) {
@@ -641,9 +644,12 @@
642645 }
643646
644647 function affectedRows() {
645 - if( !isset( $this->mLastResult ) or ! $this->mLastResult )
 648+ if ( !is_null( $this->mAffectedRows ) ) {
 649+ // Forced result for simulated queries
 650+ return $this->mAffectedRows;
 651+ }
 652+ if( empty( $this->mLastResult ) )
646653 return 0;
647 -
648654 return pg_affected_rows( $this->mLastResult );
649655 }
650656
@@ -809,7 +815,6 @@
810816
811817 $sql .= '(' . $this->makeList( $args ) . ')';
812818 $res = (bool)$this->query( $sql, $fname, $ignore );
813 -
814819 if ( $ignore ) {
815820 $bar = pg_last_error();
816821 if ($bar != false) {
@@ -821,13 +826,15 @@
822827 }
823828 }
824829 }
825 -
826830 if ( $ignore ) {
827831 $olde = error_reporting( $olde );
828832 if ($didbegin) {
829833 $this->commit();
830834 }
831835
 836+ // Set the affected row count for the whole operation
 837+ $this->mAffectedRows = $numrowsinserted;
 838+
832839 // IGNORE always returns true
833840 return true;
834841 }
@@ -1271,6 +1278,8 @@
12721279 function addQuotes( $s ) {
12731280 if ( is_null( $s ) ) {
12741281 return 'NULL';
 1282+ } else if ( is_bool( $s ) ) {
 1283+ return intval( $s );
12751284 } else if ($s instanceof Blob) {
12761285 return "'".$s->fetch($s)."'";
12771286 }
Index: branches/REL1_13/phase3/RELEASE-NOTES
@@ -5,7 +5,7 @@
66
77 == MediaWiki 1.13.1 ==
88
9 -September 4, 2008
 9+September 6, 2008
1010
1111 This is a bugfix release of the Summer 2008 snapshot release of MediaWiki.
1212
@@ -26,6 +26,7 @@
2727 performance for installations without memcached.
2828 * (bug 13770) Fixed DOM module detection for installations with both dom
2929 and domxml.
 30+* (bug 15148) Fixed Special:BlockIP for PostgreSQL
3031 * Localisation updates, Achinese (ace) added.
3132
3233 == Changes since 1.13.0rc2 ==

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r39763Force inserted bools to be ints, per Tim's suggestion on bug 15148....greg13:10, 21 August 2008
r40515Fixed bug 15148, total breakage of Special:BlockIP on PostgreSQL:...tstarling07:05, 6 September 2008