public function execute()
 {
     $this->nullsOnly = $this->getOption('nulls');
     if (!$this->getOption('nowarn')) {
         if ($this->nullsOnly) {
             $this->output("The script is about to reset the user_token " . "for USERS WITH NULL TOKENS in the database.\n");
         } else {
             $this->output("The script is about to reset the user_token for ALL USERS in the database.\n");
             $this->output("This may log some of them out and is not necessary unless you believe your\n");
             $this->output("user table has been compromised.\n");
         }
         $this->output("\n");
         $this->output("Abort with control-c in the next five seconds " . "(skip this countdown with --nowarn) ... ");
         wfCountDown(5);
     }
     // We list user by user_id from one of the slave database
     $dbr = $this->getDB(DB_SLAVE);
     $where = array();
     if ($this->nullsOnly) {
         // Have to build this by hand, because \ is escaped in helper functions
         $where = array('user_token = \'' . str_repeat('\\0', 32) . '\'');
     }
     $maxid = $dbr->selectField('user', 'MAX(user_id)', array(), __METHOD__);
     $min = 0;
     $max = $this->mBatchSize;
     do {
         $result = $dbr->select('user', array('user_id'), array_merge($where, array('user_id > ' . $dbr->addQuotes($min), 'user_id <= ' . $dbr->addQuotes($max))), __METHOD__);
         foreach ($result as $user) {
             $this->updateUser($user->user_id);
         }
         $min = $max;
         $max = $min + $this->mBatchSize;
         wfWaitForSlaves();
     } while ($min <= $maxid);
 }
