optimize_tables() static public method

Optimize sql table
static public optimize_tables ( $migration = NULL, $cron = false ) : number
$migration migration class (default NULL)
$cron to know if optimize must be done (false by default)
return number of tables
    $migration->displayWarning("***** Install process of plugin TIMELINETICKET *****");
} else {
    $migration->displayWarning("***** Update process of plugin TIMELINETICKET *****");
}
$migration->displayWarning("Current Timelineticket version: {$current_version}");
$migration->displayWarning("Version to update: " . PLUGIN_TIMELINETICKET_VERSION);
// To prevent problem of execution time
ini_set("max_execution_time", "0");
ini_set("memory_limit", "-1");
$mess = '';
if ($current_version != PLUGIN_TIMELINETICKET_VERSION and $current_version != '0') {
    $mess = "Update done.";
} else {
    if ($current_version == PLUGIN_TIMELINETICKET_VERSION) {
        $mess = "No migration needed.";
    } else {
        $mess = "installation done.";
    }
}
$plugin->getFromDBbyDir("timelineticket");
$plugin->install($plugin->fields['id']);
plugin_timelineticket_install();
$migration->displayWarning($mess);
$plugin->load("timelineticket");
$plugin->activate($plugin->fields['id']);
$plugin->load("timelineticket");
if (in_array('--optimize', $_SERVER['argv'])) {
    $migration->displayTitle("Optimizing tables");
    DBmysql::optimize_tables($migration);
    $migration->displayWarning("Optimize done.");
}
Beispiel #2
0
 /**
  * Clean log cron function
  *
  * @param $task for log
  **/
 static function cronOptimize($task)
 {
     $nb = DBmysql::optimize_tables(NULL, true);
     $task->setVolume($nb);
     return 1;
 }
