/**
  * @param DatabaseUpdater $updater
  * @return bool
  */
 public static function addSchemaUpdates(DatabaseUpdater $updater)
 {
     $base = dirname(__FILE__);
     if ($updater->getDB()->getType() == 'mysql') {
         $base = "{$base}/mysql";
         $updater->addExtensionTable('account_requests', "{$base}/ConfirmAccount.sql", true);
         $updater->addExtensionField('account_requests', 'acr_filename', "{$base}/patch-acr_filename.sql");
         $updater->addExtensionTable('addTable', 'account_credentials', "{$base}/patch-account_credentials.sql", true);
         $updater->addExtensionField('account_requests', 'acr_areas', "{$base}/patch-acr_areas.sql", true);
         $updater->addExtensionIndex('account_requests', 'acr_email', "{$base}/patch-email-index.sql", true);
     } elseif ($updater->getDB()->getType() == 'postgres') {
         $base = "{$base}/postgres";
         $updater->addExtensionUpdate(array('addTable', 'account_requests', "{$base}/ConfirmAccount.pg.sql", true));
         $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_held', "TIMESTAMPTZ"));
         $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_filename', "TEXT"));
         $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_storage_key', "TEXT"));
         $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_comment', "TEXT NOT NULL DEFAULT ''"));
         $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_type', "INTEGER NOT NULL DEFAULT 0"));
         $updater->addExtensionUpdate(array('addTable', 'account_credentials', "{$base}/patch-account_credentials.sql", true));
         $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_areas', "TEXT"));
         $updater->addExtensionUpdate(array('addPgField', 'account_credentials', 'acd_areas', "TEXT"));
         $updater->addExtensionUpdate(array('addIndex', 'account_requests', 'acr_email', "{$base}/patch-email-index.sql", true));
     }
     return true;
 }
 /**
  * LoadExtensionSchemaUpdates hook handler
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/LoadExtensionSchemaUpdates
  * @param DatabaseUpdater $updater
  */
 public static function onLoadExtensionSchemaUpdates(DatabaseUpdater $updater)
 {
     if ($updater->getDB()->getType() != 'mysql') {
         throw new MWException('GeoData extension currently supports only MySQL');
     }
     $updater->addExtensionTable('geo_tags', dirname(__FILE__) . '/GeoData.sql');
     return true;
 }
 /**
  * Schema update to set up the needed database tables.
  *
  * @since 1.2
  *
  * @param DatabaseUpdater $updater
  *
  * @return true
  */
 public static function onSchemaUpdate($updater = null)
 {
     $dbfile = dirname(__FILE__) . '/UploadWizard.' . $updater->getDB()->getType() . '.sql';
     if (!file_exists($dbfile)) {
         $dbfile = dirname(__FILE__) . '/UploadWizard.sql';
     }
     $updater->addExtensionTable('uw_campaigns', $dbfile);
     $updater->addExtensionUpdate(array('addIndex', 'uw_campaigns', 'uw_campaigns_name', dirname(__FILE__) . '/sql/UW_IndexCampaignsName.sql', true));
     $updater->addExtensionUpdate(array('addIndex', 'uw_campaigns', 'uw_campaigns_enabled', dirname(__FILE__) . '/sql/UW_IndexCampaignsEnabled.sql', true));
     return true;
 }
Example #4
0
 /** Wikia change -- moved getClientIPfromXFF() method to IP class */
 public static function checkUserSchemaUpdates(DatabaseUpdater $updater)
 {
     $base = dirname(__FILE__);
     $updater->addExtensionUpdate(array('CheckUserHooks::checkUserCreateTables'));
     if ($updater->getDB()->getType() == 'mysql') {
         $updater->addExtensionUpdate(array('addIndex', 'cu_changes', 'cuc_ip_hex_time', "{$base}/archives/patch-cu_changes_indexes.sql", true));
         $updater->addExtensionUpdate(array('addIndex', 'cu_changes', 'cuc_user_ip_time', "{$base}/archives/patch-cu_changes_indexes2.sql", true));
     }
     return true;
 }
