From 370e83bb0dfd0c70de268c93bf07ad5ee0897192 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 15 Aug 2008 01:29:47 +0200 Subject: Update auf 1.13.0 --- maintenance/archives/patch-ar_parent_id.sql | 3 + maintenance/archives/patch-category.sql | 17 ++ .../archives/patch-filearhive-user-index.sql | 5 + maintenance/archives/patch-hitcounter.sql | 2 +- maintenance/archives/patch-ipb_by_text.sql | 10 ++ maintenance/archives/patch-page_props.sql | 9 + maintenance/archives/patch-profiling-memory.sql | 2 + maintenance/archives/patch-profiling.sql | 3 +- maintenance/archives/patch-protected_titles.sql | 2 +- maintenance/archives/patch-pt_title-encoding.sql | 5 + maintenance/archives/patch-searchindex.sql | 2 +- maintenance/archives/patch-updatelog.sql | 4 + maintenance/archives/patch-user_last_timestamp.sql | 3 + maintenance/archives/populateSha1.php | 8 +- maintenance/archives/rebuildRecentchanges.inc | 6 +- maintenance/archives/upgradeLogging.php | 189 +++++++++++++++++++++ maintenance/archives/upgradeWatchlist.php | 5 +- 17 files changed, 265 insertions(+), 10 deletions(-) create mode 100644 maintenance/archives/patch-ar_parent_id.sql create mode 100644 maintenance/archives/patch-category.sql create mode 100644 maintenance/archives/patch-filearhive-user-index.sql create mode 100644 maintenance/archives/patch-ipb_by_text.sql create mode 100644 maintenance/archives/patch-page_props.sql create mode 100644 maintenance/archives/patch-profiling-memory.sql create mode 100644 maintenance/archives/patch-pt_title-encoding.sql create mode 100644 maintenance/archives/patch-updatelog.sql create mode 100644 maintenance/archives/patch-user_last_timestamp.sql create mode 100644 maintenance/archives/upgradeLogging.php (limited to 'maintenance/archives') diff --git a/maintenance/archives/patch-ar_parent_id.sql b/maintenance/archives/patch-ar_parent_id.sql new file mode 100644 index 00000000..b24cf46c --- /dev/null +++ b/maintenance/archives/patch-ar_parent_id.sql @@ -0,0 +1,3 @@ +-- Adding ar_deleted field for revisiondelete +ALTER TABLE /*$wgDBprefix*/archive + ADD ar_parent_id int unsigned default NULL; diff --git a/maintenance/archives/patch-category.sql b/maintenance/archives/patch-category.sql new file mode 100644 index 00000000..416500c3 --- /dev/null +++ b/maintenance/archives/patch-category.sql @@ -0,0 +1,17 @@ +CREATE TABLE /*$wgDBprefix*/category ( + cat_id int unsigned NOT NULL auto_increment, + + cat_title varchar(255) binary NOT NULL, + + cat_pages int signed NOT NULL default 0, + cat_subcats int signed NOT NULL default 0, + cat_files int signed NOT NULL default 0, + + cat_hidden tinyint(1) unsigned NOT NULL default 0, + + PRIMARY KEY (cat_id), + UNIQUE KEY (cat_title), + + KEY (cat_pages) +) /*$wgDBTableOptions*/; + diff --git a/maintenance/archives/patch-filearhive-user-index.sql b/maintenance/archives/patch-filearhive-user-index.sql new file mode 100644 index 00000000..c79000ad --- /dev/null +++ b/maintenance/archives/patch-filearhive-user-index.sql @@ -0,0 +1,5 @@ +-- Adding index to sort by uploader +ALTER TABLE /*$wgDBprefix*/filearchive + ADD INDEX fa_user_timestamp (fa_user_text,fa_timestamp), + -- Remove useless, incomplete index + DROP INDEX fa_deleted_user; diff --git a/maintenance/archives/patch-hitcounter.sql b/maintenance/archives/patch-hitcounter.sql index 260f717f..50e56e0c 100644 --- a/maintenance/archives/patch-hitcounter.sql +++ b/maintenance/archives/patch-hitcounter.sql @@ -6,4 +6,4 @@ CREATE TABLE /*$wgDBprefix*/hitcounter ( hc_id INTEGER UNSIGNED NOT NULL -) TYPE=HEAP MAX_ROWS=25000; +) ENGINE=HEAP MAX_ROWS=25000; diff --git a/maintenance/archives/patch-ipb_by_text.sql b/maintenance/archives/patch-ipb_by_text.sql new file mode 100644 index 00000000..c0b620d3 --- /dev/null +++ b/maintenance/archives/patch-ipb_by_text.sql @@ -0,0 +1,10 @@ +-- Adding colomn with username of blocker and sets it. +-- Required for crosswiki blocks. + +ALTER TABLE /*$wgDBprefix*/ipblocks + ADD ipb_by_text varchar(255) binary NOT NULL default ''; + +UPDATE /*$wgDBprefix*/ipblocks + JOIN /*$wgDBprefix*/user ON ipb_by = user_id + SET ipb_by_text = user_name + WHERE ipb_by != 0; \ No newline at end of file diff --git a/maintenance/archives/patch-page_props.sql b/maintenance/archives/patch-page_props.sql new file mode 100644 index 00000000..15a35581 --- /dev/null +++ b/maintenance/archives/patch-page_props.sql @@ -0,0 +1,9 @@ +-- Name/value pairs indexed by page_id +CREATE TABLE /*$wgDBprefix*/page_props ( + pp_page int NOT NULL, + pp_propname varbinary(60) NOT NULL, + pp_value blob NOT NULL, + + PRIMARY KEY (pp_page,pp_propname) +) /*$wgDBTableOptions*/; + diff --git a/maintenance/archives/patch-profiling-memory.sql b/maintenance/archives/patch-profiling-memory.sql new file mode 100644 index 00000000..ddd851e1 --- /dev/null +++ b/maintenance/archives/patch-profiling-memory.sql @@ -0,0 +1,2 @@ +ALTER TABLE /*$wgDBprefix*/profiling + ADD pf_memory float NOT NULL default 0; diff --git a/maintenance/archives/patch-profiling.sql b/maintenance/archives/patch-profiling.sql index bafd2b67..e748ca31 100644 --- a/maintenance/archives/patch-profiling.sql +++ b/maintenance/archives/patch-profiling.sql @@ -4,7 +4,8 @@ CREATE TABLE /*$wgDBprefix*/profiling ( pf_count int NOT NULL default 0, pf_time float NOT NULL default 0, + pf_memory float NOT NULL default 0, pf_name varchar(255) NOT NULL default '', pf_server varchar(30) NOT NULL default '', UNIQUE KEY pf_name_server (pf_name, pf_server) -) TYPE=HEAP; +) ENGINE=HEAP; diff --git a/maintenance/archives/patch-protected_titles.sql b/maintenance/archives/patch-protected_titles.sql index 5307cbdd..20b6035d 100644 --- a/maintenance/archives/patch-protected_titles.sql +++ b/maintenance/archives/patch-protected_titles.sql @@ -1,7 +1,7 @@ -- Protected titles - nonexistent pages that have been protected CREATE TABLE /*$wgDBprefix*/protected_titles ( pt_namespace int NOT NULL, - pt_title varchar(255) NOT NULL, + pt_title varchar(255) binary NOT NULL, pt_user int unsigned NOT NULL, pt_reason tinyblob, pt_timestamp binary(14) NOT NULL, diff --git a/maintenance/archives/patch-pt_title-encoding.sql b/maintenance/archives/patch-pt_title-encoding.sql new file mode 100644 index 00000000..b0a23932 --- /dev/null +++ b/maintenance/archives/patch-pt_title-encoding.sql @@ -0,0 +1,5 @@ +-- pt_title was accidentally left with the wrong collation. +-- This might cause failures with JOINs, and could protect the wrong pages +-- with different case variants or unrelated UTF-8 chars. +ALTER TABLE /*$wgDBprefix*/protected_titles + CHANGE COLUMN pt_title pt_title varchar(255) binary NOT NULL; diff --git a/maintenance/archives/patch-searchindex.sql b/maintenance/archives/patch-searchindex.sql index 452c4548..9b635a8f 100644 --- a/maintenance/archives/patch-searchindex.sql +++ b/maintenance/archives/patch-searchindex.sql @@ -19,7 +19,7 @@ CREATE TABLE /*$wgDBprefix*/searchindex ( UNIQUE KEY (si_page) -) TYPE=MyISAM; +) ENGINE=MyISAM; -- Copying data into new table... INSERT INTO /*$wgDBprefix*/searchindex diff --git a/maintenance/archives/patch-updatelog.sql b/maintenance/archives/patch-updatelog.sql new file mode 100644 index 00000000..168ad082 --- /dev/null +++ b/maintenance/archives/patch-updatelog.sql @@ -0,0 +1,4 @@ +CREATE TABLE /*$wgDBprefix*/updatelog ( + ul_key varchar(255) NOT NULL, + PRIMARY KEY (ul_key) +) /*$wgDBTableOptions*/; diff --git a/maintenance/archives/patch-user_last_timestamp.sql b/maintenance/archives/patch-user_last_timestamp.sql new file mode 100644 index 00000000..b6d5f0f3 --- /dev/null +++ b/maintenance/archives/patch-user_last_timestamp.sql @@ -0,0 +1,3 @@ +-- For getting diff since last view +ALTER TABLE /*$wgDBprefix*/user_newtalk + ADD user_last_timestamp binary(14) NOT NULL default ''; diff --git a/maintenance/archives/populateSha1.php b/maintenance/archives/populateSha1.php index 45f29c43..487d3bad 100644 --- a/maintenance/archives/populateSha1.php +++ b/maintenance/archives/populateSha1.php @@ -1,6 +1,10 @@ dbw = wfGetDB( DB_MASTER ); + $logging = $this->dbw->tableName( 'logging' ); + $logging_1_10 = $this->dbw->tableName( 'logging_1_10' ); + $logging_pre_1_10 = $this->dbw->tableName( 'logging_pre_1_10' ); + + if ( $this->dbw->tableExists( 'logging_pre_1_10' ) && !$this->dbw->tableExists( 'logging' ) ) { + # Fix previous aborted run + echo "Cleaning up from previous aborted run\n"; + $this->dbw->query( "RENAME TABLE $logging_pre_1_10 TO $logging", __METHOD__ ); + } + + if ( $this->dbw->tableExists( 'logging_pre_1_10' ) ) { + echo "This script has already been run to completion\n"; + return; + } + + # Create the target table + if ( !$this->dbw->tableExists( 'logging_1_10' ) ) { + global $wgDBTableOptions; + + $sql = <<dbw->query( $sql, __METHOD__ ); + } + + # Synchronise the tables + echo "Doing initial sync...\n"; + $this->sync( 'logging', 'logging_1_10' ); + echo "Sync done\n\n"; + + # Rename the old table away + echo "Renaming the old table to $logging_pre_1_10\n"; + $this->dbw->query( "RENAME TABLE $logging TO $logging_pre_1_10", __METHOD__ ); + + # Copy remaining old rows + # Done before the new table is active so that $copyPos is accurate + echo "Doing final sync...\n"; + $this->sync( 'logging_pre_1_10', 'logging_1_10' ); + + # Move the new table in + echo "Moving the new table in...\n"; + $this->dbw->query( "RENAME TABLE $logging_1_10 TO $logging", __METHOD__ ); + echo "Finished.\n"; + } + + /** + * Copy all rows from $srcTable to $dstTable + */ + function sync( $srcTable, $dstTable ) { + $batchSize = 1000; + $minTs = $this->dbw->selectField( $srcTable, 'MIN(log_timestamp)', false, __METHOD__ ); + $minTsUnix = wfTimestamp( TS_UNIX, $minTs ); + $numRowsCopied = 0; + + while ( true ) { + $maxTs = $this->dbw->selectField( $srcTable, 'MAX(log_timestamp)', false, __METHOD__ ); + $copyPos = $this->dbw->selectField( $dstTable, 'MAX(log_timestamp)', false, __METHOD__ ); + $maxTsUnix = wfTimestamp( TS_UNIX, $maxTs ); + $copyPosUnix = wfTimestamp( TS_UNIX, $copyPos ); + + if ( $copyPos === null ) { + $percent = 0; + } else { + $percent = ( $copyPosUnix - $minTsUnix ) / ( $maxTsUnix - $minTsUnix ) * 100; + } + printf( "%s %.2f%%\n", $copyPos, $percent ); + + # Handle all entries with timestamp equal to $copyPos + if ( $copyPos !== null ) { + $numRowsCopied += $this->copyExactMatch( $srcTable, $dstTable, $copyPos ); + } + + # Now copy a batch of rows + if ( $copyPos === null ) { + $conds = false; + } else { + $conds = array( 'log_timestamp > ' . $this->dbw->addQuotes( $copyPos ) ); + } + $srcRes = $this->dbw->select( $srcTable, '*', $conds, __METHOD__, + array( 'LIMIT' => $batchSize, 'ORDER BY' => 'log_timestamp' ) ); + + if ( ! $srcRes->numRows() ) { + # All done + break; + } + + $batch = array(); + foreach ( $srcRes as $srcRow ) { + $batch[] = (array)$srcRow; + } + $this->dbw->insert( $dstTable, $batch, __METHOD__ ); + $numRowsCopied += count( $batch ); + + wfWaitForSlaves( 5 ); + } + echo "Copied $numRowsCopied rows\n"; + } + + function copyExactMatch( $srcTable, $dstTable, $copyPos ) { + $numRowsCopied = 0; + $srcRes = $this->dbw->select( $srcTable, '*', array( 'log_timestamp' => $copyPos ), __METHOD__ ); + $dstRes = $this->dbw->select( $dstTable, '*', array( 'log_timestamp' => $copyPos ), __METHOD__ ); + + if ( $srcRes->numRows() ) { + $srcRow = $srcRes->fetchObject(); + $srcFields = array_keys( (array)$srcRow ); + $srcRes->seek( 0 ); + $dstRowsSeen = array(); + + # Make a hashtable of rows that already exist in the destination + foreach ( $dstRes as $dstRow ) { + $reducedDstRow = array(); + foreach ( $srcFields as $field ) { + $reducedDstRow[$field] = $dstRow->$field; + } + $hash = md5( serialize( $reducedDstRow ) ); + $dstRowsSeen[$hash] = true; + } + + # Copy all the source rows that aren't already in the destination + foreach ( $srcRes as $srcRow ) { + $hash = md5( serialize( (array)$srcRow ) ); + if ( !isset( $dstRowsSeen[$hash] ) ) { + $this->dbw->insert( $dstTable, (array)$srcRow, __METHOD__ ); + $numRowsCopied++; + } + } + } + return $numRowsCopied; + } +} + +$ul = new UpdateLogging; +$ul->execute(); + diff --git a/maintenance/archives/upgradeWatchlist.php b/maintenance/archives/upgradeWatchlist.php index e62a39ad..9788aa56 100644 --- a/maintenance/archives/upgradeWatchlist.php +++ b/maintenance/archives/upgradeWatchlist.php @@ -1,7 +1,8 @@