Пример #2
0
 function execute()
 {
     global $wgVersion, $wgTitle, $wgLang;
     $wgLang = Language::factory('en');
     $wgTitle = Title::newFromText("MediaWiki database updater");
     $this->output("MediaWiki {$wgVersion} Updater\n\n");
     if (!$this->hasOption('skip-compat-checks')) {
         $this->compatChecks();
     } else {
         $this->output("Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n");
         wfCountdown(5);
     }
     # Attempt to connect to the database as a privileged user
     # This will vomit up an error if there are permissions problems
     $db = wfGetDB(DB_MASTER);
     $this->output("Going to run database updates for " . wfWikiID() . "\n");
     $this->output("Depending on the size of your database this may take a while!\n");
     if (!$this->hasOption('quick')) {
         $this->output("Abort with control-c in the next five seconds (skip this countdown with --quick) ... ");
         wfCountDown(5);
     }
     $shared = $this->hasOption('doshared');
     $updates = array('core', 'extensions');
     if (!$this->hasOption('nopurge')) {
         $updates[] = 'purge';
     }
     $updater = DatabaseUpdater::newForDb($db, $shared, $this);
     $updater->doUpdates($updates);
     foreach ($updater->getPostDatabaseUpdateMaintenance() as $maint) {
         $child = $this->runChild($maint);
         $child->execute();
     }
     $this->output("\nDone.\n");
 }
 public function execute()
 {
     if (!$this->getOption('nowarn')) {
         $this->output("The script is about to reset the user_token for ALL USERS in the database.\n");
         $this->output("This may log some of them out and is not necessary unless you believe your\n");
         $this->output("user table has been compromised.\n");
         $this->output("\n");
         $this->output("Abort with control-c in the next five seconds (skip this countdown with --nowarn) ... ");
         wfCountDown(5);
     }
     // We list user by user_id from one of the slave database
     $dbr = CentralAuthUser::getCentralDB(DB_SLAVE);
     $maxid = $this->getOption('maxid', -1);
     if ($maxid == -1) {
         $maxid = $dbr->selectField('globaluser', 'MAX(gu_id)', array(), __METHOD__);
     }
     $min = $this->getOption('minid', 0);
     $max = $min + $this->mBatchSize;
     do {
         $result = $dbr->select('globaluser', array('gu_id', 'gu_name'), array('gu_id > ' . $dbr->addQuotes($min), 'gu_id <= ' . $dbr->addQuotes($max)), __METHOD__);
         foreach ($result as $user) {
             $this->updateUser($user->gu_name);
         }
         $min = $max;
         $max = $min + $this->mBatchSize;
         if ($max > $maxid) {
             $max = $maxid;
         }
         CentralAuthUser::waitForSlaves();
     } while ($min < $maxid);
 }
 /**
  * @see Maintenance::execute
  */
 public function execute()
 {
     if (!defined('SMW_VERSION') || !$GLOBALS['smwgSemanticsEnabled']) {
         $this->output("You need to have SMW enabled in order to use this maintenance script!\n\n");
         exit;
     }
     $applicationFactory = ApplicationFactory::getInstance();
     $maintenanceFactory = $applicationFactory->newMaintenanceFactory();
     $fulltextSearchTableFactory = new FulltextSearchTableFactory();
     // Only the SQLStore is supported
     $searchTableRebuilder = $fulltextSearchTableFactory->newSearchTableRebuilder($applicationFactory->getStore('\\SMW\\SQLStore\\SQLStore'));
     $searchTableRebuilder->reportVerbose($this->hasOption('v'));
     $this->reportMessage("\nThe script rebuilds the search index from property tables that\n" . "support a fulltext search. Any change of the index rules (altered\n" . "stopwords, new stemmer etc.) and/or a newly added or altered table\n" . "requires to run this script again to ensure that the index complies\n" . "with the rules set forth by the DB or Sanitizer.\n\n");
     $searchTable = $searchTableRebuilder->getSearchTable();
     $textSanitizer = $fulltextSearchTableFactory->newTextSanitizer();
     foreach ($textSanitizer->getVersions() as $key => $value) {
         $this->reportMessage("\r" . sprintf("%-35s%s", "- {$key}", $value) . "\n");
     }
     $this->reportMessage("\nThe following properties are exempted from the fulltext search index.\n");
     $exemptionList = '';
     foreach ($searchTable->getPropertyExemptionList() as $prop) {
         $exemptionList .= ($exemptionList === '' ? '' : ', ') . $prop;
         if (strlen($exemptionList) > 60) {
             $this->reportMessage("\n- " . $exemptionList);
             $exemptionList = '';
         }
     }
     $this->reportMessage("\n- " . $exemptionList . "\n\n");
     $this->reportMessage("The entire index table is going to be purged first and \n" . "it may take a moment before the rebuild is completed due to\n" . "dependencies on table content and selected options.\n");
     if (!$this->hasOption('quick')) {
         $this->reportMessage("\n" . 'Abort the rebuild with control-c in the next five seconds ...  ');
         wfCountDown(5);
     }
     $maintenanceHelper = $maintenanceFactory->newMaintenanceHelper();
     $maintenanceHelper->initRuntimeValues();
     // Need to instantiate an extra object here since we cannot make this class itself
     // into a MessageReporter since the maintenance script does not load the interface in time.
     $reporter = MessageReporterFactory::getInstance()->newObservableMessageReporter();
     $reporter->registerReporterCallback(array($this, 'reportMessage'));
     $searchTableRebuilder->setMessageReporter($reporter);
     $result = $searchTableRebuilder->run();
     if ($result && $this->hasOption('report-runtime')) {
         $this->reportMessage("\n" . $maintenanceHelper->transformRuntimeValuesForOutput() . "\n");
     }
     if ($this->hasOption('with-maintenance-log')) {
         $maintenanceLogger = $maintenanceFactory->newMaintenanceLogger('RebuildFulltextSearchTableLogger');
         $maintenanceLogger->log($maintenanceHelper->transformRuntimeValuesForOutput());
     }
     $maintenanceHelper->reset();
     return $result;
 }