Beispiel #3
0
        $percent = 0;
    }
    if ($percent >= 0) {
        Html::displayProgressBar(400, $percent);
        echo '<br>';
    }
    if ($offset != -1) {
        if (restoreMySqlDump($DB, $path . "/" . $_GET["file"], $duree)) {
            echo "<div class='center'>" . "<a href=\"backup.php?file=" . $_GET["file"] . "&amp;duree={$duree}&amp;offset=" . "{$offset}&amp;cpt={$cpt}&amp;donotcheckversion=1\">";
            echo __('Automatic redirection, else click') . "</a>";
            echo "<script language='javascript' type='text/javascript'>" . "window.location=\"backup.php?file=" . $_GET["file"] . "&duree={$duree}&offset={$offset}&cpt={$cpt}&donotcheckversion=1\";" . "</script></div>";
            Html::glpi_flush();
            exit;
        }
    } else {
        DBmysql::optimize_tables(NULL, true);
        // Compatiblity for old version for utf8 complete conversion
        $cnf = new Config();
        $input['id'] = 1;
        $input['utf8_conv'] = 1;
        $cnf->update($input);
    }
}
if (isset($_POST["delfile"])) {
    if (isset($_POST['file']) && $_POST["file"] != "") {
        $filename = $_POST["file"];
        if (is_file($path . "/" . $_POST["file"])) {
            unlink($path . "/" . $_POST["file"]);
            // TRANS: %s is a file name
            echo "<div class ='center spaced'>" . sprintf(__('%s deleted'), $filename) . "</div>";
        }
Beispiel #4
0
function updateDbUpTo031()
{
    global $DB, $migration;
    $ret = array();
    // Before 0.31
    if (!TableExists("glpi_config") && !TableExists("glpi_configs")) {
        $query = "CREATE TABLE `glpi_config` (\n                  `ID` int(11) NOT NULL auto_increment,\n                  `num_of_events` varchar(200) NOT NULL default '',\n                  `jobs_at_login` varchar(200) NOT NULL default '',\n                  `sendexpire` varchar(200) NOT NULL default '',\n                  `cut` varchar(200) NOT NULL default '',\n                  `expire_events` varchar(200) NOT NULL default '',\n                  `list_limit` varchar(200) NOT NULL default '',\n                  `version` varchar(200) NOT NULL default '',\n                  `logotxt` varchar(200) NOT NULL default '',\n                  `root_doc` varchar(200) NOT NULL default '',\n                  `event_loglevel` varchar(200) NOT NULL default '',\n                  `mailing` varchar(200) NOT NULL default '',\n                  `imap_auth_server` varchar(200) NOT NULL default '',\n                  `imap_host` varchar(200) NOT NULL default '',\n                  `ldap_host` varchar(200) NOT NULL default '',\n                  `ldap_basedn` varchar(200) NOT NULL default '',\n                  `ldap_rootdn` varchar(200) NOT NULL default '',\n                  `ldap_pass` varchar(200) NOT NULL default '',\n                  `admin_email` varchar(200) NOT NULL default '',\n                  `mailing_signature` varchar(200) NOT NULL default '',\n                  `mailing_new_admin` varchar(200) NOT NULL default '',\n                  `mailing_followup_admin` varchar(200) NOT NULL default '',\n                  `mailing_finish_admin` varchar(200) NOT NULL default '',\n                  `mailing_new_all_admin` varchar(200) NOT NULL default '',\n                  `mailing_followup_all_admin` varchar(200) NOT NULL default '',\n                  `mailing_finish_all_admin` varchar(200) NOT NULL default '',\n                  `mailing_new_all_normal` varchar(200) NOT NULL default '',\n                  `mailing_followup_all_normal` varchar(200) NOT NULL default '',\n                  `mailing_finish_all_normal` varchar(200) NOT NULL default '',\n                  `mailing_new_attrib` varchar(200) NOT NULL default '',\n                  `mailing_followup_attrib` varchar(200) NOT NULL default '',\n                  `mailing_finish_attrib` varchar(200) NOT NULL default '',\n                  `mailing_new_user` varchar(200) NOT NULL default '',\n                  `mailing_followup_user` varchar(200) NOT NULL default '',\n                  `mailing_finish_user` varchar(200) NOT NULL default '',\n                  `ldap_field_name` varchar(200) NOT NULL default '',\n                  `ldap_field_email` varchar(200) NOT NULL default '',\n                  `ldap_field_location` varchar(200) NOT NULL default '',\n                  `ldap_field_realname` varchar(200) NOT NULL default '',\n                  `ldap_field_phone` varchar(200) NOT NULL default '',\n                PRIMARY KEY (`ID`)\n                ) TYPE=MyISAM AUTO_INCREMENT=2 ";
        $DB->queryOrDie($query);
        $query = "INSERT INTO `glpi_config`\n                VALUES (1, '10', '1', '1', '80', '30', '15', ' 0.31', 'GLPI powered by indepnet',\n                        '/glpi', '5', '0', '', '', '', '', '', '', '*****@*****.**', 'SIGNATURE',\n                        '1', '1', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0','1', '1', '1',\n                        'uid', 'mail', 'physicaldeliveryofficename', 'cn', 'telephonenumber')";
        $DB->queryOrDie($query);
        echo "<p class='center'>Version > 0.31  </p>";
    }
    // Save if problem with session during update
    $glpilanguage = $_SESSION["glpilanguage"];
    // < 0.78
    if (TableExists("glpi_config")) {
        // Get current version
        // Use language from session, even if sometime not reliable
        $query = "SELECT `version`, 'language'\n                FROM `glpi_config`";
        $result = $DB->queryOrDie($query, "get current version");
        $current_version = trim($DB->result($result, 0, 0));
        $glpilanguage = trim($DB->result($result, 0, 1));
        // < 0.85
    } else {
        if (FieldExists('glpi_configs', 'version')) {
            // Get current version and language
            $query = "SELECT `version`, `language`\n                FROM `glpi_configs`";
            $result = $DB->queryOrDie($query, "get current version");
            $current_version = trim($DB->result($result, 0, 0));
            $glpilanguage = trim($DB->result($result, 0, 1));
        } else {
            $configurationValues = Config::getConfigurationValues('core', array('version', 'language'));
            $current_version = $configurationValues['version'];
            $glpilanguage = $configurationValues['language'];
        }
    }
    // To prevent problem of execution time
    ini_set("max_execution_time", "0");
    $migration = new Migration($current_version);
    switch ($current_version) {
        case "0.31":
            include "update_031_04.php";
            update031to04();
        case "0.4":
        case "0.41":
            include "update_04_042.php";
            update04to042();
        case "0.42":
            showLocationUpdateForm();
            include "update_042_05.php";
            update042to05();
        case "0.5":
            include "update_05_051.php";
            update05to051();
        case "0.51":
        case "0.51a":
            include "update_051_06.php";
            update051to06();
        case "0.6":
            include "update_06_065.php";
            update06to065();
        case "0.65":
            include "update_065_068.php";
            update065to068();
        case "0.68":
            include "update_068_0681.php";
            update068to0681();
        case "0.68.1":
        case "0.68.2":
        case "0.68.3":
            // Force update content
            if (showLocationUpdateForm()) {
                $query = "UPDATE `glpi_config`\n                      SET `version` = ' 0.68.3x'";
                $DB->queryOrDie($query, "0.68.3");
                showContentUpdateForm();
                exit;
            }
        case "0.68.3x":
            // Special version for replay upgrade process from here
            include "update_0681_07.php";
            update0681to07();
        case "0.7":
        case "0.70.1":
        case "0.70.2":
            include "update_07_071.php";
            update07to071();
        case "0.71":
        case "0.71.1":
            include "update_071_0712.php";
            update071to0712();
        case "0.71.2":
            include "update_0712_0713.php";
            update0712to0713();
        case "0.71.3":
        case "0.71.4":
        case "0.71.5":
        case "0.71.6":
            include "update_0713_072.php";
            update0713to072();
        case "0.72":
            include "update_072_0721.php";
            update072to0721();
        case "0.72.1":
            include "update_0721_0722.php";
            update0721to0722();
        case "0.72.2":
        case "0.72.21":
            include "update_0722_0723.php";
            update0722to0723();
        case "0.72.3":
        case "0.72.4":
            include "update_0723_078.php";
            update0723to078();
        case "0.78":
            include "update_078_0781.php";
            update078to0781();
        case "0.78.1":
            include "update_0781_0782.php";
            update0781to0782();
        case "0.78.2":
        case "0.78.3":
        case "0.78.4":
        case "0.78.5":
            include "update_0782_080.php";
            update0782to080();
        case "0.80":
            include "update_080_0801.php";
            update080to0801();
        case "0.80.1":
        case "0.80.2":
            include "update_0801_0803.php";
            update0801to0803();
        case "0.80.3":
        case "0.80.4":
        case "0.80.5":
        case "0.80.6":
        case "0.80.61":
        case "0.80.7":
            include "update_0803_083.php";
            update0803to083();
        case "0.83":
            include "update_083_0831.php";
            update083to0831();
        case "0.83.1":
        case "0.83.2":
            include "update_0831_0833.php";
            update0831to0833();
        case "0.83.3":
        case "0.83.31":
        case "0.83.4":
        case "0.83.5":
        case "0.83.6":
        case "0.83.7":
        case "0.83.8":
        case "0.83.9":
        case "0.83.91":
            include "update_0831_084.php";
            update0831to084();
        case "0.84":
            include "update_084_0841.php";
            update084to0841();
        case "0.84.1":
        case "0.84.2":
            include "update_0841_0843.php";
            update0841to0843();
        case "0.84.3":
            include "update_0843_0844.php";
            update0843to0844();
        case "0.84.4":
        case "0.84.5":
            include "update_0845_0846.php";
            update0845to0846();
        case "0.84.6":
        case "0.84.7":
        case "0.84.8":
        case "0.84.9":
            include "update_084_085.php";
            update084to085();
        case "0.85":
        case "0.85.1":
        case "0.85.2":
            include "update_085_0853.php";
            update085to0853();
        case "0.85.3":
        case "0.85.4":
        case "0.85.5":
            include "update_0853_090.php";
            update0853to090();
        case "0.90":
            break;
        default:
            include "update_031_04.php";
            update031to04();
            include "update_04_042.php";
            update04to042();
            showLocationUpdateForm();
            include "update_042_05.php";
            update042to05();
            include "update_05_051.php";
            update05to051();
            include "update_051_06.php";
            update051to06();
            include "update_06_065.php";
            update06to065();
            include "update_065_068.php";
            update065to068();
            include "update_068_0681.php";
            update068to0681();
            // Force update content
            $query = "UPDATE `glpi_config`\n                   SET `version` = ' 0.68.3x'";
            $DB->queryOrDie($query, "0.68.3");
            showContentUpdateForm();
            exit;
    }
    // Update version number and default langage and new version_founded ---- LEAVE AT THE END
    Config::setConfigurationValues('core', array('version' => '0.90', 'language' => $glpilanguage, 'founded_new_version' => ''));
    // Update process desactivate all plugins
    $plugin = new Plugin();
    $plugin->unactivateAll();
    DBmysql::optimize_tables($migration);
    return $ret;
}
Beispiel #5
0
// Entite
$added = 0;
$entity = new Entity ();
for ($i=0 ; $i<max(1,pow($entity_number,1/2))&&$added<$entity_number ; $i++) {
   $added++;
   $newID = $entity->add(array('name'      => "entity $i",
                               'comment'   => "comment entity $i"));
   generate_entity($newID);

   for ($j=0 ; $j<mt_rand(0,pow($entity_number,1/2))&&$added<$entity_number ; $j++) {
      $added++;
      $newID2 = $entity->add(array('name'         => "s-entity $j",
                                   'comment'      => "comment s-entity $j",
                                   'entities_id'  => $newID));
      generate_entity($newID2);

      for ($k=0 ; $k<mt_rand(0,pow($entity_number,1/2))&&$added<$entity_number ; $k++) {
         $added++;
         $newID3 = $entity->add(array('name'         => "ss-entity $k",
                                      'comment'      => "comment ss-entity $k",
                                      'entities_id'  => $newID2));
         generate_entity($newID3);
      }
   }
}

DBmysql::optimize_tables();
// clean messages;
$_SESSION["MESSAGE_AFTER_REDIRECT"]=''
?>