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/Doxyfile | 12 +- maintenance/FiveUpgrade.inc | 24 +- maintenance/Makefile | 13 +- maintenance/README | 25 +- maintenance/addwiki.php | 58 +- 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 +- maintenance/attachLatest.php | 3 +- maintenance/attribute.php | 4 +- maintenance/backup.inc | 13 +- maintenance/backupPrefetch.inc | 3 +- maintenance/benchmarkPurge.php | 4 +- maintenance/changePassword.php | 21 +- maintenance/checkAutoLoader.php | 22 + maintenance/checkUsernames.php | 8 + maintenance/cleanupCaps.php | 8 +- maintenance/cleanupDupes.inc | 5 +- maintenance/cleanupImages.php | 6 +- maintenance/cleanupSpam.php | 6 +- maintenance/cleanupTable.inc | 5 +- maintenance/cleanupTitles.php | 8 +- maintenance/cleanupWatchlist.php | 6 +- maintenance/clear_interwiki_cache.php | 4 +- maintenance/clear_stats.php | 7 + maintenance/commandLine.inc | 66 +-- maintenance/convertLinks.inc | 7 +- maintenance/convertLinks.php | 5 +- maintenance/counter.php | 7 + maintenance/createAndPromote.php | 3 +- maintenance/deleteArchivedFiles.inc | 22 +- maintenance/deleteArchivedFiles.php | 3 +- maintenance/deleteArchivedRevisions.inc | 5 +- maintenance/deleteArchivedRevisions.php | 5 +- maintenance/deleteBatch.php | 19 +- maintenance/deleteDefaultMessages.php | 3 + maintenance/deleteImageMemcached.php | 14 +- maintenance/deleteOldRevisions.inc | 6 +- maintenance/deleteOldRevisions.php | 3 +- maintenance/deleteOrphanedRevisions.inc.php | 3 +- maintenance/deleteOrphanedRevisions.php | 3 +- maintenance/deleteRevision.php | 7 + maintenance/dumpBackup.php | 9 +- maintenance/dumpInterwiki.inc | 13 +- maintenance/dumpInterwiki.php | 4 +- maintenance/dumpLinks.php | 3 +- maintenance/dumpSisterSites.php | 3 +- maintenance/dumpTextPass.php | 13 +- maintenance/dumpUploads.php | 4 + maintenance/edit.php | 4 + maintenance/eval.php | 34 +- maintenance/fetchText.php | 11 +- maintenance/findhooks.php | 62 ++- maintenance/fixSlaveDesync.php | 10 +- maintenance/fixTimestamps.php | 4 +- maintenance/fixUserRegistration.php | 3 + maintenance/fuzz-tester.php | 5 +- maintenance/generateSitemap.php | 47 +- maintenance/getLagTimes.php | 12 +- maintenance/getSlaveServer.php | 19 +- maintenance/importDump.php | 33 +- maintenance/importImages.inc.php | 3 +- maintenance/importImages.php | 3 +- maintenance/importLogs.inc | 7 +- maintenance/importLogs.php | 3 +- maintenance/importTextFile.php | 3 +- maintenance/importUseModWiki.php | 3 +- maintenance/initEditCount.php | 4 + maintenance/initStats.inc | 6 +- maintenance/initStats.php | 3 +- maintenance/installExtension.php | 58 +- maintenance/interwiki.sql | 117 +---- maintenance/language/StatOutputs.php | 2 + maintenance/language/alltrans.php | 3 +- maintenance/language/checkExtensions.php | 268 +--------- maintenance/language/checkLanguage.inc | 476 +++++++++++++++++ maintenance/language/checkLanguage.php | 306 +---------- maintenance/language/date-formats.php | 4 + maintenance/language/diffLanguage.php | 3 +- maintenance/language/digit2html.php | 5 + maintenance/language/dumpMessages.php | 3 +- maintenance/language/function-list.php | 4 + maintenance/language/lang2po.php | 3 + maintenance/language/langmemusage.php | 3 + maintenance/language/languages.inc | 47 +- maintenance/language/messageTypes.inc | 83 ++- maintenance/language/messages.inc | 430 +++++++++++---- maintenance/language/rebuildLanguage.php | 23 +- maintenance/language/transstat.php | 3 +- maintenance/language/validate.php | 4 + maintenance/language/writeMessagesArray.inc | 50 +- maintenance/mcc.php | 3 +- maintenance/mctest.php | 9 +- maintenance/moveBatch.php | 3 +- maintenance/mssql/README | 78 +++ maintenance/mssql/tables.sql | 395 ++++++++++++++ maintenance/mwdocgen.php | 158 +++--- maintenance/namespace2sql.php | 10 +- maintenance/namespaceDupes.php | 5 + maintenance/nextJobDB.php | 18 +- maintenance/nukeNS.php | 3 +- maintenance/nukePage.inc | 3 +- maintenance/nukePage.php | 3 +- maintenance/orphans.php | 3 +- maintenance/ourusers.php | 15 +- maintenance/parserTests.inc | 582 ++++++++++++--------- maintenance/parserTests.php | 3 +- maintenance/parserTests.txt | 179 +++++-- maintenance/parserTestsParserHook.php | 3 +- maintenance/parserTestsParserTime.php | 3 +- maintenance/parserTestsStaticParserHook.php | 3 +- maintenance/patchSql.php | 36 ++ maintenance/populateCategory.inc | 85 +++ maintenance/populateCategory.php | 52 ++ maintenance/populateParentId.inc | 83 +++ maintenance/populateParentId.php | 18 + maintenance/postgres/archives/patch-category.sql | 15 + maintenance/postgres/archives/patch-page_props.sql | 9 + .../postgres/archives/patch-tsearch2funcs.sql | 29 + maintenance/postgres/archives/patch-updatelog.sql | 4 + maintenance/postgres/compare_schemas.pl | 130 +++-- maintenance/postgres/mediawiki_mysql2postgres.pl | 8 +- maintenance/postgres/tables.sql | 45 +- maintenance/preprocessorFuzzTest.php | 4 + maintenance/purgeList.php | 4 +- maintenance/purgeOldText.inc | 5 +- maintenance/purgeOldText.php | 3 +- maintenance/reassignEdits.inc.php | 5 +- maintenance/reassignEdits.php | 3 +- maintenance/rebuildImages.php | 3 +- maintenance/rebuildInterwiki.inc | 13 +- maintenance/rebuildInterwiki.php | 4 +- maintenance/rebuildall.php | 17 +- maintenance/rebuildmessages.php | 11 +- maintenance/rebuildrecentchanges.inc | 96 +++- maintenance/rebuildrecentchanges.php | 3 +- maintenance/rebuildtextindex.inc | 5 +- maintenance/rebuildtextindex.php | 7 +- maintenance/refreshImageCount.php | 10 +- maintenance/refreshLinks.inc | 48 +- maintenance/refreshLinks.php | 26 +- maintenance/removeUnusedAccounts.inc | 6 +- maintenance/removeUnusedAccounts.php | 4 +- maintenance/renamewiki.php | 7 +- maintenance/renderDump.php | 3 +- maintenance/runJobs.php | 14 +- maintenance/showJobs.php | 4 + maintenance/showStats.php | 2 + maintenance/sql.php | 6 +- maintenance/sqlite/tables.sql | 340 ++++++++++++ maintenance/stats.php | 7 + maintenance/storage/blobs.sql | 2 +- maintenance/storage/checkStorage.php | 10 +- maintenance/storage/compressOld.inc | 4 +- maintenance/storage/compressOld.php | 10 +- maintenance/storage/dumpRev.php | 4 + maintenance/storage/moveToExternal.php | 8 +- maintenance/storage/resolveStubs.php | 4 + maintenance/tables.sql | 76 ++- maintenance/undelete.php | 6 + maintenance/update.php | 5 +- maintenance/updateArticleCount.inc.php | 4 +- maintenance/updateArticleCount.php | 4 +- maintenance/updateRestrictions.php | 13 +- maintenance/updateSearchIndex.inc | 5 +- maintenance/updateSearchIndex.php | 3 +- maintenance/updateSpecialPages.php | 13 +- maintenance/updaters.inc | 175 +++++-- maintenance/upgrade1_5.php | 25 +- maintenance/userDupes.inc | 39 +- maintenance/userOptions.inc | 9 +- maintenance/userOptions.php | 2 + maintenance/waitForSlave.php | 13 +- maintenance/wikipedia-interwiki.sql | 64 ++- maintenance/wiktionary-interwiki.sql | 27 +- 189 files changed, 4411 insertions(+), 1711 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 create mode 100644 maintenance/checkAutoLoader.php create mode 100644 maintenance/mssql/README create mode 100644 maintenance/mssql/tables.sql create mode 100644 maintenance/patchSql.php create mode 100644 maintenance/populateCategory.inc create mode 100644 maintenance/populateCategory.php create mode 100644 maintenance/populateParentId.inc create mode 100644 maintenance/populateParentId.php create mode 100644 maintenance/postgres/archives/patch-category.sql create mode 100644 maintenance/postgres/archives/patch-page_props.sql create mode 100644 maintenance/postgres/archives/patch-tsearch2funcs.sql create mode 100644 maintenance/postgres/archives/patch-updatelog.sql create mode 100644 maintenance/sqlite/tables.sql (limited to 'maintenance') diff --git a/maintenance/Doxyfile b/maintenance/Doxyfile index 6c9811d0..df67ba60 100644 --- a/maintenance/Doxyfile +++ b/maintenance/Doxyfile @@ -1,16 +1,18 @@ -# Doxyfile 1.4.6 +# Doxyfile 1.5.1 # # Some placeholders have been added for MediaWiki usage: # {{OUTPUT_DIRECTORY}} +# {{CURRENT_VERSION}} # {{STRIP_FROM_PATH}} +# {{SVNSTAT}} # {{INPUT}} #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- PROJECT_NAME = MediaWiki -PROJECT_NUMBER = trunk +PROJECT_NUMBER = {{CURRENT_VERSION}} OUTPUT_DIRECTORY = {{OUTPUT_DIRECTORY}} CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English @@ -39,7 +41,7 @@ MULTILINE_CPP_IS_BRIEF = NO DETAILS_AT_TOP = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 8 +TAB_SIZE = 4 ALIASES = OPTIMIZE_OUTPUT_FOR_C = NO OPTIMIZE_OUTPUT_JAVA = NO @@ -74,7 +76,7 @@ ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES SHOW_DIRECTORIES = NO -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = {{SVNSTAT}} #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- @@ -132,7 +134,7 @@ FILE_PATTERNS = *.c \ *.PY RECURSIVE = YES EXCLUDE = -EXCLUDE_SYMLINKS = NO +EXCLUDE_SYMLINKS = YES EXCLUDE_PATTERNS = LocalSettings.php AdminSettings.php EXAMPLE_PATH = EXAMPLE_PATTERNS = * diff --git a/maintenance/FiveUpgrade.inc b/maintenance/FiveUpgrade.inc index 9a882bc6..7ae8f5d0 100644 --- a/maintenance/FiveUpgrade.inc +++ b/maintenance/FiveUpgrade.inc @@ -1,4 +1,8 @@ conversionTables = $this->prepareWindows1252(); @@ -61,9 +68,10 @@ class FiveUpgrade { * @access private */ function &newConnection() { - global $wgDBadminuser, $wgDBadminpassword; + global $wgDBadminuser, $wgDBadminpassword, $wgDBtype; global $wgDBserver, $wgDBname; - $db = new Database( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); + $dbclass = 'Database' . ucfirst( $wgDBtype ) ; + $db = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); return $db; } @@ -75,11 +83,15 @@ class FiveUpgrade { * @access private */ function &streamConnection() { + global $wgDBtype; + $timeout = 3600 * 24; $db =& $this->newConnection(); $db->bufferResults( false ); - $db->query( "SET net_read_timeout=$timeout" ); - $db->query( "SET net_write_timeout=$timeout" ); + if ($wgDBtype == 'mysql') { + $db->query( "SET net_read_timeout=$timeout" ); + $db->query( "SET net_write_timeout=$timeout" ); + } return $db; } @@ -702,7 +714,7 @@ END; 'major' => '', 'minor' => '' ); - $magic =& wfGetMimeMagic(); + $magic = MimeMagic::singleton(); $mime = $magic->guessMimeType( $filename, true ); list( $info['major'], $info['minor'] ) = explode( '/', $mime ); @@ -1165,5 +1177,3 @@ ENDS; } } - -?> diff --git a/maintenance/Makefile b/maintenance/Makefile index e84cfdf3..82476139 100644 --- a/maintenance/Makefile +++ b/maintenance/Makefile @@ -1,17 +1,10 @@ -mediawiki_version := $(shell php -r "include('commandLine.inc'); print SpecialVersion::getVersion();") - help: @echo "Run 'make test' to run the parser tests." - @echo "Run 'make doc' to run the phpdoc generation." - @echo "Run 'make doxydoc' (unsupported doxygen generation)." + @echo "Run 'make doc' to run the doxygen generation." test: php parserTests.php --quiet doc: - php mwdocgen.php -all - echo 'Doc generation done. Look at ./docs/html/' - -doxydoc: - cd .. && /bin/sed -e "s/MW_VERSION_PLACEHOLDER/$(mediawiki_version)/" maintenance/mwdoxygen.cfg | doxygen - - echo 'Doc generation done. Look at ./docs/html/' + php mwdocgen.php --all + @echo 'Doc generation done. Look at ./docs/html/' diff --git a/maintenance/README b/maintenance/README index 7ef358b8..e4c01b53 100644 --- a/maintenance/README +++ b/maintenance/README @@ -48,8 +48,11 @@ installations. dumpBackup.php Backup dump script - dumpHTML.php - Produce an HTML dump of a wiki + edit.php + Edit a page to change its content + + findhooks.php + Find hooks that aren't documented in docs/hooks.txt importDump.php XML dump importer @@ -60,6 +63,12 @@ installations. importTextFile.php Import the contents of a text file into a wiki page + moveBatch.php + Move a batch of pages + + namespaceDupes.php + Check articles name to see if they conflict with new/existing namespaces + nukePage.php Wipe a page and all revisions from the database @@ -84,5 +93,17 @@ installations. runJobs.php Immediately complete all jobs in the job queue + stats.php + Show all statistics stored in memcached + + undelete.php + Undelete all revisions of a page + update.php Check and upgrade the database schema to the current version + + updateRestrictions.php + Update pages restriction to the new schema + + userOptions.php + Change user options \ No newline at end of file diff --git a/maintenance/addwiki.php b/maintenance/addwiki.php index a19b24ce..b9c48506 100644 --- a/maintenance/addwiki.php +++ b/maintenance/addwiki.php @@ -1,4 +1,11 @@ \n" ); + wfDie( "Usage: php addwiki.php \nThe site for Wikipedia is 'wikipedia'.\n" ); } addWiki( $args[0], $args[1], $args[2] ); @@ -17,13 +24,17 @@ function addWiki( $lang, $site, $dbName ) { global $IP, $wgLanguageNames, $wgDefaultExternalStore; + if ( !isset( $wgLanguageNames[$lang] ) ) { + print "Language $lang not found in \$wgLanguageNames\n"; + return; + } $name = $wgLanguageNames[$lang]; - $dbw = wfGetDB( DB_WRITE ); + $dbw = wfGetDB( DB_MASTER ); $common = "/home/wikipedia/common"; $maintenance = "$IP/maintenance"; - print "Creating database $dbName for $lang.$site\n"; + print "Creating database $dbName for $lang.$site ($name)\n"; # Set up the database $dbw->query( "SET table_type=Innodb" ); @@ -33,8 +44,12 @@ function addWiki( $lang, $site, $dbName ) print "Initialising tables\n"; dbsource( "$maintenance/tables.sql", $dbw ); dbsource( "$IP/extensions/OAI/update_table.sql", $dbw ); - dbsource( "$IP/extensions/AntiSpoof/mysql/patch-antispoof.sql", $dbw ); + dbsource( "$IP/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql", $dbw ); dbsource( "$IP/extensions/CheckUser/cu_changes.sql", $dbw ); + dbsource( "$IP/extensions/CheckUser/cu_log.sql", $dbw ); + dbsource( "$IP/extensions/TitleKey/titlekey.sql", $dbw ); + dbsource( "$IP/extensions/Oversight/hidden.sql", $dbw ); + $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" ); # Initialise external storage @@ -72,7 +87,8 @@ function addWiki( $lang, $site, $dbName ) } global $wgTitle, $wgArticle; - $wgTitle = Title::newMainPage(); + $wgTitle = Title::newFromText( wfMsgWeirdKey( "mainpage/$lang" ) ); + print "Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n"; $wgArticle = new Article( $wgTitle ); $ucsite = ucfirst( $site ); @@ -218,32 +234,16 @@ EOT fclose( $file ); # Update the sublists - system("cd $common && ./refresh-dblist"); + shell_exec("cd $common && ./refresh-dblist"); - print "Constructing interwiki SQL\n"; + #print "Constructing interwiki SQL\n"; # Rebuild interwiki tables - $sql = getRebuildInterwikiSQL(); - $tempname = tempnam( '/tmp', 'addwiki' ); - $file = fopen( $tempname, 'w' ); - if ( !$file ) { - wfDie( "Error, unable to open temporary file $tempname\n" ); - } - fwrite( $file, $sql ); - fclose( $file ); - print "Sourcing interwiki SQL\n"; - dbsource( $tempname, $dbw ); - #unlink( $tempname ); - - # Create the upload dir - global $wgUploadDirectory; - if( file_exists( $wgUploadDirectory ) ) { - echo "$wgUploadDirectory already exists.\n"; - } else { - echo "Creating $wgUploadDirectory...\n"; - mkdir( $wgUploadDirectory, 0777 ); - chmod( $wgUploadDirectory, 0777 ); - } + #passthru( '/home/wikipedia/conf/interwiki/update' ); - print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n"; + print "Script ended. You still have to: +* Add any required settings in InitialiseSettings.php +* Run sync-common-all +* Run /home/wikipedia/conf/interwiki/update +"; } 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 @@ stderr = fopen( "php://stderr", "wt" ); @@ -177,6 +185,7 @@ class BackupDumper { $db = $this->backupDb(); $exporter = new WikiExporter( $db, $history, WikiExporter::STREAM, $text ); + $exporter->dumpUploads = $this->dumpUploads; $wrapper = new ExportProgressFilter( $this->sink, $this ); $exporter->setOutputSink( $wrapper ); @@ -293,5 +302,3 @@ class ExportProgressFilter extends DumpFilter { $this->progress->revCount(); } } - -?> diff --git a/maintenance/backupPrefetch.inc b/maintenance/backupPrefetch.inc index 413247d7..512af1c7 100644 --- a/maintenance/backupPrefetch.inc +++ b/maintenance/backupPrefetch.inc @@ -52,6 +52,7 @@ foreach( $xmlReaderConstants as $name ) { * recorded, so the previous dump is a reliable source * * Requires PHP 5 and the XMLReader PECL extension. + * @ingroup Maintenance */ class BaseDump { var $reader = null; @@ -199,5 +200,3 @@ class BaseDump { return null; } } - -?> diff --git a/maintenance/benchmarkPurge.php b/maintenance/benchmarkPurge.php index 0ceb8445..76302a01 100644 --- a/maintenance/benchmarkPurge.php +++ b/maintenance/benchmarkPurge.php @@ -1,7 +1,9 @@ * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason @@ -25,6 +26,9 @@ if( in_array( '--help', $argv ) ) $cp = new ChangePassword( @$options['user'], @$options['password'] ); $cp->main(); +/** + * @ingroup Maintenance + */ class ChangePassword { var $dbw; var $user, $password; @@ -36,7 +40,7 @@ class ChangePassword { } $this->user = User::newFromName( $user ); - if ( !$this->user->getID() ) { + if ( !$this->user->getId() ) { die ( "No such user: $user\n" ); } @@ -48,16 +52,7 @@ class ChangePassword { function main() { $fname = 'ChangePassword::main'; - $this->dbw->update( 'user', - array( - 'user_password' => wfEncryptPassword( $this->user->getID(), $this->password ) - ), - array( - 'user_id' => $this->user->getID() - ), - $fname - ); + $this->user->setPassword( $this->password ); + $this->user->saveSettings(); } } - - diff --git a/maintenance/checkAutoLoader.php b/maintenance/checkAutoLoader.php new file mode 100644 index 00000000..c2909ef7 --- /dev/null +++ b/maintenance/checkAutoLoader.php @@ -0,0 +1,22 @@ + '$file',\n"; + } elseif ( AutoLoader::$localClasses[$class] !== $file ) { + echo "$class: Wrong file: found in $file, listed in " . AutoLoader::$localClasses[$class] . "\n"; + } + } + +} + + diff --git a/maintenance/checkUsernames.php b/maintenance/checkUsernames.php index 3441aeeb..77565b99 100644 --- a/maintenance/checkUsernames.php +++ b/maintenance/checkUsernames.php @@ -1,4 +1,12 @@ - * @addtogroup maintenance + * @ingroup maintenance */ $options = array( 'dry-run' ); @@ -33,6 +34,9 @@ $options = array( 'dry-run' ); require_once( 'commandLine.inc' ); require_once( 'FiveUpgrade.inc' ); +/** + * @ingroup Maintenance + */ class CapsCleanup extends FiveUpgrade { function CapsCleanup( $dryrun = false, $namespace=0 ) { parent::FiveUpgrade(); @@ -152,5 +156,3 @@ $wgUser->setName( 'Conversion script' ); $ns = isset( $options['namespace'] ) ? $options['namespace'] : 0; $caps = new CapsCleanup( isset( $options['dry-run'] ), $ns ); $caps->cleanup(); - - diff --git a/maintenance/cleanupDupes.inc b/maintenance/cleanupDupes.inc index ce1ffc6e..bb408007 100644 --- a/maintenance/cleanupDupes.inc +++ b/maintenance/cleanupDupes.inc @@ -21,7 +21,8 @@ * If on the old non-unique indexes, check the cur table for duplicate * entries and remove them... * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance */ function fixDupes( $fixthem = false) { @@ -125,5 +126,3 @@ function checkDupes( $fixthem = false, $indexonly = false ) { } } } - -?> diff --git a/maintenance/cleanupImages.php b/maintenance/cleanupImages.php index d6ed5a7a..79ff54e8 100644 --- a/maintenance/cleanupImages.php +++ b/maintenance/cleanupImages.php @@ -24,13 +24,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * + * @file * @author Brion Vibber - * @addtogroup maintenance + * @ingroup Maintenance */ require_once( 'commandLine.inc' ); require_once( 'cleanupTable.inc' ); +/** + * @ingroup Maintenance + */ class ImageCleanup extends TableCleanup { function __construct( $dryrun = false ) { parent::__construct( 'image', $dryrun ); diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 36d8b258..eb9bd914 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -1,4 +1,8 @@ getID() ) { +if ( !$wgUser->getId() ) { $wgUser->addToDatabase(); } diff --git a/maintenance/cleanupTable.inc b/maintenance/cleanupTable.inc index cf33e8f0..26b0a0e2 100644 --- a/maintenance/cleanupTable.inc +++ b/maintenance/cleanupTable.inc @@ -2,6 +2,9 @@ require_once( 'FiveUpgrade.inc' ); +/** + * @ingroup Maintenance + */ abstract class TableCleanup extends FiveUpgrade { function __construct( $table, $dryrun = false ) { parent::__construct(); @@ -82,5 +85,3 @@ abstract class TableCleanup extends FiveUpgrade { abstract function processPage( $row ); } - -?> diff --git a/maintenance/cleanupTitles.php b/maintenance/cleanupTitles.php index 1f06b165..a6991829 100644 --- a/maintenance/cleanupTitles.php +++ b/maintenance/cleanupTitles.php @@ -24,13 +24,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * + * @file * @author Brion Vibber - * @addtogroup maintenance + * @ingroup Maintenance */ require_once( 'commandLine.inc' ); require_once( 'cleanupTable.inc' ); +/** + * @ingroup Maintenance + */ class TitleCleanup extends TableCleanup { function __construct( $dryrun = false ) { parent::__construct( 'page', $dryrun ); @@ -125,7 +129,7 @@ class TitleCleanup extends TableCleanup { ), array( 'page_id' => $row->page_id ), 'cleanupTitles::moveInconsistentPage' ); - $linkCache =& LinkCache::singleton(); + $linkCache = LinkCache::singleton(); $linkCache->clear(); } } diff --git a/maintenance/cleanupWatchlist.php b/maintenance/cleanupWatchlist.php index bcf05730..a6cedb2e 100644 --- a/maintenance/cleanupWatchlist.php +++ b/maintenance/cleanupWatchlist.php @@ -24,8 +24,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * + * @file * @author Brion Vibber - * @addtogroup maintenance + * @ingroup Maintenance */ $options = array( 'fix' ); @@ -33,6 +34,9 @@ $options = array( 'fix' ); require_once( 'commandLine.inc' ); require_once( 'FiveUpgrade.inc' ); +/** + * @ingroup Maintenance + */ class WatchlistCleanup extends FiveUpgrade { function WatchlistCleanup( $dryrun = false ) { parent::FiveUpgrade(); diff --git a/maintenance/clear_interwiki_cache.php b/maintenance/clear_interwiki_cache.php index af5d9b2f..ce154779 100644 --- a/maintenance/clear_interwiki_cache.php +++ b/maintenance/clear_interwiki_cache.php @@ -2,7 +2,9 @@ /** * This script is used to clear the interwiki links for ALL languages in * memcached. - * @addtogroup Maintenance + * + * @file + * @ingroup Maintenance */ /** */ diff --git a/maintenance/clear_stats.php b/maintenance/clear_stats.php index 5c1dce97..4cacd74c 100644 --- a/maintenance/clear_stats.php +++ b/maintenance/clear_stats.php @@ -1,4 +1,11 @@ siteFromDB( $db ); # If not, work out the language and site the old way @@ -150,6 +161,10 @@ if ( file_exists( '/home/wikipedia/common/langlist' ) ) { $DP = $IP; ini_set( 'include_path', ".:$IP:$IP/includes:$IP/languages:$IP/maintenance" ); + if ( $lang == 'test' && $site == 'wikipedia' ) { + define( 'TESTWIKI', 1 ); + } + #require_once( $IP.'/includes/ProfilerStub.php' ); require_once( $IP.'/includes/Defines.php' ); require_once( $IP.'/CommonSettings.php' ); @@ -169,6 +184,14 @@ if ( file_exists( '/home/wikipedia/common/langlist' ) ) { } else { $settingsFile = "$IP/LocalSettings.php"; } + if ( isset( $options['wiki'] ) ) { + $bits = explode( '-', $options['wiki'] ); + if ( count( $bits ) == 1 ) { + $bits[] = ''; + } + define( 'MW_DB', $bits[0] ); + define( 'MW_PREFIX', $bits[1] ); + } if ( ! is_readable( $settingsFile ) ) { print "A copy of your installation's LocalSettings.php\n" . @@ -177,6 +200,7 @@ if ( file_exists( '/home/wikipedia/common/langlist' ) ) { } $wgCommandLineMode = true; $DP = $IP; + require_once( "$IP/includes/AutoLoader.php" ); #require_once( $IP.'/includes/ProfilerStub.php' ); require_once( $IP.'/includes/Defines.php' ); require_once( $settingsFile ); @@ -207,6 +231,10 @@ if ( empty( $wgUseNormalUser ) && isset( $wgDBadminuser ) ) { $wgDBservers[$i]['password'] = $wgDBpassword; } } + if( isset( $wgLBFactoryConf['serverTemplate'] ) ) { + $wgLBFactoryConf['serverTemplate']['user'] = $wgDBuser; + $wgLBFactoryConf['serverTemplate']['password'] = $wgDBpassword; + } } if ( defined( 'MW_CMDLINE_CALLBACK' ) ) { @@ -235,28 +263,4 @@ $wgShowSQLErrors = true; require_once( "$IP/includes/Setup.php" ); require_once( "$IP/install-utils.inc" ); $wgTitle = null; # Much much faster startup than creating a title object -set_time_limit(0); - -// -------------------------------------------------------------------- -// Functions -// -------------------------------------------------------------------- - -function wfWaitForSlaves( $maxLag ) { - global $wgLoadBalancer; - if ( $maxLag ) { - list( $host, $lag ) = $wgLoadBalancer->getMaxLag(); - while ( $lag > $maxLag ) { - $name = @gethostbyaddr( $host ); - if ( $name !== false ) { - $host = $name; - } - print "Waiting for $host (lagged $lag seconds)...\n"; - sleep($maxLag); - list( $host, $lag ) = $wgLoadBalancer->getMaxLag(); - } - } -} - - - -?> +@set_time_limit(0); diff --git a/maintenance/convertLinks.inc b/maintenance/convertLinks.inc index d0c57f78..e4deb22b 100644 --- a/maintenance/convertLinks.inc +++ b/maintenance/convertLinks.inc @@ -1,7 +1,8 @@ diff --git a/maintenance/convertLinks.php b/maintenance/convertLinks.php index bc0aef49..e86d1e7c 100644 --- a/maintenance/convertLinks.php +++ b/maintenance/convertLinks.php @@ -3,7 +3,8 @@ * Convert from the old links schema (string->ID) to the new schema (ID->ID) * The wiki should be put into read-only mode while this script executes * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance */ /** */ @@ -11,5 +12,3 @@ require_once( "commandLine.inc" ); require_once( "convertLinks.inc" ); convertLinks(); - - diff --git a/maintenance/counter.php b/maintenance/counter.php index 67b9ce21..67575ec1 100644 --- a/maintenance/counter.php +++ b/maintenance/counter.php @@ -1,4 +1,11 @@ */ diff --git a/maintenance/deleteArchivedFiles.inc b/maintenance/deleteArchivedFiles.inc index 32ddf4c8..da1c14d5 100644 --- a/maintenance/deleteArchivedFiles.inc +++ b/maintenance/deleteArchivedFiles.inc @@ -3,17 +3,18 @@ /** * Support functions for the deleteArchivedFiles script * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance * @author Aaron Schulz */ require_once( "$IP/includes/FileStore.php" ); +require_once( "$IP/includes/filerepo/File.php" ); function DeleteArchivedFiles( $delete = false ) { # Data should come off the master, wrapped in a transaction $dbw = wfGetDB( DB_MASTER ); - $dbw->begin(); $transaction = new FSTransaction(); if( !FileStore::lock() ) { @@ -32,25 +33,24 @@ function DeleteArchivedFiles( $delete = false ) { $id = $row->fa_id; $store = FileStore::get( $group ); - if ( $store ) { + if( $store ) { $path = $store->filePath( $key ); - if ( $path && file_exists($path) ) { + $sha1 = substr( $key, 0, strcspn( $key, '.' ) ); + $inuse = $dbw->selectField( 'oldimage', '1', + array( 'oi_sha1' => $sha1, + 'oi_deleted & '.File::DELETED_FILE => File::DELETED_FILE ), + __METHOD__, array( 'FOR UPDATE' ) ); + if ( $path && file_exists($path) && !$inuse ) { $transaction->addCommit( FSTransaction::DELETE_FILE, $path ); $dbw->query( "DELETE FROM $tbl_arch WHERE fa_id = $id" ); } else { echo( "Notice - file '$key' not found in group '$group'\n" ); } } else { - echo( "Notice - invalid file storage group '$group'\n" ); + echo( "Notice - invalid file storage group '$group' for file '$key'\n" ); } } echo( "done.\n" ); $transaction->commit(); - - # This bit's done - $dbw->commit(); - } - -?> \ No newline at end of file diff --git a/maintenance/deleteArchivedFiles.php b/maintenance/deleteArchivedFiles.php index a556c3b9..97dc5824 100644 --- a/maintenance/deleteArchivedFiles.php +++ b/maintenance/deleteArchivedFiles.php @@ -3,7 +3,8 @@ /** * Delete archived (non-current) files from the database * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance * @author Aaron Schulz * Based on deleteOldRevisions.php by Rob Church */ diff --git a/maintenance/deleteArchivedRevisions.inc b/maintenance/deleteArchivedRevisions.inc index f820ccb0..67e4c5a2 100644 --- a/maintenance/deleteArchivedRevisions.inc +++ b/maintenance/deleteArchivedRevisions.inc @@ -3,7 +3,8 @@ /** * Support functions for the deleteArchivedRevisions script * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance * @author Aaron Schulz */ @@ -31,5 +32,3 @@ function DeleteArchivedRevisions( $delete = false ) { } } - -?> \ No newline at end of file diff --git a/maintenance/deleteArchivedRevisions.php b/maintenance/deleteArchivedRevisions.php index 53aec4c3..87eebfad 100644 --- a/maintenance/deleteArchivedRevisions.php +++ b/maintenance/deleteArchivedRevisions.php @@ -1,9 +1,10 @@ ] [-r ] [-i ] -# where -# is a file where each line contains the title of a page to be deleted. -# is the username -# is the delete reason -# is the number of seconds to sleep for after each delete +/** + * Deletes a batch of pages + * Usage: php deleteBatch.php [-u ] [-r ] [-i ] + * where + * is a file where each line contains the title of a page to be deleted. + * is the username + * is the delete reason + * is the number of seconds to sleep for after each delete + * + * @file + * @ingroup Maintenance + */ $oldCwd = getcwd(); $optionsWithArgs = array( 'u', 'r', 'i' ); diff --git a/maintenance/deleteDefaultMessages.php b/maintenance/deleteDefaultMessages.php index 9a7f5c6a..77e85741 100644 --- a/maintenance/deleteDefaultMessages.php +++ b/maintenance/deleteDefaultMessages.php @@ -3,6 +3,9 @@ /** * Deletes all pages in the MediaWiki namespace which were last edited by * "MediaWiki default". + * + * @file + * @ingroup Maintenance */ if ( !defined( 'MEDIAWIKI' ) ) { diff --git a/maintenance/deleteImageMemcached.php b/maintenance/deleteImageMemcached.php index 7ec9953c..2c3afa86 100644 --- a/maintenance/deleteImageMemcached.php +++ b/maintenance/deleteImageMemcached.php @@ -1,9 +1,21 @@ */ @@ -66,5 +66,3 @@ function DeleteOldRevisions( $delete = false, $args = array() ) { } } - -?> \ No newline at end of file diff --git a/maintenance/deleteOldRevisions.php b/maintenance/deleteOldRevisions.php index 8454479b..c283c607 100644 --- a/maintenance/deleteOldRevisions.php +++ b/maintenance/deleteOldRevisions.php @@ -3,7 +3,8 @@ /** * Delete old (non-current) revisions from the database * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance * @author Rob Church */ diff --git a/maintenance/deleteOrphanedRevisions.inc.php b/maintenance/deleteOrphanedRevisions.inc.php index 707eaf98..6678d5b8 100644 --- a/maintenance/deleteOrphanedRevisions.inc.php +++ b/maintenance/deleteOrphanedRevisions.inc.php @@ -3,7 +3,8 @@ /** * Support functions for the deleteOrphanedRevisions maintenance script * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance * @author Rob Church */ diff --git a/maintenance/deleteOrphanedRevisions.php b/maintenance/deleteOrphanedRevisions.php index 0842018e..78441f8e 100644 --- a/maintenance/deleteOrphanedRevisions.php +++ b/maintenance/deleteOrphanedRevisions.php @@ -4,7 +4,8 @@ * Maintenance script to delete revisions which refer to a nonexisting page * Sometimes manual deletion done in a rush leaves crap in the database * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance * @author Rob Church * @todo More efficient cleanup of text records */ diff --git a/maintenance/deleteRevision.php b/maintenance/deleteRevision.php index 0876efc9..0c203ab0 100644 --- a/maintenance/deleteRevision.php +++ b/maintenance/deleteRevision.php @@ -1,4 +1,11 @@ skipHeader = isset( $options['skip-header'] ); $dumper->skipFooter = isset( $options['skip-footer'] ); +$dumper->dumpUploads = isset( $options['uploads'] ); $textMode = isset( $options['stub'] ) ? WikiExporter::STUB : WikiExporter::TEXT; @@ -62,7 +64,7 @@ if( isset( $options['full'] ) ) { } elseif( isset( $options['current'] ) ) { $dumper->dump( WikiExporter::CURRENT, $textMode ); } else { - $dumper->progress( <<progress( << header --skip-footer Don't output the footer --stub Don't perform old_text lookups; for 2-pass dump + --uploads Include upload records (experimental) Fancy stuff: --plugin=[:] Load a dump plugin class @@ -90,7 +93,7 @@ Fancy stuff: s: file, gzip, bzip2, 7zip --filter=[:] Add a filter on an output branch -END +ENDS ); } diff --git a/maintenance/dumpInterwiki.inc b/maintenance/dumpInterwiki.inc index 9af6ccc5..481e21cc 100644 --- a/maintenance/dumpInterwiki.inc +++ b/maintenance/dumpInterwiki.inc @@ -3,20 +3,19 @@ * Rebuild interwiki table using the file on meta and the language list * Wikimedia specific! * + * @file * @todo document - * @addtogroup Maintenance + * @ingroup Maintenance */ -/** */ - /** * @todo document - * @addtogroup Maintenance + * @ingroup Maintenance */ class Site { var $suffix, $lateral, $url; - function Site( $s, $l, $u ) { + function __construct( $s, $l, $u ) { $this->suffix = $s; $this->lateral = $l; $this->url = $u; @@ -92,7 +91,7 @@ function getRebuildInterwikiDump() { } # Extract the intermap from meta - $intermap = wfGetHTTP( 'http://meta.wikimedia.org/w/index.php?title=Interwiki_map&action=raw', 30 ); + $intermap = Http::get( 'http://meta.wikimedia.org/w/index.php?title=Interwiki_map&action=raw', 30 ); $lines = array_map( 'trim', explode( "\n", trim( $intermap ) ) ); if ( !$lines || count( $lines ) < 2 ) { @@ -207,5 +206,3 @@ function makeLink( $entry, $source ) { print "{$source}:{$entry['iw_prefix']} {$entry['iw_url']} {$entry['iw_local']}\n"; } - -?> diff --git a/maintenance/dumpInterwiki.php b/maintenance/dumpInterwiki.php index 02116a53..91cdbe8a 100644 --- a/maintenance/dumpInterwiki.php +++ b/maintenance/dumpInterwiki.php @@ -2,8 +2,10 @@ /** * Rebuild interwiki table using the file on meta and the language list * Wikimedia specific! + * + * @file * @todo document - * @addtogroup Maintenance + * @ingroup Maintenance */ /** */ diff --git a/maintenance/dumpLinks.php b/maintenance/dumpLinks.php index f61c398b..65dfac64 100644 --- a/maintenance/dumpLinks.php +++ b/maintenance/dumpLinks.php @@ -26,7 +26,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @addtogroup SpecialPage + * @file + * @ingroup Mainatenance */ require_once 'commandLine.inc'; diff --git a/maintenance/dumpSisterSites.php b/maintenance/dumpSisterSites.php index 0c2fff46..2a7369c0 100644 --- a/maintenance/dumpSisterSites.php +++ b/maintenance/dumpSisterSites.php @@ -21,7 +21,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @addtogroup SpecialPage + * @file + * @ingroup SpecialPage */ require_once( 'commandLine.inc' ); diff --git a/maintenance/dumpTextPass.php b/maintenance/dumpTextPass.php index 440f6d27..eb4cc072 100644 --- a/maintenance/dumpTextPass.php +++ b/maintenance/dumpTextPass.php @@ -18,7 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @addtogroup SpecialPage + * @file + * @ingroup Maintenance */ $originalDir = getcwd(); @@ -30,6 +31,8 @@ require_once( 'backup.inc' ); * Stream wrapper around 7za filter program. * Required since we can't pass an open file resource to XMLReader->open() * which is used for the text prefetch. + * + * @ingroup Maintenance */ class SevenZipStream { var $stream; @@ -93,7 +96,9 @@ class SevenZipStream { } stream_wrapper_register( 'mediawiki.compress.7z', 'SevenZipStream' ); - +/** + * @ingroup Maintenance + */ class TextPassDumper extends BackupDumper { var $prefetch = null; var $input = "php://stdin"; @@ -494,7 +499,7 @@ $dumper = new TextPassDumper( $argv ); if( true ) { $dumper->dump(); } else { - $dumper->progress( <<progress( << 1 ) { - foreach ( $wgLoadBalancer->mServers as $i => $server ) { - $wgLoadBalancer->mServers[$i]['flags'] |= DBO_DEBUG; + $lb = wfGetLB(); + foreach ( $lb->mServers as $i => $server ) { + $lb->mServers[$i]['flags'] |= DBO_DEBUG; } } if ( $d > 2 ) { @@ -42,8 +39,24 @@ if ( isset( $options['d'] ) ) { } } +if ( function_exists( 'readline_add_history' ) + && function_exists( 'posix_isatty' ) && posix_isatty( 0 /*STDIN*/ ) ) +{ + $useReadline = true; +} else { + $useReadline = false; +} + +if ( $useReadline ) { + $historyFile = "{$_ENV['HOME']}/.mweval_history"; + readline_read_history( $historyFile ); +} while ( ( $line = readconsole( '> ' ) ) !== false ) { + if ( $useReadline ) { + readline_add_history( $line ); + readline_write_history( $historyFile ); + } $val = eval( $line . ";" ); if( is_null( $val ) ) { echo "\n"; @@ -52,9 +65,6 @@ while ( ( $line = readconsole( '> ' ) ) !== false ) { } else { var_dump( $val ); } - if ( function_exists( "readline_add_history" ) ) { - readline_add_history( $line ); - } } print "\n"; diff --git a/maintenance/fetchText.php b/maintenance/fetchText.php index 3b745c0a..91b78be3 100644 --- a/maintenance/fetchText.php +++ b/maintenance/fetchText.php @@ -1,7 +1,9 @@ \ No newline at end of file diff --git a/maintenance/findhooks.php b/maintenance/findhooks.php index 8433571d..7a2ba53f 100644 --- a/maintenance/findhooks.php +++ b/maintenance/findhooks.php @@ -7,37 +7,56 @@ * - hooks names in hooks.txt are at the beginning of a line and single quoted. * - hooks names in code are the first parameter of wfRunHooks. * + * if --online option is passed, the script will compare the hooks in the code + * with the ones at http://www.mediawiki.org/wiki/Manual:Hooks + * * Any instance of wfRunHooks that doesn't meet these parameters will be noted. * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance * * @author Ashar Voultoiz * @copyright Copyright © Ashar voultoiz * @license http://www.gnu.org/copyleft/gpl.html GNU General Public Licence 2.0 or later */ - + /** This is a command line script*/ include('commandLine.inc'); - - + # GLOBALS - + $doc = $IP . '/docs/hooks.txt'; -$pathinc = array( $IP.'/includes/', $IP.'/includes/api/', $IP.'/includes/filerepo/', $IP.'/languages/', $IP.'/maintenance/', $IP.'/skins/' ); - +$pathinc = array( + $IP.'/', + $IP.'/includes/', + $IP.'/includes/api/', + $IP.'/includes/db/', + $IP.'/includes/filerepo/', + $IP.'/includes/parser/', + $IP.'/includes/specials/', + $IP.'/languages/', + $IP.'/maintenance/', + $IP.'/skins/', +); + # FUNCTIONS - + /** * @return array of documented hooks */ function getHooksFromDoc() { - global $doc; - $content = file_get_contents( $doc ); + global $doc, $options; $m = array(); - preg_match_all( "/\n'(.*?)'/", $content, $m); - return $m[1]; + if( isset( $options['online'] ) ){ + $content = Http::get( 'http://www.mediawiki.org/w/index.php?title=Manual:Hooks&action=raw' ); + preg_match_all( '/\[\[\/([a-zA-Z0-9-_:]+)\|/', $content, $m ); + } else { + $content = file_get_contents( $doc ); + preg_match_all( "/\n'(.*?)'/", $content, $m ); + } + return array_unique( $m[1] ); } - + /** * Get hooks from a PHP file * @param $file Full filename to the PHP file. @@ -49,7 +68,7 @@ function getHooksFromFile( $file ) { preg_match_all( '/wfRunHooks\(\s*([\'"])(.*?)\1/', $content, $m); return $m[2]; } - + /** * Get hooks from the source code. * @param $path Directory where the include files can be found @@ -67,7 +86,7 @@ function getHooksFromPath( $path ) { } return $hooks; } - + /** * Get bad hooks (where the hook name could not be determined) from a PHP file * @param $file Full filename to the PHP file. @@ -84,7 +103,7 @@ function getBadHooksFromFile( $file ) { } return $list; } - + /** * Get bad hooks from the source code. * @param $path Directory where the include files can be found @@ -103,7 +122,7 @@ function getBadHooksFromPath( $path ) { } return $hooks; } - + /** * Nicely output the array * @param $msg A message to show before the value @@ -114,10 +133,9 @@ function printArray( $msg, $arr, $sort = true ) { if($sort) asort($arr); foreach($arr as $v) echo "$msg: $v\n"; } - - + # MAIN - + $documented = getHooksFromDoc($doc); $potential = array(); $bad = array(); @@ -125,12 +143,12 @@ foreach( $pathinc as $dir ) { $potential = array_merge( $potential, getHooksFromPath( $dir ) ); $bad = array_merge( $bad, getBadHooksFromPath( $dir ) ); } - + $potential = array_unique( $potential ); $bad = array_unique( $bad ); $todo = array_diff( $potential, $documented ); $deprecated = array_diff( $documented, $potential ); - + // let's show the results: printArray('undocumented', $todo ); printArray('not found', $deprecated ); diff --git a/maintenance/fixSlaveDesync.php b/maintenance/fixSlaveDesync.php index daa5bbb4..7817bc56 100644 --- a/maintenance/fixSlaveDesync.php +++ b/maintenance/fixSlaveDesync.php @@ -1,4 +1,8 @@ isNonZeroLoad( $i ) ) { + if ( wfGetLB()->isNonZeroLoad( $i ) ) { $slaveIndexes[] = $i; } } /* -foreach ( $wgLoadBalancer->mServers as $i => $server ) { - $wgLoadBalancer->mServers[$i]['flags'] |= DBO_DEBUG; +foreach ( wfGetLB()->mServers as $i => $server ) { + wfGetLB()->mServers[$i]['flags'] |= DBO_DEBUG; }*/ $reportingInterval = 1000; diff --git a/maintenance/fixTimestamps.php b/maintenance/fixTimestamps.php index 39cdaae1..f6794141 100644 --- a/maintenance/fixTimestamps.php +++ b/maintenance/fixTimestamps.php @@ -1,11 +1,13 @@ * @copyright Copyright © 2005, Brion Vibber * - * @see http://www.google.com/webmasters/sitemaps/docs/en/about.html - * @see http://www.google.com/schemas/sitemap/0.84/sitemap.xsd + * @see http://www.sitemaps.org/ + * @see http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd * * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ @@ -20,7 +20,7 @@ class GenerateSitemap { /** * The maximum amount of urls in a sitemap file * - * @link http://www.google.com/schemas/sitemap/0.84/sitemap.xsd + * @link http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd * * @var int */ @@ -29,7 +29,7 @@ class GenerateSitemap { /** * The maximum size of a sitemap file * - * @link http://www.google.com/webmasters/sitemaps/docs/en/protocol.html#faq_sitemap_size + * @link http://www.sitemaps.org/faq.php#faq_sitemap_size * * @var int */ @@ -148,22 +148,47 @@ class GenerateSitemap { $this->url_limit = 50000; $this->size_limit = pow( 2, 20 ) * 10; - $this->fspath = isset( $fspath ) ? $fspath : ''; + $this->fspath = self::init_path( $fspath ); + $this->compress = $compress; $this->stderr = fopen( 'php://stderr', 'wt' ); $this->dbr = wfGetDB( DB_SLAVE ); $this->generateNamespaces(); $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() ); + + $this->findex = fopen( "{$this->fspath}sitemap-index-" . wfWikiID() . ".xml", 'wb' ); } + /** + * Create directory if it does not exist and return pathname with a trailing slash + */ + private static function init_path( $fspath ) { + if( !isset( $fspath ) ) { + return null; + } + # Create directory if needed + if( $fspath && !is_dir( $fspath ) ) { + mkdir( $fspath, 0755 ) or die("Can not create directory $fspath.\n"); + } + + return realpath( $fspath ). DIRECTORY_SEPARATOR ; + } + /** * Generate a one-dimensional array of existing namespaces */ function generateNamespaces() { $fname = 'GenerateSitemap::generateNamespaces'; + // Only generate for specific namespaces if $wgSitemapNamespaces is an array. + global $wgSitemapNamespaces; + if( is_array( $wgSitemapNamespaces ) ) { + $this->namespaces = $wgSitemapNamespaces; + return; + } + $res = $this->dbr->select( 'page', array( 'page_namespace' ), array(), @@ -200,7 +225,7 @@ class GenerateSitemap { * @return string */ function guessPriority( $namespace ) { - return Namespace::isMain( $namespace ) ? $this->priorities[GS_MAIN] : $this->priorities[GS_TALK]; + return MWNamespace::isMain( $namespace ) ? $this->priorities[GS_MAIN] : $this->priorities[GS_TALK]; } /** @@ -253,7 +278,7 @@ class GenerateSitemap { $this->file = $this->open( $this->fspath . $filename, 'wb' ); $this->write( $this->file, $this->openFile() ); fwrite( $this->findex, $this->indexEntry( $filename ) ); - $this->debug( "\t$filename" ); + $this->debug( "\t$this->fspath$filename" ); $length = $this->limit[0]; $i = 1; } @@ -345,7 +370,7 @@ class GenerateSitemap { * @returns string */ function xmlSchema() { - return 'http://www.google.com/schemas/sitemap/0.84'; + return 'http://www.sitemaps.org/schemas/sitemap/0.9'; } /** @@ -450,7 +475,7 @@ if ( in_array( '--help', $argv ) ) { Usage: php generateSitemap.php [options] --help show this message - --fspath= The file system path to save to, e.g /tmp/sitemap/ + --fspath= The file system path to save to, e.g /tmp/sitemap --server= The protocol and server name to use in URLs, e.g. http://en.wikipedia.org. This is sometimes necessary because diff --git a/maintenance/getLagTimes.php b/maintenance/getLagTimes.php index d3934592..0f750caf 100644 --- a/maintenance/getLagTimes.php +++ b/maintenance/getLagTimes.php @@ -1,14 +1,20 @@ getServerCount() == 1 ) { echo "This script dumps replication lag times, but you don't seem to have\n"; echo "a multi-host db server configuration.\n"; } else { - $lags = $wgLoadBalancer->getLagTimes(); + $lags = $lb->getLagTimes(); foreach( $lags as $n => $lag ) { - $host = $wgDBservers[$n]["host"]; + $host = $lb->getServerName( $n ); if( IP::isValid( $host ) ) { $ip = $host; $host = gethostbyaddr( $host ); diff --git a/maintenance/getSlaveServer.php b/maintenance/getSlaveServer.php index 9aca1043..25258267 100644 --- a/maintenance/getSlaveServer.php +++ b/maintenance/getSlaveServer.php @@ -1,13 +1,26 @@ getProperty( 'mServer' ); + $host = $db->getServer(); } else { - $i = $wgLoadBalancer->getReaderIndex(); - $host = $wgDBservers[$i]['host']; + $lb = wfGetLB(); + $i = $lb->getReaderIndex(); + $host = $lb->getServerName( $i ); } print "$host\n"; diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 211d0a9e..99e69ce8 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -18,19 +18,25 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance */ $optionsWithArgs = array( 'report' ); require_once( 'commandLine.inc' ); +/** + * @ingroup Maintenance + */ class BackupReader { var $reportingInterval = 100; var $reporting = true; var $pageCount = 0; var $revCount = 0; var $dryRun = false; + var $debug = false; + var $uploads = false; function BackupReader() { $this->stderr = fopen( "php://stderr", "wt" ); @@ -57,6 +63,21 @@ class BackupReader { call_user_func( $this->importCallback, $rev ); } } + + function handleUpload( $revision ) { + if( $this->uploads ) { + $this->uploadCount++; + //$this->report(); + $this->progress( "upload: " . $revision->getFilename() ); + + if( !$this->dryRun ) { + // bluuuh hack + //call_user_func( $this->uploadCallback, $revision ); + $dbw = wfGetDB( DB_MASTER ); + return $dbw->deadlockLoop( array( $revision, 'importUpload' ) ); + } + } + } function report( $final = false ) { if( $final xor ( $this->pageCount % $this->reportingInterval == 0 ) ) { @@ -76,6 +97,7 @@ class BackupReader { } $this->progress( "$this->pageCount ($rate pages/sec $revrate revs/sec)" ); } + wfWaitForSlaves(5); } function progress( $string ) { @@ -101,9 +123,12 @@ class BackupReader { $source = new ImportStreamSource( $handle ); $importer = new WikiImporter( $source ); + $importer->setDebug( $this->debug ); $importer->setPageCallback( array( &$this, 'reportPage' ) ); $this->importCallback = $importer->setRevisionCallback( array( &$this, 'handleRevision' ) ); + $this->uploadCallback = $importer->setUploadCallback( + array( &$this, 'handleUpload' ) ); return $importer->doImport(); } @@ -123,6 +148,12 @@ if( isset( $options['report'] ) ) { if( isset( $options['dry-run'] ) ) { $reader->dryRun = true; } +if( isset( $options['debug'] ) ) { + $reader->debug = true; +} +if( isset( $options['uploads'] ) ) { + $reader->uploads = true; // experimental! +} if( isset( $args[0] ) ) { $result = $reader->importFromFile( $args[0] ); diff --git a/maintenance/importImages.inc.php b/maintenance/importImages.inc.php index 9a68bac0..53895778 100644 --- a/maintenance/importImages.inc.php +++ b/maintenance/importImages.inc.php @@ -3,7 +3,8 @@ /** * Support functions for the importImages script * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance * @author Rob Church */ diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 660d831c..63bbec5f 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -4,7 +4,8 @@ * Maintenance script to import one or more images from the local file system into * the wiki without using the web-based interface * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance * @author Rob Church */ diff --git a/maintenance/importLogs.inc b/maintenance/importLogs.inc index 0dc87eab..a008e6c7 100644 --- a/maintenance/importLogs.inc +++ b/maintenance/importLogs.inc @@ -22,8 +22,9 @@ * * Not yet complete. * + * @file * @todo document - * @addtogroup Maintenance + * @ingroup Maintenance */ /** */ @@ -35,7 +36,7 @@ require_once( 'LogPage.php' ); /** * Log importer * @todo document - * @addtogroup Maintenance + * @ingroup Maintenance */ class LogImporter { var $dummy = false; @@ -141,5 +142,3 @@ function wfUnescapeWikiText( $text ) { $text ); return $text; } - -?> diff --git a/maintenance/importLogs.php b/maintenance/importLogs.php index 199a7f0c..059c2f17 100644 --- a/maintenance/importLogs.php +++ b/maintenance/importLogs.php @@ -1,7 +1,8 @@ */ diff --git a/maintenance/importUseModWiki.php b/maintenance/importUseModWiki.php index 4febc497..05a4c78c 100644 --- a/maintenance/importUseModWiki.php +++ b/maintenance/importUseModWiki.php @@ -22,7 +22,8 @@ * 2005-03-14 * * @todo document - * @addtogroup Maintenance + * @file + * @ingroup Maintenance */ if( php_sapi_name() != 'cli' ) { diff --git a/maintenance/initEditCount.php b/maintenance/initEditCount.php index 5a4367d0..d26349bb 100644 --- a/maintenance/initEditCount.php +++ b/maintenance/initEditCount.php @@ -1,4 +1,8 @@ \ No newline at end of file diff --git a/maintenance/initStats.php b/maintenance/initStats.php index 05377481..d206c202 100644 --- a/maintenance/initStats.php +++ b/maintenance/initStats.php @@ -3,7 +3,8 @@ /** * Maintenance script to re-initialise or update the site statistics table * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance * @author Brion Vibber * @author Rob Church * @licence GNU General Public Licence 2.0 or later diff --git a/maintenance/installExtension.php b/maintenance/installExtension.php index 549c4a68..d5c4f4be 100644 --- a/maintenance/installExtension.php +++ b/maintenance/installExtension.php @@ -17,7 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @addtogroup Maintenance + * @file + * @ingroup Maintenance */ $optionsWithArgs = array( 'target', 'repository', 'repos' ); @@ -28,6 +29,9 @@ define('EXTINST_NOPATCH', 0); define('EXTINST_WRITEPATCH', 6); define('EXTINST_HOTPATCH', 10); +/** + * @ingroup Maintenance + */ class InstallerRepository { var $path; @@ -43,7 +47,7 @@ class InstallerRepository { trigger_error( 'override InstallerRepository::getResource()', E_USER_ERROR ); } - /*static*/ function makeRepository( $path, $type = NULL ) { + static function makeRepository( $path, $type = NULL ) { if ( !$type ) { $m = array(); preg_match( '!(([-+\w]+)://)?.*?(\.[-\w\d.]+)?$!', $path, $m ); @@ -64,6 +68,9 @@ class InstallerRepository { } } +/** + * @ingroup Maintenance + */ class LocalInstallerRepository extends InstallerRepository { function LocalInstallerRepository ( $path ) { @@ -101,6 +108,9 @@ class LocalInstallerRepository extends InstallerRepository { } } +/** + * @ingroup Maintenance + */ class WebInstallerRepository extends InstallerRepository { function WebInstallerRepository ( $path ) { @@ -144,6 +154,9 @@ class WebInstallerRepository extends InstallerRepository { } } +/** + * @ingroup Maintenance + */ class SVNInstallerRepository extends InstallerRepository { function SVNInstallerRepository ( $path ) { @@ -176,6 +189,9 @@ class SVNInstallerRepository extends InstallerRepository { } } +/** + * @ingroup Maintenance + */ class InstallerResource { var $path; var $isdir; @@ -243,6 +259,9 @@ class InstallerResource { } } +/** + * @ingroup Maintenance + */ class LocalInstallerResource extends InstallerResource { function LocalInstallerResource( $path ) { InstallerResource::InstallerResource( $path, is_dir( $path ), true ); @@ -255,6 +274,9 @@ class LocalInstallerResource extends InstallerResource { } +/** + * @ingroup Maintenance + */ class WebInstallerResource extends InstallerResource { function WebInstallerResource( $path ) { InstallerResource::InstallerResource( $path, false, false ); @@ -278,6 +300,9 @@ class WebInstallerResource extends InstallerResource { } } +/** + * @ingroup Maintenance + */ class SVNInstallerResource extends InstallerResource { function SVNInstallerResource( $path ) { InstallerResource::InstallerResource( $path, true, false ); @@ -297,6 +322,9 @@ class SVNInstallerResource extends InstallerResource { } } +/** + * @ingroup Maintenance + */ class ExtensionInstaller { var $source; var $target; @@ -319,15 +347,15 @@ class ExtensionInstaller { #TODO: allow a config file different from "LocalSettings.php" } - function note( $msg ) { + static function note( $msg ) { print "$msg\n"; } - function warn( $msg ) { + static function warn( $msg ) { print "WARNING: $msg\n"; } - function error( $msg ) { + static function error( $msg ) { print "ERROR: $msg\n"; } @@ -470,18 +498,18 @@ class ExtensionInstaller { #TODO: allow custom installer scripts + sql patches if ( !file_exists( $f ) ) { - $this->warn( "No install.settings file provided!" ); + self::warn( "No install.settings file provided!" ); $this->tasks[] = "Please read the instructions and edit LocalSettings.php manually to activate the extension."; return '?'; } else { - $this->note( "applying settings patch..." ); + self::note( "applying settings patch..." ); } $settings = file_get_contents( $f ); if ( !$settings ) { - $this->error( "failed to read settings from $f!" ); + self::error( "failed to read settings from $f!" ); return false; } @@ -489,7 +517,7 @@ class ExtensionInstaller { if ( $mode == EXTINST_NOPATCH ) { $this->tasks[] = "Please put the following into your LocalSettings.php:" . "\n$settings\n"; - $this->note( "Skipping patch phase, automatic patching is off." ); + self::note( "Skipping patch phase, automatic patching is off." ); return true; } @@ -500,18 +528,18 @@ class ExtensionInstaller { $ok = copy( $t, $bak ); if ( !$ok ) { - $this->warn( "failed to create backup of LocalSettings.php!" ); + self::warn( "failed to create backup of LocalSettings.php!" ); return false; } else { - $this->note( "created backup of LocalSettings.php at $bak" ); + self::note( "created backup of LocalSettings.php at $bak" ); } } $localsettings = file_get_contents( $t ); if ( !$settings ) { - $this->error( "failed to read $t for patching!" ); + self::error( "failed to read $t for patching!" ); return false; } @@ -534,14 +562,14 @@ class ExtensionInstaller { $ok = file_put_contents( $t, $localsettings ); if ( !$ok ) { - $this->error( "failed to patch $t!" ); + self::error( "failed to patch $t!" ); return false; } else if ( $mode == EXTINST_HOTPATCH ) { - $this->note( "successfully patched $t" ); + self::note( "successfully patched $t" ); } else { - $this->note( "created patched settings file $t" ); + self::note( "created patched settings file $t" ); $this->tasks[] = "Replace your current LocalSettings.php with ".basename($t); } diff --git a/maintenance/interwiki.sql b/maintenance/interwiki.sql index ed71c067..c8e088f5 100644 --- a/maintenance/interwiki.sql +++ b/maintenance/interwiki.sql @@ -2,152 +2,87 @@ -- Default interwiki prefixes... REPLACE INTO /*$wgDBprefix*/interwiki (iw_prefix,iw_url,iw_local) VALUES -('abbenormal','http://www.ourpla.net/cgi-bin/pikie.cgi?$1',0), ('acronym','http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=$1',0), ('advogato','http://www.advogato.org/$1',0), -('aiwiki','http://www.ifi.unizh.ch/ailab/aiwiki/aiw.cgi?$1',0), ('annotationwiki','http://www.seedwiki.com/page.cfm?wikiid=368&doc=$1',0), ('arxiv','http://www.arxiv.org/abs/$1',0), -('bemi','http://bemi.free.fr/vikio/index.php?$1',0), ('c2find','http://c2.com/cgi/wiki?FindPage&value=$1',0), ('cache','http://www.google.com/search?q=cache:$1',0), -('cliki','http://ww.telent.net/cliki/$1',0), -('cmwiki','http://www.ourpla.net/cgi-bin/wiki.pl?$1',0), -('codersbase','http://www.codersbase.com/index.php/$1',0), +('codersbase','http://www.codersbase.com/index.php/$1',0), # 2008-02-27: Fatal error ('commons','http://commons.wikimedia.org/wiki/$1',0), -('consciousness','http://teadvus.inspiral.org/',0), ('corpknowpedia','http://corpknowpedia.org/wiki/index.php/$1',0), -('creationmatters','http://www.ourpla.net/cgi-bin/wiki.pl?$1',0), -('dejanews','http://www.deja.com/=dnc/getdoc.xp?AN=$1',0), ('dictionary','http://www.dict.org/bin/Dict?Database=*&Form=Dict1&Strategy=*&Query=$1',0), ('disinfopedia','http://www.disinfopedia.org/wiki.phtml?title=$1',0), -('diveintoosx','http://diveintoosx.org/$1',0), ('docbook','http://wiki.docbook.org/topic/$1',0), -('dolphinwiki','http://www.object-arts.com/wiki/html/Dolphin/$1',0), ('drumcorpswiki','http://www.drumcorpswiki.com/index.php/$1',0), ('dwjwiki','http://www.suberic.net/cgi-bin/dwj/wiki.cgi?$1',0), -('eĉei','http://www.ikso.net/cgi-bin/wiki.pl?$1',0), -('echei','http://www.ikso.net/cgi-bin/wiki.pl?$1',0), -('ecxei','http://www.ikso.net/cgi-bin/wiki.pl?$1',0), -('efnetceewiki','http://purl.net/wiki/c/$1',0), -('efnetcppwiki','http://purl.net/wiki/cpp/$1',0), -('efnetpythonwiki','http://purl.net/wiki/python/$1',0), -('efnetxmlwiki','http://purl.net/wiki/xml/$1',0), -('eljwiki','http://elj.sourceforge.net/phpwiki/index.php/$1',0), +('efnetceewiki','http://purl.net/wiki/c/$1',0), # 2008-02-27: does not appear to be working +('efnetcppwiki','http://purl.net/wiki/cpp/$1',0), # 2008-02-27: does not appear to be working +('efnetpythonwiki','http://purl.net/wiki/python/$1',0), # 2008-02-27: does not appear to be working +('efnetxmlwiki','http://purl.net/wiki/xml/$1',0), # 2008-02-27: does not appear to be working +('eljwiki','http://elj.sourceforge.net/phpwiki/index.php/$1',0), # 2008-02-27: Fatal PhpWiki Error ('emacswiki','http://www.emacswiki.org/cgi-bin/wiki.pl?$1',0), ('elibre','http://enciclopedia.us.es/index.php/$1',0), -('eokulturcentro','http://esperanto.toulouse.free.fr/wakka.php?wiki=$1',0), -('evowiki','http://www.evowiki.org/index.php/$1',0), -('finalempire','http://final-empire.sourceforge.net/cgi-bin/wiki.pl?$1',0), -('firstwiki','http://firstwiki.org/index.php/$1',0), -('foldoc','http://www.foldoc.org/foldoc/foldoc.cgi?$1',0), +('eokulturcentro','http://esperanto.toulouse.free.fr/wakka.php?wiki=$1',0), # 2007-02-27: no access to database +('foldoc','http://foldoc.org/?$1',0), ('foxwiki','http://fox.wikis.com/wc.dll?Wiki~$1',0), -('fr.be','http://fr.wikinations.be/$1',0), -('fr.ca','http://fr.ca.wikinations.org/$1',0), -('fr.fr','http://fr.fr.wikinations.org/$1',0), -('fr.org','http://fr.wikinations.org/$1',0), ('freebsdman','http://www.FreeBSD.org/cgi/man.cgi?apropos=1&query=$1',0), -('gamewiki','http://gamewiki.org/wiki/index.php/$1',0), ('gej','http://www.esperanto.de/cgi-bin/aktivikio/wiki.pl?$1',0), ('gentoo-wiki','http://gentoo-wiki.com/$1',0), -('globalvoices','http://cyber.law.harvard.edu/dyn/globalvoices/wiki/$1',0), -('gmailwiki','http://www.gmailwiki.com/index.php/$1',0), ('google','http://www.google.com/search?q=$1',0), ('googlegroups','http://groups.google.com/groups?q=$1',0), -('gotamac','http://www.got-a-mac.org/$1',0), -('greencheese','http://www.greencheese.org/$1',0), -('hammondwiki','http://www.dairiki.org/HammondWiki/index.php3?$1',0), -('haribeau','http://wiki.haribeau.de/cgi-bin/wiki.pl?$1',0), +('gotamac','http://www.got-a-mac.org/$1',0), # 2008-02-27: appears ill maintained; loads of spambots +('hammondwiki','http://www.dairiki.org/HammondWiki/$1',0), ('hewikisource','http://he.wikisource.org/wiki/$1',1), -('herzkinderwiki','http://www.herzkinderinfo.de/Mediawiki/index.php/$1',0), ('hrwiki','http://www.hrwiki.org/index.php/$1',0), -('iawiki','http://www.IAwiki.net/$1',0), ('imdb','http://us.imdb.com/Title?$1',0), -('infosecpedia','http://www.infosecpedia.org/pedia/index.php/$1',0), +('infosecpedia','http://www.infosecpedia.org/pedia/index.php/$1',0), # 2008-02-27: lot of spambot activity ('jargonfile','http://sunir.org/apps/meta.pl?wiki=JargonFile&redirect=$1',0), -('jefo','http://www.esperanto-jeunes.org/vikio/index.php?$1',0), -('jiniwiki','http://www.cdegroot.com/cgi-bin/jini?$1',0), -('jspwiki','http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=$1',0), +('jspwiki','http://www.jspwiki.org/wiki/$1',0), ('keiki','http://kei.ki/en/$1',0), -('kerimwiki','http://wiki.oxus.net/$1',0), -('kmwiki','http://www.voght.com/cgi-bin/pywiki?$1',0), -('knowhow','http://www2.iro.umontreal.ca/~paquetse/cgi-bin/wiki.cgi?$1',0), -('lanifexwiki','http://opt.lanifex.com/cgi-bin/wiki.pl?$1',0), -('lasvegaswiki','http://wiki.gmnow.com/index.php/$1',0), -('linuxwiki','http://www.linuxwiki.de/$1',0), +('kmwiki','http://kmwiki.wikispaces.com/$1',0), +('linuxwiki','http://linuxwiki.de/$1',0), ('lojban','http://www.lojban.org/tiki/tiki-index.php?page=$1',0), ('lqwiki','http://wiki.linuxquestions.org/wiki/$1',0), ('lugkr','http://lug-kr.sourceforge.net/cgi-bin/lugwiki.pl?$1',0), -('lutherwiki','http://www.lutheranarchives.com/mw/index.php/$1',0), ('mathsongswiki','http://SeedWiki.com/page.cfm?wikiid=237&doc=$1',0), -('mbtest','http://www.usemod.com/cgi-bin/mbtest.pl?$1',0), ('meatball','http://www.usemod.com/cgi-bin/mb.pl?$1',0), ('mediazilla','http://bugzilla.wikipedia.org/$1',1), ('mediawikiwiki','http://www.mediawiki.org/wiki/$1',0), ('memoryalpha','http://www.memory-alpha.org/en/index.php/$1',0), -('metaweb','http://www.metaweb.com/wiki/wiki.phtml?title=$1',0), ('metawiki','http://sunir.org/apps/meta.pl?$1',0), ('metawikipedia','http://meta.wikimedia.org/wiki/$1',0), ('moinmoin','http://purl.net/wiki/moin/$1',0), ('mozillawiki','http://wiki.mozilla.org/index.php/$1',0), -('muweb','http://www.dunstable.com/scripts/MuWebWeb?$1',0), -('netvillage','http://www.netbros.com/?$1',0), ('oeis','http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=$1',0), ('openfacts','http://openfacts.berlios.de/index.phtml?title=$1',0), ('openwiki','http://openwiki.com/?$1',0), -('opera7wiki','http://nontroppo.org/wiki/$1',0), -('orgpatterns','http://www.bell-labs.com/cgi-user/OrgPatterns/OrgPatterns?$1',0), -('osi reference model','http://wiki.tigma.ee/',0), -('pangalacticorg','http://www.pangalactic.org/Wiki/$1',0), -('personaltelco','http://www.personaltelco.net/index.cgi/$1',0), -('patwiki','http://gauss.ffii.org/$1',0), -('phpwiki','http://phpwiki.sourceforge.net/phpwiki/index.php?$1',0), -('pikie','http://pikie.darktech.org/cgi/pikie?$1',0), +('orgpatterns','http://www.bell-labs.com/cgi-user/OrgPatterns/OrgPatterns?$1',0), # 2008-02-27: may not be working. Please double check +('patwiki','http://gauss.ffii.org/$1',0), # 2008-02-27: lots of spambots ('pmeg','http://www.bertilow.com/pmeg/$1.php',0), ('ppr','http://c2.com/cgi/wiki?$1',0), -('purlnet','http://purl.oclc.org/NET/$1',0), -('pythoninfo','http://www.python.org/cgi-bin/moinmoin/$1',0), -('pythonwiki','http://www.pythonwiki.de/$1',0), -('pywiki','http://www.voght.com/cgi-bin/pywiki?$1',0), -('raec','http://www.raec.clacso.edu.ar:8080/raec/Members/raecpedia/$1',0), -('revo','http://purl.org/NET/voko/revo/art/$1.html',0), +('pythoninfo','http://wiki.python.org/moin/$1',0), ('rfc','http://www.rfc-editor.org/rfc/rfc$1.txt',0), ('s23wiki','http://is-root.de/wiki/index.php/$1',0), -('scoutpedia','http://www.scoutpedia.info/index.php/$1',0), -('seapig','http://www.seapig.org/$1',0), -('seattlewiki','http://seattlewiki.org/wiki/$1',0), +('seattlewiki','http://seattle.wikia.com/wiki/$1',0), ('seattlewireless','http://seattlewireless.net/?$1',0), -('seeds','http://www.IslandSeeds.org/wiki/$1',0), ('senseislibrary','http://senseis.xmp.net/?$1',0), -('shakti','http://cgi.algonet.se/htbin/cgiwrap/pgd/ShaktiWiki/$1',0), -('slashdot','http://slashdot.org/article.pl?sid=$1',0), -('smikipedia','http://www.smikipedia.org/$1',0), -('sockwiki','http://wiki.socklabs.com/$1',0), +('slashdot','http://slashdot.org/article.pl?sid=$1',0), # 2008-02-27: update me ('sourceforge','http://sourceforge.net/$1',0), -('squeak','http://minnow.cc.gatech.edu/squeak/$1',0), -('strikiwiki','http://ch.twi.tudelft.nl/~mostert/striki/teststriki.pl?$1',0), +('squeak','http://wiki.squeak.org/squeak/$1',0), ('susning','http://www.susning.nu/$1',0), -('svgwiki','http://www.protocol7.com/svg-wiki/default.asp?$1',0), +('svgwiki','http://wiki.svg.org/$1',0), ('tavi','http://tavi.sourceforge.net/$1',0), ('tejo','http://www.tejo.org/vikio/$1',0), -('terrorwiki','http://www.liberalsagainstterrorism.com/wiki/index.php/$1',0), -('tmbw','http://www.tmbw.net/wiki/index.php/$1',0), +('tmbw','http://www.tmbw.net/wiki/$1',0), ('tmnet','http://www.technomanifestos.net/?$1',0), ('tmwiki','http://www.EasyTopicMaps.com/?page=$1',0), -('turismo','http://www.tejo.org/turismo/$1',0), ('theopedia','http://www.theopedia.com/$1',0), ('twiki','http://twiki.org/cgi-bin/view/$1',0), -('twistedwiki','http://purl.net/wiki/twisted/$1',0), ('uea','http://www.tejo.org/uea/$1',0), ('unreal','http://wiki.beyondunreal.com/wiki/$1',0), -('ursine','http://wiki.ursine.ca/$1',0), -('usej','http://www.tejo.org/usej/$1',0), ('usemod','http://www.usemod.com/cgi-bin/wiki.pl?$1',0), ('vinismo','http://vinismo.com/en/$1',0), -('visualworks','http://wiki.cs.uiuc.edu/VisualWorks/$1',0), -('warpedview','http://www.warpedview.com/index.php/$1',0), -('webdevwikinl','http://www.promo-it.nl/WebDevWiki/index.php?page=$1',0), -('webisodes','http://www.webisodes.org/$1',0), ('webseitzwiki','http://webseitz.fluxent.com/wiki/$1',0), ('why','http://clublet.com/c/c/why?$1',0), ('wiki','http://c2.com/cgi/wiki?$1',0), @@ -163,13 +98,9 @@ REPLACE INTO /*$wgDBprefix*/interwiki (iw_prefix,iw_url,iw_local) VALUES ('wikisource','http://sources.wikipedia.org/wiki/$1',1), ('wikispecies','http://species.wikipedia.org/wiki/$1',1), ('wikitravel','http://wikitravel.org/en/$1',0), -('wikiworld','http://WikiWorld.com/wiki/index.php/$1',0), ('wiktionary','http://en.wiktionary.org/wiki/$1',1), ('wikipedia', 'http://en.wikipedia.org/wiki/$1', 1), ('wlug','http://www.wlug.org.nz/$1',0), -('wlwiki','http://winslowslair.supremepixels.net/wiki/index.php/$1',0), -('ypsieyeball','http://sknkwrks.dyndns.org:1957/writewiki/wiki.pl?$1',0), -('zwiki','http://www.zwiki.org/$1',0), -('zzz wiki','http://wiki.zzz.ee/',0), +('zwiki','http://zwiki.org/$1',0), +('zzz wiki','http://wiki.zzz.ee/index.php/$1',0), ('wikt','http://en.wiktionary.org/wiki/$1',1); - diff --git a/maintenance/language/StatOutputs.php b/maintenance/language/StatOutputs.php index 50829cbe..f65b263e 100644 --- a/maintenance/language/StatOutputs.php +++ b/maintenance/language/StatOutputs.php @@ -3,6 +3,8 @@ if (!defined('MEDIAWIKI')) die(); /** * Statistic output classes. * + * @file + * @ingroup MaintenanceLanguage * @author Ævar Arnfjörð Bjarmason * @author Ashar Voultoiz */ diff --git a/maintenance/language/alltrans.php b/maintenance/language/alltrans.php index 4adc2a66..67c870e6 100644 --- a/maintenance/language/alltrans.php +++ b/maintenance/language/alltrans.php @@ -1,6 +1,7 @@ + * Check the extensions language files. * - * Based on dumpBackup: - * Copyright (C) 2005 Brion Vibber - * - * http://www.mediawiki.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @addtogroup Maintenance + * @file + * @ingroup MaintenanceLanguage */ -# -# Lacking documentation. Examples: -# php checkExtensions.php /opt/mw/extensions/CentralAuth/CentralAuth.i18n.php wgCentralAuthMessages -# php checkExtensions.php --extdir /opt/mw/extensions/ -# -# BUGS: cant guess registered extensions :) -# TODO: let users set parameters to configure checklanguage.inc - -// Filename for the extension i18n files database: -define( 'EXT_I18N_DB', 'i18n.db' ); - -$optionsWithArgs = array( 'extdir', 'lang' ); - require_once( dirname(__FILE__).'/../commandLine.inc' ); require_once( 'languages.inc' ); require_once( 'checkLanguage.inc' ); - -class extensionLanguages extends languages { - private $mExt18nFilename, $mExtArrayName ; - private $mExtArray; - - function __construct( $ext18nFilename, $extArrayName ) { - $this->mExt18nFilename = $ext18nFilename; - $this->mExtArrayName = $extArrayName; - - $this->mIgnoredMessages = array(); - $this->mOptionalMessages = array(); - - if ( file_exists( $this->mExt18nFilename ) ) { - require_once( $this->mExt18nFilename ); - - $foundarray = false; - if( isset( ${$this->mExtArrayName} ) ) { - // File provided in the db file - $foundarray = ${$this->mExtArrayName}; - } else { - - /* For extensions included elsewhere. For some reason other extensions - * break with the global statement, so recheck here. - */ - global ${$this->mExtArrayName}; - if( is_array( ${$this->mExtArrayName} ) ) { - $foundarray = ${$this->mExtArrayName}; - } - - /* we might have been given a function name, test it too */ - if( function_exists( $this->mExtArrayName ) ) { - // Load data - $funcName = $this->mExtArrayName ; - $foundarray = $funcName(); - } - - if(!$foundarray) { - // Provided array could not be found we try to guess it. - - # Using the extension path ($m[1]) and filename ($m[2]): - $m = array(); - preg_match( '%.*/(.*)/(.*).i18n\.php%', $this->mExt18nFilename, $m); - $arPathCandidate = 'wg' . $m[1].'Messages'; - $arFileCandidate = 'wg' . $m[2].'Messages'; - $funcCandidate = "ef{$m[2]}Messages"; - - // Try them: - if( isset($$arPathCandidate) && is_array( $$arPathCandidate ) ) { - print "warning> messages from guessed path array \$$arPathCandidate.\n"; - $foundarray = $$arPathCandidate; - } elseif( isset($$arFileCandidate) && is_array( $$arFileCandidate ) ) { - print "warning> messages from guessed file array \$$arFileCandidate.\n"; - $foundarray = $$arFileCandidate; - } elseif( function_exists( $funcCandidate ) ) { - print "warning> messages build from guessed function {$funcCandidate}().\n"; - $foundarray = $funcCandidate(); - } - } - - # We are unlucky, return empty stuff - if(!$foundarray) { - print "ERROR> failed to guess an array to use.\n"; - $this->mExtArray = null; - $this->mLanguages = null; - return; - } - } - - $this->mExtArray = $foundarray ; - $this->mLanguages = array_keys( $this->mExtArray ); - } else { - wfDie( "File $this->mExt18nFilename not found\n" ); - } - } - - protected function loadRawMessages( $code ) { - if ( isset( $this->mRawMessages[$code] ) ) { - return; - } - if( isset( $this->mExtArray[$code] ) ) { - $this->mRawMessages[$code] = $this->mExtArray[$code] ; - } else { - $this->mRawMessages[$code] = array(); - } - } - - public function getLanguages() { - return $this->mLanguages; - } -} - -/** - * @param $filename Filename containing the extension i18n - * @param $arrayname The name of the array in the filename - * @param $filter Optional, restrict check to a given language code (default; null) - */ -function checkExtensionLanguage( $filename, $arrayname, $filter = null ) { - $extLanguages = new extensionLanguages($filename, $arrayname); - - $langs = $extLanguages->getLanguages(); - if( !$langs ) { - print "ERROR> \$$arrayname array does not exist.\n"; - return false; - } - - $nErrors = 0; - if( $filter ) { - $nErrors += checkLanguage( $extLanguages, $filter ); - } else { - print "Will check ". count($langs) . " languages : " . implode(' ', $langs) .".\n"; - foreach( $langs as $lang ) { - if( $lang == 'en' ) { - #print "Skipped english language\n"; - continue; - } - - $nErrors += checkLanguage( $extLanguages, $lang ); - } - } - - return $nErrors; -} - -/** - * Read the db file, parse it, start the check. - */ -function checkExtensionRepository( $extdir, $db ) { - $fh = fopen( $extdir. '/' . $db, 'r' ); - - $line_number = 0; - while( $line = fgets( $fh ) ) { - $line_number++; - - // Ignore comments - if( preg_match( '/^#/', $line ) ) { - continue; - } - - // Load data from i18n database - $data = split( ' ', chop($line) ); - $i18n_file = @$data[0]; - $arrayname = @$data[1]; - - print "------------------------------------------------------\n"; - print "Checking $i18n_file (\$$arrayname).\n"; - - // Check data - if( !file_exists( $extdir . '/' . $i18n_file ) ) { - print "ERROR> $i18n_file not found ($db:$line_number).\n"; - continue; - } -# if( $arrayname == '' ) { -# print "warning> no array name for $i18n_file ($db:$line_number).\n"; -# } - - $i18n_file = $extdir . '/' . $i18n_file ; - - global $myLang; - $nErrors = checkExtensionLanguage( $i18n_file, $arrayname, $myLang ); - if($nErrors == 1 ) { - print "\nFound $nErrors error for this extension.\n"; - } elseif($nErrors) { - print "\nFound $nErrors errors for this extension.\n"; - } else { - print "Looks OK.\n"; - } - - print "\n"; - } -} - - -function usage() { -// Usage -print << - php checkExtensions.php --extdir - -Common option: - --lang : only check the given language. - +if( !class_exists( 'MessageGroups' ) || !class_exists( 'PremadeMediawikiExtensionGroups' ) ) { + echo <<execute(); diff --git a/maintenance/language/checkLanguage.inc b/maintenance/language/checkLanguage.inc index 51de8014..2cfd1b04 100644 --- a/maintenance/language/checkLanguage.inc +++ b/maintenance/language/checkLanguage.inc @@ -1,15 +1,491 @@ help(); + exit(); + } + + if ( isset($options['lang']) ) { + $this->code = $options['lang']; + } else { + global $wgLanguageCode; + $this->code = $wgLanguageCode; + } + + if ( isset($options['level']) ) { + $this->level = $options['level']; + } + + $this->doLinks = isset($options['links']); + $this->includeExif = !isset($options['noexif']); + $this->checkAll = isset($options['all']); + + if ( isset($options['wikilang']) ) { + $this->wikiCode = $options['wikilang']; + } + + if ( isset( $options['whitelist'] ) ) { + $this->checks = explode( ',', $options['whitelist'] ); + } elseif ( isset( $options['blacklist'] ) ) { + $this->checks = array_diff( + $this->defaultChecks, + explode( ',', $options['blacklist'] ) + ); + } else { + $this->checks = $this->defaultChecks; + } + + if ( isset($options['output']) ) { + $this->output = $options['output']; + } + + # Some additional checks not enabled by default + if ( isset( $options['duplicate'] ) ) { + $this->checks[] = 'duplicate'; + } + + $this->L = new languages( $this->includeExif ); + } + + protected function getChecks() { + $checks = array(); + $checks['untranslated'] = 'getUntranslatedMessages'; + $checks['duplicate'] = 'getDuplicateMessages'; + $checks['obsolete'] = 'getObsoleteMessages'; + $checks['variables'] = 'getMessagesWithoutVariables'; + $checks['plural'] = 'getMessagesWithoutPlural'; + $checks['empty'] = 'getEmptyMessages'; + $checks['whitespace'] = 'getMessagesWithWhitespace'; + $checks['xhtml'] = 'getNonXHTMLMessages'; + $checks['chars'] = 'getMessagesWithWrongChars'; + $checks['links'] = 'getMessagesWithDubiousLinks'; + $checks['unbalanced'] = 'getMessagesWithUnbalanced'; + return $checks; + } + + protected function getDescriptions() { + $descriptions = array(); + $descriptions['untranslated'] = '$1 message(s) of $2 are not translated to $3, but exist in en:'; + $descriptions['duplicate'] = '$1 message(s) of $2 are translated the same in en and $3:'; + $descriptions['obsolete'] = '$1 message(s) of $2 do not exist in en or are in the ignore list, but are in $3'; + $descriptions['variables'] = '$1 message(s) of $2 in $3 don\'t use some variables that en uses:'; + $descriptions['plural'] = '$1 message(s) of $2 in $3 don\'t use {{plural}} while en uses:'; + $descriptions['empty'] = '$1 message(s) of $2 in $3 are empty or -:'; + $descriptions['whitespace'] = '$1 message(s) of $2 in $3 have trailing whitespace:'; + $descriptions['xhtml'] = '$1 message(s) of $2 in $3 contain illegal XHTML:'; + $descriptions['chars'] = '$1 message(s) of $2 in $3 include hidden chars which should not be used in the messages:'; + $descriptions['links'] = '$1 message(s) of $2 in $3 have problematic link(s):'; + $descriptions['unbalanced'] = '$1 message(s) of $2 in $3 have unbalanced {[]}:'; + return $descriptions; + } + + protected function help() { + return <<