Пример #5
0
 public function execute()
 {
     global $smwgDefaultStore;
     $alternativestore = $this->getArg('backend', false);
     $alternativestore = $alternativestore !== false && $alternativestore !== $smwgDefaultStore;
     if ($alternativestore !== false) {
         $smwgDefaultStore = $this->getArg('backend', false);
         print "\nSelected storage " . $smwgDefaultStore . " for update!\n\n";
     }
     global $smwgIP;
     if (!isset($smwgIP)) {
         $smwgIP = dirname(__FILE__) . '/../';
     }
     require_once $smwgIP . 'includes/SMW_GlobalFunctions.php';
     if ($this->hasOption('delete')) {
         print "\n  Deleting all stored data for {$smwgDefaultStore} completely!\n  \n\n";
         if ($alternativestore) {
             print "  This store is currently not used by SMW. Deleting it\n  should not cause problems in the wiki.\n\n";
             $delay = 5;
         } else {
             print "  WARNING: This store is currently used by SMW! Deleting it\n           will cause problems in the wiki if SMW is enabled.\n\n";
             $delay = 20;
         }
         print "Abort with CTRL-C in the next {$delay} seconds ...  ";
         wfCountDown($delay);
         smwfGetStore()->drop(true);
         wfRunHooks('smwDropTables');
         print "\n";
         while (ob_get_level() > 0) {
             // be sure to have some buffer, otherwise some PHPs complain
             ob_end_flush();
         }
         echo "\n  All storage structures for {$smwgDefaultStore} have been deleted.\n  You can recreate them with this script, and then use\n  SMW_refreshData.php to rebuild their contents.";
     } else {
         smwfGetStore()->setup();
         wfRunHooks('smwInitializeTables');
     }
 }
 public function execute()
 {
     if (!$this->getOption('nowarn')) {
         $this->output("The script is about to reset the user_token for ALL USERS in the database.\n");
         $this->output("This may log some of them out and is not necessary unless you believe your\n");
         $this->output("user table has been compromised.\n");
         $this->output("\n");
         $this->output("Abort with control-c in the next five seconds (skip this countdown with --nowarn) ... ");
         wfCountDown(5);
     }
     // We list user by user_id from one of the slave database
     $dbr = wfGetDB(DB_SLAVE);
     $result = $dbr->select('user', array('user_id'), array(), __METHOD__);
     foreach ($result as $id) {
         $user = User::newFromId($id->user_id);
         $username = $user->getName();
         $this->output("Resetting user_token for {$username}: ");
         // Change value
         $user->setToken();
         $user->saveSettings();
         $this->output(" OK\n");
     }
 }
Пример #7
0
 /**
  * @since 1.9.2
  *
  * @return boolean
  */
 public function rebuild()
 {
     switch ($this->action) {
         case 'status':
             $this->reportMessage("\nDisplaying concept cache status information. Use CTRL-C to abort.\n\n");
             break;
         case 'create':
             $this->reportMessage("\nCreating/updating concept caches. Use CTRL-C to abort.\n\n");
             break;
         case 'delete':
             $delay = 5;
             $this->reportMessage("\nAbort with CTRL-C in the next {$delay} seconds ... ");
             $this->hasOption('quiet') ? '' : wfCountDown($delay);
             $this->reportMessage("\nDeleting concept caches.\n\n");
             break;
         default:
             return false;
     }
     if ($this->hasOption('hard')) {
         $settings = ' smwgQMaxDepth: ' . $this->settings->get('smwgQMaxDepth');
         $settings .= ' smwgQMaxSize: ' . $this->settings->get('smwgQMaxSize');
         $settings .= ' smwgQFeatures: ' . $this->settings->get('smwgQFeatures');
         $this->reportMessage("Option 'hard' is parameterized by{$settings}\n\n");
     }
     $concepts = $this->getConcepts();
     foreach ($concepts as $concept) {
         $this->workOnConcept($concept);
     }
     if ($concepts === array()) {
         $this->reportMessage("No concept available.\n");
     } else {
         $this->reportMessage("\nDone.\n");
     }
     return true;
 }