Example #5
0
 /**
  * @author Władysław Bodzek <*****@*****.**>
  * @modify Piotr Molski <*****@*****.**>
  */
 public static function do_clean_math_table(DatabaseUpdater $updater)
 {
     $db = $updater->getDB();
     $table = 'math';
     $primaryKey = 'math_inputhash';
     $fields = array('math_inputhash', 'math_outputhash', 'math_html', 'math_mathml');
     $updater->output("Checking {$table} table and removing rows with different encoding than utf8...\n");
     if ($db->tableExists($table)) {
         $updater->output("...scanning table...");
         // Read the whole table
         $allFields = array_unique(array_merge($fields, array($primaryKey)));
         $res = $db->select(" `{$table}`", $allFields, '', __METHOD__);
         // scan for all rows containing text which is not in utf8 encoding
         $wrong = array();
         while ($row = $db->fetchRow($res)) {
             foreach ($fields as $field) {
                 if (!self::is_valid_utf8_text($row[$field])) {
                     $wrong[] = $row[$primaryKey];
                     break;
                 }
             }
         }
         $db->freeResult($res);
         $count = count($wrong);
         $updater->output("ok (found " . count($wrong) . " rows)\n");
         // and finally remove all the malformed rows
         if ($count > 0) {
             $updater->output("...removing malformed rows...");
             $pos = 0;
             $chunkSize = 500;
             while ($pos < $count) {
                 $removing = array_slice($wrong, $pos, $chunkSize);
                 $res = $db->delete($table, array($primaryKey => $removing), __METHOD__);
                 $pos += $chunkSize;
             }
             $updater->output("ok\n");
         }
     }
 }
 /**
  * @param $updater DatabaseUpdater
  * @return bool
  */
 public static function asUpdateSchema(DatabaseUpdater $updater)
 {
     $updater->addExtensionTable('spoofuser', __DIR__ . '/sql/patch-antispoof.' . $updater->getDB()->getType() . '.sql');
     return true;
 }
