aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/archives
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/archives')
-rw-r--r--maintenance/archives/importTests.php2
-rw-r--r--maintenance/archives/moveCustomMessages.inc149
-rw-r--r--maintenance/archives/moveCustomMessages.php128
-rw-r--r--maintenance/archives/patch-linkscc-1.3.sql6
-rw-r--r--maintenance/archives/patch-profiling.sql10
-rw-r--r--maintenance/archives/patch-rc_ip.sql7
6 files changed, 178 insertions, 124 deletions
diff --git a/maintenance/archives/importTests.php b/maintenance/archives/importTests.php
index ef751a759eaf..6e283790dbaa 100644
--- a/maintenance/archives/importTests.php
+++ b/maintenance/archives/importTests.php
@@ -26,7 +26,7 @@ $testingonly = true;
setlocale( LC_ALL, "C" );
-include( "importUseModWiki.php" );
+include_once( "importUseModWiki.php" );
$wgRootDirectory = "./testconvert";
runTests();
diff --git a/maintenance/archives/moveCustomMessages.inc b/maintenance/archives/moveCustomMessages.inc
new file mode 100644
index 000000000000..5438194690a1
--- /dev/null
+++ b/maintenance/archives/moveCustomMessages.inc
@@ -0,0 +1,149 @@
+<?php
+
+function isTemplateInitialised() {
+ $sql = "SELECT 1 FROM cur WHERE cur_namespace=" . NS_TEMPLATE . " LIMIT 1";
+ $res = wfQuery( $sql, DB_READ );
+ return wfNumRows( $res ) ? true : false;
+}
+
+function moveCustomMessages( $phase ) {
+ global $wgUser, $wgAllMessagesEn, $wgDeferredUpdateList, $wgLang;
+ global $targets, $template, $replaceCount;
+
+ $wgUser = new User;
+ $wgUser->setLoaded( true ); # Don't load from DB
+ $wgUser->setName( "Template namespace initialisation script" );
+ $wgUser->addRight( "bot" );
+
+ wfIgnoreSQLErrors( true );
+
+ # Compose DB key array
+ $dbkeys = array();
+
+ foreach ( $wgAllMessagesEn as $key => $enValue ) {
+ $title = Title::newFromText( $key );
+ $dbkeys[$title->getDBkey()] = 1;
+ }
+
+ $sql = "SELECT cur_id, cur_title FROM cur WHERE cur_namespace= " . NS_MEDIAWIKI;
+ $res = wfQuery( $sql, DB_READ );
+
+ # Compile target array
+ $targets = array();
+ while ( $row = wfFetchObject( $res ) ) {
+ if ( !array_key_exists( $row->cur_title, $dbkeys ) ) {
+ $targets[$row->cur_title] = 1;
+ }
+ }
+ wfFreeResult( $res );
+
+ # Create redirects from destination to source
+ if ( $phase == 0 || $phase == 1 ) {
+ print "Creating redirects\n";
+ foreach ( $targets as $partial => $dummy ) {
+ print "$partial...";
+ $nt = Title::makeTitle( NS_TEMPLATE, $partial );
+ $ot = Title::makeTitle( NS_MEDIAWIKI, $partial );
+
+ if ( $nt->createRedirect( $ot, "" ) ) {
+ print "redirected\n";
+ } else {
+ print "not redirected\n";
+ }
+ }
+ if ( $phase == 0 ) {
+ print "\nRedirects created. Update live script files now.\nPress ENTER to continue.\n\n";
+ readconsole();
+ }
+ }
+
+ # Move pages
+ if ( $phase == 0 || $phase == 2 ) {
+ print "\nMoving pages...\n";
+ foreach ( $targets as $partial => $dummy ) {
+ wfQuery( "BEGIN", DB_WRITE );
+ $ot = Title::makeTitle( NS_MEDIAWIKI, $partial );
+ $nt = Title::makeTitle( NS_TEMPLATE, $partial );
+ print "$partial...";
+
+ if ( $ot->moveNoAuth( $nt ) === true ) {
+ print "moved\n";
+ } else {
+ print "not moved\n";
+ }
+ # Do deferred updates
+ while ( count( $wgDeferredUpdateList ) ) {
+ $up = array_pop( $wgDeferredUpdateList );
+ $up->doUpdate();
+ }
+ wfQuery( "COMMIT", DB_WRITE );
+ }
+ }
+
+ # Convert text
+ if ( $phase == 0 || $phase == 3 ) {
+ print "\nConverting text...\n";
+
+ $parser = new Parser;
+ $options = ParserOptions::newFromUser( $wgUser );
+ $completedTitles = array();
+ $titleChars = Title::legalChars();
+ $mediaWiki = $wgLang->getNsText( NS_MEDIAWIKI );
+ $template = $wgLang->getNsText( NS_TEMPLATE );
+ $linkRegex = "/\[\[$mediaWiki:([$titleChars]*?)\]\]/";
+ $msgRegex = "/{{msg:([$titleChars]*?)}}/";
+
+ foreach ( $targets as $partial => $dummy ) {
+ $dest = Title::makeTitle( NS_MEDIAWIKI, $partial );
+ $linksTo = $dest->getLinksTo();
+ foreach( $linksTo as $source ) {
+ wfQuery( "BEGIN", DB_WRITE );
+ $pdbk = $source->getPrefixedDBkey();
+ if ( !array_key_exists( $pdbk, $completedTitles ) ) {
+ $completedTitles[$pdbk] = 1;
+ $id = $source->getArticleID();
+ $row = wfGetArray( 'cur', array( 'cur_text' ),
+ array( 'cur_id' => $source->getArticleID() ) );
+ $parser->startExternalParse( $source, $options, OT_WIKI );
+ $text = $parser->strip( $row->cur_text, $stripState, false );
+ # {{msg}} -> {{}}
+ $text = preg_replace( $msgRegex, "{{\$1}}", $text );
+ # [[MediaWiki:]] -> [[Template:]]
+ $text = preg_replace_callback( $linkRegex, "wfReplaceMediaWiki", $text );
+ $text = $parser->unstrip( $text, $stripState );
+ $text = $parser->unstripNoWiki( $text, $stripState );
+ if ( $text != $row->cur_text ) {
+ print "$pdbk\n";
+ $art = new Article( $source );
+ $art->updateArticle( $text, "", false, false );
+ # Do deferred updates
+ while ( count( $wgDeferredUpdateList ) ) {
+ $up = array_pop( $wgDeferredUpdateList );
+ $up->doUpdate();
+ }
+ } else {
+ print "($pdbk)\n";
+ }
+ }
+ wfQuery( "COMMIT", DB_WRITE );
+ }
+ }
+ }
+}
+
+
+#--------------------------------------------------------------------------------------------------------------
+function wfReplaceMediaWiki( $m ) {
+ global $targets, $template, $replaceCount;
+ $title = Title::newFromText( $m[1] );
+ $partial = $title->getDBkey();
+
+ if ( array_key_exists( $partial, $targets ) ) {
+ $text = "[[$template:{$m[1]}]]";
+ } else {
+ $text = $m[0];
+ }
+ return $text;
+}
+
+?>
diff --git a/maintenance/archives/moveCustomMessages.php b/maintenance/archives/moveCustomMessages.php
index bcd49743501c..454bc830781d 100644
--- a/maintenance/archives/moveCustomMessages.php
+++ b/maintenance/archives/moveCustomMessages.php
@@ -8,132 +8,14 @@
# 3. Convert the text to suit the new syntax
chdir( ".." );
-require_once( "commandLine.inc" );
+require_once( "liveCmdLine.inc" );
+require_once( "moveCustomMessages.inc" );
$phase = 0;
-if ( is_numeric( @$argv[2] ) && $argv[2] > 0) {
- $phase = intval($argv[2]);
+if ( is_numeric( @$argv[3] ) && $argv[3] > 0) {
+ $phase = intval($argv[3]);
}
-$wgUser = new User;
-$wgUser->setLoaded( true ); # Don't load from DB
-$wgUser->setName( "Template namespace initialisation script" );
-$wgUser->addRight( "bot" );
+moveCustomMessages( $phase );
-# Compose DB key array
-global $wgAllMessagesEn;
-$dbkeys = array();
-
-foreach ( $wgAllMessagesEn as $key => $enValue ) {
- $title = Title::newFromText( $key );
- $dbkeys[$title->getDBkey()] = 1;
-}
-
-$sql = "SELECT cur_id, cur_title FROM cur WHERE cur_namespace= " . NS_MEDIAWIKI;
-$res = wfQuery( $sql, DB_READ );
-
-# Compile target array
-$targets = array();
-while ( $row = wfFetchObject( $res ) ) {
- if ( !array_key_exists( $row->cur_title, $dbkeys ) ) {
- $targets[$row->cur_title] = 1;
- }
-}
-wfFreeResult( $res );
-
-# Create redirects from destination to source
-if ( $phase == 0 || $phase == 1 ) {
- foreach ( $targets as $partial => $dummy ) {
- print "$partial...";
- $nt = Title::makeTitle( NS_TEMPLATE, $partial );
- $ot = Title::makeTitle( NS_MEDIAWIKI, $partial );
-
- if ( $nt->createRedirect( $ot, "" ) ) {
- print "redirected\n";
- } else {
- print "not redirected\n";
- }
- }
- if ( $phase == 0 ) {
- print "\nRedirects created. Update live script files now.\nPress ENTER to continue.\n\n";
- readconsole();
- }
-}
-
-# Move pages
-if ( $phase == 0 || $phase == 2 ) {
- print "\n";
- foreach ( $targets as $partial => $dummy ) {
- $ot = Title::makeTitle( NS_MEDIAWIKI, $partial );
- $nt = Title::makeTitle( NS_TEMPLATE, $partial );
- print "$partial...";
-
- if ( $ot->moveNoAuth( $nt ) === true ) {
- print "moved\n";
- } else {
- print "not moved\n";
- }
- # Do deferred updates
- while ( count( $wgDeferredUpdateList ) ) {
- $up = array_pop( $wgDeferredUpdateList );
- $up->doUpdate();
- }
- }
-}
-
-# Convert text
-if ( $phase == 0 || $phase == 3 ) {
- print "\n";
-
- $parser = new Parser;
- $options = ParserOptions::newFromUser( $wgUser );
- $completedTitles = array();
- $titleChars = Title::legalChars();
- $mediaWiki = $wgLang->getNsText( NS_MEDIAWIKI );
- $template = $wgLang->getNsText( NS_TEMPLATE );
- $linkRegex = "/\[\[$mediaWiki:([$titleChars]*?)\]\]/";
- $msgRegex = "/{{msg:([$titleChars]*?)}}/";
-
- foreach ( $targets as $partial => $dummy ) {
- $dest = Title::makeTitle( NS_TEMPLATE, $partial );
- $linksTo = $dest->getLinksTo();
- foreach( $linksTo as $source ) {
- $pdbk = $source->getPrefixedDBkey();
- print "$pdbk...";
- if ( !array_key_exists( $pdbk, $completedTitles ) ) {
- $completedTitles[$pdbk] = 1;
- $id = $source->getArticleID();
- $row = wfGetArray( 'cur', array( 'cur_text' ),
- array( 'cur_id' => $source->getArticleID() ) );
- $parser->startExternalParse( $source, $options, OT_WIKI );
- $text = $parser->strip( $row->cur_text, $stripState, false );
- # {{msg}} -> {{}}
- $text = preg_replace( $msgRegex, "{{\$1}}", $text );
- # [[MediaWiki:]] -> [[Template:]]
- $text = preg_replace_callback( $linkRegex, "wfReplaceMediaWiki", $text );
- $text = $parser->unstrip( $text, $stripState );
- if ( $text != $row->cur_text ) {
- wfUpdateArray( 'cur', array( 'cur_text' => $text ), array( 'cur_id' => $id ) );
- print "modified\n";
- } else {
- print "not modified\n";
- }
- }
- }
- }
-}
-
-#--------------------------------------------------------------------------------------------------------------
-function wfReplaceMediaWiki( $m ) {
- global $targets, $template, $replaceCount;
- $title = Title::newFromText( $m[1] );
- $partial = $title->getDBkey();
-
- if ( array_key_exists( $partial, $targets ) ) {
- $text = "[[$template:{$m[1]}]]";
- } else {
- $text = $m[0];
- }
- return $text;
-}
?>
diff --git a/maintenance/archives/patch-linkscc-1.3.sql b/maintenance/archives/patch-linkscc-1.3.sql
new file mode 100644
index 000000000000..6f9e6313532e
--- /dev/null
+++ b/maintenance/archives/patch-linkscc-1.3.sql
@@ -0,0 +1,6 @@
+--
+-- linkscc table used to cache link lists in easier to digest form.
+-- New schema for 1.3 - removes old lcc_title column.
+-- May 2004
+--
+ALTER TABLE linkscc DROP COLUMN lcc_title; \ No newline at end of file
diff --git a/maintenance/archives/patch-profiling.sql b/maintenance/archives/patch-profiling.sql
new file mode 100644
index 000000000000..ea9974ce3f76
--- /dev/null
+++ b/maintenance/archives/patch-profiling.sql
@@ -0,0 +1,10 @@
+-- profiling table
+-- This is optional
+
+CREATE TABLE profiling (
+ pf_count integer not null default 0,
+ pf_time float not null default 0,
+ pf_name varchar(255) not null default '',
+ UNIQUE KEY pf_name (pf_name)
+);
+
diff --git a/maintenance/archives/patch-rc_ip.sql b/maintenance/archives/patch-rc_ip.sql
new file mode 100644
index 000000000000..6106d93380f1
--- /dev/null
+++ b/maintenance/archives/patch-rc_ip.sql
@@ -0,0 +1,7 @@
+-- Adding the rc_ip field for logging of IP addresses in recentchanges
+
+ALTER TABLE recentchanges
+ ADD rc_ip char(15) NOT NULL default '',
+ ADD INDEX rc_ip (rc_ip);
+
+