Пример #8
0
 function execute()
 {
     global $wgVersion, $wgLang, $wgAllowSchemaUpdates;
     if (!$wgAllowSchemaUpdates && !($this->hasOption('force') || $this->hasOption('schema') || $this->hasOption('noschema'))) {
         $this->error("Do not run update.php on this wiki. If you're seeing this you should\n" . "probably ask for some help in performing your schema updates or use\n" . "the --noschema and --schema options to get an SQL file for someone\n" . "else to inspect and run.\n\n" . "If you know what you are doing, you can continue with --force\n", true);
     }
     $this->fileHandle = null;
     if (substr($this->getOption('schema'), 0, 2) === "--") {
         $this->error("The --schema option requires a file as an argument.\n", true);
     } elseif ($this->hasOption('schema')) {
         $file = $this->getOption('schema');
         $this->fileHandle = fopen($file, "w");
         if ($this->fileHandle === false) {
             $err = error_get_last();
             $this->error("Problem opening the schema file for writing: {$file}\n\t{$err['message']}", true);
         }
     }
     $wgLang = Language::factory('en');
     define('MW_UPDATER', true);
     $this->output("MediaWiki {$wgVersion} Updater\n\n");
     wfWaitForSlaves();
     if (!$this->hasOption('skip-compat-checks')) {
         $this->compatChecks();
     } else {
         $this->output("Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n");
         wfCountdown(5);
     }
     // Check external dependencies are up to date
     if (!$this->hasOption('skip-external-dependencies')) {
         $composerLockUpToDate = $this->runChild('CheckComposerLockUpToDate');
         $composerLockUpToDate->execute();
     } else {
         $this->output("Skipping checking whether external dependencies are up to date, proceed at your own risk\n");
     }
     # Attempt to connect to the database as a privileged user
     # This will vomit up an error if there are permissions problems
     $db = $this->getDB(DB_MASTER);
     $this->output("Going to run database updates for " . wfWikiID() . "\n");
     if ($db->getType() === 'sqlite') {
         $this->output("Using SQLite file: '{$db->getDbFilePath()}'\n");
     }
     $this->output("Depending on the size of your database this may take a while!\n");
     if (!$this->hasOption('quick')) {
         $this->output("Abort with control-c in the next five seconds " . "(skip this countdown with --quick) ... ");
         wfCountDown(5);
     }
     $time1 = microtime(true);
     $shared = $this->hasOption('doshared');
     $updates = array('core', 'extensions');
     if (!$this->hasOption('schema')) {
         if ($this->hasOption('noschema')) {
             $updates[] = 'noschema';
         }
         $updates[] = 'stats';
     }
     $updater = DatabaseUpdater::newForDb($db, $shared, $this);
     $updater->doUpdates($updates);
     foreach ($updater->getPostDatabaseUpdateMaintenance() as $maint) {
         $child = $this->runChild($maint);
         // LoggedUpdateMaintenance is checking the updatelog itself
         $isLoggedUpdate = $child instanceof LoggedUpdateMaintenance;
         if (!$isLoggedUpdate && $updater->updateRowExists($maint)) {
             continue;
         }
         $child->execute();
         if (!$isLoggedUpdate) {
             $updater->insertUpdateRow($maint);
         }
     }
     $updater->setFileAccess();
     if (!$this->hasOption('nopurge')) {
         $updater->purgeCache();
     }
     $time2 = microtime(true);
     $timeDiff = $wgLang->formatTimePeriod($time2 - $time1);
     $this->output("\nDone in {$timeDiff}.\n");
 }