Example #7
0
 /**
  * Creates the necessary database table when the user runs
  * maintenance/update.php.
  *
  * @param DatabaseUpdater $updater
  * @return bool
  */
 public static function addTable($updater)
 {
     $dbt = $updater->getDB()->getType();
     $file = __DIR__ . "/vote.{$dbt}";
     if (file_exists($file)) {
         $updater->addExtensionUpdate(array('addTable', 'Vote', $file, true));
     } else {
         throw new MWException("VoteNY does not support {$dbt}.");
     }
     return true;
 }
 /**
  * Hook: LoadExtensionSchemaUpdates
  *
  * @param $updater DatabaseUpdater object
  * @return bool true in all cases
  */
 public static function getSchemaUpdates(DatabaseUpdater $updater)
 {
     $dir = __DIR__;
     $baseSQLFile = "{$dir}/flow.sql";
     $updater->addExtensionTable('flow_revision', $baseSQLFile);
     $updater->addExtensionField('flow_revision', 'rev_last_edit_id', "{$dir}/db_patches/patch-revision_last_editor.sql");
     $updater->addExtensionField('flow_revision', 'rev_mod_reason', "{$dir}/db_patches/patch-moderation_reason.sql");
     if ($updater->getDB()->getType() === 'sqlite') {
         $updater->modifyExtensionField('flow_summary_revision', 'summary_workflow_id', "{$dir}/db_patches/patch-summary2header.sqlite.sql");
         $updater->modifyExtensionField('flow_revision', 'rev_comment', "{$dir}/db_patches/patch-rev_change_type.sqlite.sql");
         // sqlite ignores field types, this just substr's uuid's to 88 bits
         $updater->modifyExtensionField('flow_workflow', 'workflow_id', "{$dir}/db_patches/patch-88bit_uuids.sqlite.sql");
         $updater->addExtensionField('flow_workflow', 'workflow_type', "{$dir}/db_patches/patch-add_workflow_type.sqlite");
         $updater->modifyExtensionField('flow_workflow', 'workflow_user_id', "{$dir}/db_patches/patch-default_null_workflow_user.sqlite.sql");
     } else {
         // sqlite doesn't support alter table change, it also considers all types the same so
         // this patch doesn't matter to it.
         $updater->modifyExtensionField('flow_subscription', 'subscription_user_id', "{$dir}/db_patches/patch-subscription_user_id.sql");
         // renames columns, alternate patch is above for sqlite
         $updater->modifyExtensionField('flow_summary_revision', 'summary_workflow_id', "{$dir}/db_patches/patch-summary2header.sql");
         // rename rev_change_type -> rev_comment, alternate patch is above for sqlite
         $updater->modifyExtensionField('flow_revision', 'rev_comment', "{$dir}/db_patches/patch-rev_change_type.sql");
         // convert 128 bit uuid's into 88bit
         $updater->modifyExtensionField('flow_workflow', 'workflow_id', "{$dir}/db_patches/patch-88bit_uuids.sql");
         $updater->addExtensionField('flow_workflow', 'workflow_type', "{$dir}/db_patches/patch-add_workflow_type.sql");
         $updater->modifyExtensionField('flow_workflow', 'workflow_user_id', "{$dir}/db_patches/patch-default_null_workflow_user.sql");
         // Doesn't need SQLite support, since SQLite doesn't care about text widths.
         $updater->modifyExtensionField('flow_workflow', 'workflow_wiki', "{$dir}/db_patches/patch-increase_width_wiki_fields.sql");
     }
     $updater->addExtensionIndex('flow_workflow', 'flow_workflow_lookup', "{$dir}/db_patches/patch-workflow_lookup_idx.sql");
     $updater->addExtensionIndex('flow_topic_list', 'flow_topic_list_topic_id', "{$dir}/db_patches/patch-topic_list_topic_id_idx.sql");
     $updater->modifyExtensionField('flow_revision', 'rev_change_type', "{$dir}/db_patches/patch-rev_change_type_update.sql");
     $updater->modifyExtensionField('recentchanges', 'rc_source', "{$dir}/db_patches/patch-rc_source.sql");
     $updater->modifyExtensionField('flow_revision', 'rev_change_type', "{$dir}/db_patches/patch-censor_to_suppress.sql");
     $updater->addExtensionField('flow_revision', 'rev_user_ip', "{$dir}/db_patches/patch-remove_usernames.sql");
     $updater->addExtensionField('flow_revision', 'rev_user_wiki', "{$dir}/db_patches/patch-add-wiki.sql");
     $updater->addExtensionIndex('flow_tree_revision', 'flow_tree_descendant_rev_id', "{$dir}/db_patches/patch-flow_tree_idx_fix.sql");
     $updater->dropExtensionField('flow_tree_revision', 'tree_orig_create_time', "{$dir}/db_patches/patch-tree_orig_create_time.sql");
     $updater->addExtensionIndex('flow_revision', 'flow_revision_user', "{$dir}/db_patches/patch-revision_user_idx.sql");
     $updater->modifyExtensionField('flow_revision', 'rev_user_ip', "{$dir}/db_patches/patch-revision_user_ip.sql");
     $updater->addExtensionField('flow_revision', 'rev_type_id', "{$dir}/db_patches/patch-rev_type_id.sql");
     $updater->addExtensionTable('flow_ext_ref', "{$dir}/db_patches/patch-add-linkstables.sql");
     $updater->dropExtensionTable('flow_definition', "{$dir}/db_patches/patch-drop_definition.sql");
     $updater->dropExtensionField('flow_workflow', 'workflow_user_ip', "{$dir}/db_patches/patch-drop_workflow_user.sql");
     $updater->addExtensionField('flow_revision', 'rev_content_length', "{$dir}/db_patches/patch-add-revision-content-length.sql");
     $updater->addExtensionIndex('flow_ext_ref', 'flow_ext_ref_idx', "{$dir}/db_patches/patch-remove_unique_ref_indices.sql");
     $updater->addExtensionIndex('flow_workflow', 'flow_workflow_update_timestamp', "{$dir}/db_patches/patch-flow_workflow_update_timestamp_idx.sql");
     require_once __DIR__ . '/maintenance/FlowUpdateRecentChanges.php';
     $updater->addPostDatabaseUpdateMaintenance('FlowUpdateRecentChanges');
     require_once __DIR__ . '/maintenance/FlowSetUserIp.php';
     $updater->addPostDatabaseUpdateMaintenance('FlowSetUserIp');
     /*
      * Remove old *_user_text columns once the maintenance script that
      * moves the necessary data has been run.
      * This duplicates what is being done in FlowSetUserIp already, but that
      * was not always the case, so that script may have already run without
      * having executed this.
      */
     if ($updater->updateRowExists('FlowSetUserIp')) {
         $updater->dropExtensionField('flow_revision', 'rev_user_text', "{$dir}/db_patches/patch-remove_usernames_2.sql");
     }
     require_once __DIR__ . '/maintenance/FlowUpdateUserWiki.php';
     $updater->addPostDatabaseUpdateMaintenance('FlowUpdateUserWiki');
     require_once __DIR__ . '/maintenance/FlowUpdateRevisionTypeId.php';
     $updater->addPostDatabaseUpdateMaintenance('FlowUpdateRevisionTypeId');
     require_once __DIR__ . '/maintenance/FlowPopulateLinksTables.php';
     $updater->addPostDatabaseUpdateMaintenance('FlowPopulateLinksTables');
     require_once __DIR__ . '/maintenance/FlowFixLog.php';
     $updater->addPostDatabaseUpdateMaintenance('FlowFixLog');
     require_once __DIR__ . '/maintenance/FlowUpdateWorkflowPageId.php';
     $updater->addPostDatabaseUpdateMaintenance('FlowUpdateWorkflowPageId');
     require_once __DIR__ . '/maintenance/FlowCreateMentionTemplate.php';
     $updater->addPostDatabaseUpdateMaintenance('FlowCreateMentionTemplate');
     return true;
 }