Пример #9
0
require_once getenv('MW_INSTALL_PATH') !== false ? getenv('MW_INSTALL_PATH') . '/maintenance/commandLine.inc' : dirname(__FILE__) . '/../../../maintenance/commandLine.inc';
$output_level = array_key_exists('quiet', $options) ? 0 : (array_key_exists('verbose', $options) ? 2 : 1);
if (array_key_exists('help', $options)) {
    $action = 'help';
} elseif (array_key_exists('status', $options)) {
    $action = 'status';
    outputMessage("\nDisplaying concept cache status information. Use CTRL-C to abort.\n\n");
} elseif (array_key_exists('create', $options)) {
    $action = 'create';
    outputMessage("\nCreating/updating concept caches. Use CTRL-C to abort.\n\n");
} elseif (array_key_exists('delete', $options)) {
    $action = 'delete';
    outputMessage("\nDeleting concept caches.\n\n");
    $delay = 9;
    if (outputMessage("Abort with CTRL-C in the next {$delay} seconds ... ")) {
        wfCountDown($delay);
    }
} else {
    $action = 'help';
}
if ($action == 'help') {
    print <<<ENDS

This script is used to manage concept caches for Semantic MediaWiki. Concepts
are semantic queries stored on Concept: pages. The elements of concepts can be
computed online, or they can come from a pre-computed cache. The wiki may even
be configured to display certain concepts only if they are available cached.

This script can create, delete and update these caches, or merely show their
status.
Пример #10
0
 protected function performFullDelete()
 {
     $this->reportMessage("\n Deleting all stored data completely and rebuilding it again later!\n" . " Semantic data in the wiki might be incomplete for some time while this operation runs.\n\n" . " NOTE: It is usually necessary to run this script ONE MORE TIME after this operation,\n" . " since some properties' types are not stored yet in the first run.\n" . " The first run can normally use the parameter -p to refresh only properties.\n\n");
     if ($this->useIds) {
         $this->reportMessage(" WARNING: -s or -e are used, so some pages will not be refreshed at all!\n" . " Data for those pages will only be available again when they have been\n" . " refreshed as well!\n\n");
     }
     $obLevel = ob_get_level();
     $this->reportMessage(' Abort with control-c in the next five seconds ...  ');
     wfCountDown(6);
     $this->store->drop($this->verbose);
     wfRunHooks('smwDropTables');
     wfRunHooks('SMW::Store::dropTables', array($this->verbose));
     $this->store->setupStore($this->verbose);
     // Be sure to have some buffer, otherwise some PHPs complain
     while (ob_get_level() > $obLevel) {
         ob_end_flush();
     }
     $this->reportMessage("\nAll storage structures have been deleted and recreated.\n\n");
     return true;
 }
Пример #11
0
 function execute()
 {
     global $wgVersion, $wgTitle, $wgLang, $wgAllowSchemaUpdates;
     if (!$wgAllowSchemaUpdates && !$this->hasOption('force')) {
         $this->error("Do not run update.php on this wiki. If you're seeing this you should\n" . "probably ask for some help in performing your schema updates.\n\n" . "If you know what you are doing, you can continue with --force", true);
     }
     $wgLang = Language::factory('en');
     $wgTitle = Title::newFromText("MediaWiki database updater");
     $this->output("MediaWiki {$wgVersion} Updater\n\n");
     wfWaitForSlaves(5);
     // let's not kill databases, shall we? ;) --tor
     if (!$this->hasOption('skip-compat-checks')) {
         $this->compatChecks();
     } else {
         $this->output("Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n");
         wfCountdown(5);
     }
     # Attempt to connect to the database as a privileged user
     # This will vomit up an error if there are permissions problems
     $db = wfGetDB(DB_MASTER);
     $this->output("Going to run database updates for " . wfWikiID() . "\n");
     $this->output("Depending on the size of your database this may take a while!\n");
     if (!$this->hasOption('quick')) {
         $this->output("Abort with control-c in the next five seconds (skip this countdown with --quick) ... ");
         wfCountDown(5);
     }
     $shared = $this->hasOption('doshared');
     $updates = array('core', 'extensions', 'stats');
     if (!$this->hasOption('nopurge')) {
         $updates[] = 'purge';
     }
     $updater = DatabaseUpdater::newForDb($db, $shared, $this);
     $updater->doUpdates($updates);
     foreach ($updater->getPostDatabaseUpdateMaintenance() as $maint) {
         if ($updater->updateRowExists($maint)) {
             continue;
         }
         $child = $this->runChild($maint);
         $child->execute();
         $updater->insertUpdateRow($maint);
     }
     $this->output("\nDone.\n");
 }
Пример #12
0
require_once dirname(__FILE__) . '/commandLine.inc';
require "updaters.inc";
$wgTitle = Title::newFromText("MediaWiki database updater");
echo "MediaWiki {$wgVersion} Updater\n\n";
if (!isset($options['skip-compat-checks'])) {
    install_version_checks();
} else {
    print "Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n";
    wfCountdown(5);
}
# Attempt to connect to the database as a privileged user
# This will vomit up an error if there are permissions problems
$wgDatabase = wfGetDB(DB_MASTER);
print "Going to run database updates for " . wfWikiID() . "\n";
print "Depending on the size of your database this may take a while!\n";
if (!isset($options['quick'])) {
    print "Abort with control-c in the next five seconds (skip this countdown with --quick) ... ";
    wfCountDown(5);
}
$shared = isset($options['doshared']);
$purge = !isset($options['nopurge']);
do_all_updates($shared, $purge);
print "Done.\n";
function wfSetupUpdateScript()
{
    global $wgLocalisationCacheConf;
    # Don't try to access the database
    # This needs to be disabled early since extensions will try to use the l10n
    # cache from $wgExtensionSetupFunctions (bug 20471)
    $wgLocalisationCacheConf = array('class' => 'LocalisationCache', 'storeClass' => 'LCStore_Null', 'storeDirectory' => false, 'manualRecache' => false);
}
Пример #13
0
    $filterarray[] = NS_CATEGORY;
}
if (array_key_exists('p', $options)) {
    $filterarray[] = SMW_NS_PROPERTY;
}
if (array_key_exists('t', $options)) {
    $filterarray[] = SMW_NS_TYPE;
}
$filter = count($filterarray) > 0 ? $filterarray : false;
if (array_key_exists('f', $options)) {
    print "\n  Deleting all stored data completely and rebuilding it again later!\n  Semantic data in the wiki might be incomplete for some time while this operation runs.\n\n  NOTE: It is usually necessary to run this script ONE MORE TIME after this operation,\n  since some properties' types are not stored yet in the first run.\n  The first run can normally use the parameter -p to refresh only properties.\n\n";
    if (array_key_exists('s', $options) || array_key_exists('e', $options)) {
        print "  WARNING: -s or -e are used, so some pages will not be refreshed at all!\n    Data for those pages will only be available again when they have been\n    refreshed as well!\n\n";
    }
    print 'Abort with control-c in the next five seconds ...  ';
    wfCountDown(6);
    smwfGetStore()->drop($verbose);
    wfRunHooks('smwDropTables');
    print "\n";
    SMWStore::setupStore($verbose);
    while (ob_get_level() > 0) {
        // be sure to have some buffer, otherwise some PHPs complain
        ob_end_flush();
    }
    echo "\nAll storage structures have been deleted and recreated.\n\n";
}
$linkCache = LinkCache::singleton();
$num_files = 0;
if ($pages == false) {
    print "Refreshing all semantic data in the database!\n---\n" . " Some versions of PHP suffer from memory leaks in long-running scripts.\n" . " If your machine gets very slow after many pages (typically more than\n" . " 1000) were refreshed, please abort with CTRL-C and resume this script\n" . " at the last processed page id using the parameter -s (use -v to display\n" . " page ids during refresh). Continue this until all pages were refreshed.\n---\n";
    print "Processing all IDs from {$start} to " . ($end ? "{$end}" : 'last ID') . " ...\n";
if (  array_key_exists( 'f', $options ) ) {
	print "\n  Deleting all stored data completely and rebuilding it again later!\n  Semantic data in the wiki might be incomplete for some time while this operation runs.\n\n  NOTE: It is usually necessary to run this script ONE MORE TIME after this operation,\n  since some properties' types are not stored yet in the first run.\n  The first run can normally use the parameter -p to refresh only properties.\n\n";
	if ( ( array_key_exists( 's', $options ) )  || ( array_key_exists( 'e', $options ) ) ) {
		print "  WARNING: -s or -e are used, so some pages will not be refreshed at all!\n    Data for those pages will only be available again when they have been\n    refreshed as well!\n\n";
	}

	print 'Abort with control-c in the next five seconds ...  ';

	// TODO
	// Remove the following section and replace it with a simple
	// wfCountDown as soon as we switch to MediaWiki 1.16.
	// Currently, wfCountDown is only supported from
	// revision 51650 (Jun 9 2009) onward.
	$n = 6;
	if ( function_exists( 'wfCountDown' ) ) {
		wfCountDown( $n );
	} else {
		for ( $i = $n; $i >= 0; $i-- ) {
			if ( $i != $n ) {
				echo str_repeat( "\x08", strlen( $i + 1 ) );
			}
			echo $i;
			flush();
			if ( $i ) {
				sleep( 1 );
			}
		}
		echo "\n";
	}
	// Remove up to here and just uncomment the following line:
	// wfCountDown( 6 );
Пример #15
0
	public function execute() {
		global $smwgDefaultStore;

		$alternativestore = $this->getArg( 'backend', false );
		$alternativestore = $alternativestore !== false && $alternativestore !== $smwgDefaultStore;
		
		if ( $alternativestore !== false ) {
			$smwgDefaultStore = $this->getArg( 'backend', false );
			print "\nSelected storage " . $smwgDefaultStore . " for update!\n\n";
		}
		
		global $smwgIP;
		if ( !isset( $smwgIP ) ) {
			$smwgIP = dirname( __FILE__ ) . '/../';
		}
		
		require_once( $smwgIP . 'includes/SMW_GlobalFunctions.php' );
		
		if ( $this->hasOption( 'delete' ) ) {
			print "\n  Deleting all stored data for $smwgDefaultStore completely!\n  \n\n";
			if ( $alternativestore ) {
				print "  This store is currently not used by SMW. Deleting it\n  should not cause problems in the wiki.\n\n";
				$delay = 5;
			} else {
				print "  WARNING: This store is currently used by SMW! Deleting it\n           will cause problems in the wiki if SMW is enabled.\n\n";
				$delay = 20;
			}
		
			print "Abort with CTRL-C in the next $delay seconds ...  ";
		
			// TODO
			// Remove the following section and replace it with a simple
			// wfCountDown as soon as we switch to MediaWiki 1.16.
			// Currently, wfCountDown is only supported from
			// revision 51650 (Jun 9 2009) onward.
			if ( function_exists( 'wfCountDown' ) ) {
				wfCountDown( $delay );
			} else {
				for ( $i = $delay; $i >= 0; $i-- ) {
					if ( $i != $delay ) {
						echo str_repeat( "\x08", strlen( $i + 1 ) );
					}
					echo $i;
					flush();
					if ( $i ) {
						sleep( 1 );
					}
				}
				echo "\n";
			}
			// Remove up to here and just uncomment the following line:
			// wfCountDown( $delay );
		
			smwfGetStore()->drop( true );
			wfRunHooks( 'smwDropTables' );
			print "\n";
			while ( ob_get_level() > 0 ) { // be sure to have some buffer, otherwise some PHPs complain
				ob_end_flush();
			}
			echo "\n  All storage structures for $smwgDefaultStore have been deleted.\n  You can recreate them with this script, and then use\n  SMW_refreshData.php to rebuild their contents.";
		} else {
			smwfGetStore()->setup();
			wfRunHooks( 'smwInitializeTables' );
		}
	}