/** * This function verifies that the database is not using an unsupported storage engine. * * @param environment_results $result object to update, if relevant * @return environment_results|null updated results object, or null if the storage engine is supported */ function check_database_storage_engine(environment_results $result) { global $DB; // Check if MySQL is the DB family (this will also be the same for MariaDB). if ($DB->get_dbfamily() == 'mysql') { // Get the database engine we will either be using to install the tables, or what we are currently using. $engine = $DB->get_dbengine(); // Check if MyISAM is the storage engine that will be used, if so, do not proceed and display an error. if ($engine == 'MyISAM') { $result->setInfo('unsupported_db_storage_engine'); $result->setStatus(false); return $result; } } return null; }
/** * This function will check if database requirements are satisfied * * @global object * @uses NO_VERSION_DATA_FOUND * @uses NO_DATABASE_SECTION_FOUND * @uses NO_DATABASE_VENDORS_FOUND * @uses NO_DATABASE_VENDOR_MYSQL_FOUND * @uses NO_DATABASE_VENDOR_POSTGRES_FOUND * @uses NO_DATABASE_VENDOR_VERSION_FOUND * @param string $version xml version we are going to use to test this server * @param int $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. * @return object results encapsulated in one environment_result object */ function environment_check_database($version, $env_select) { global $DB; $result = new environment_results('database'); $vendors = array(); //Array of vendors in version /// Get the enviroment version we need if (!($data = get_environment_for_version($version, $env_select))) { /// Error. No version data found $result->setStatus(false); $result->setErrorCode(NO_VERSION_DATA_FOUND); return $result; } /// Extract the database part if (!isset($data['#']['DATABASE'])) { /// Error. No DATABASE section found $result->setStatus(false); $result->setErrorCode(NO_DATABASE_SECTION_FOUND); return $result; } else { /// Extract level $level = get_level($data['#']['DATABASE']['0']); } /// Extract DB vendors. At least 2 are mandatory (mysql & postgres) if (!isset($data['#']['DATABASE']['0']['#']['VENDOR'])) { /// Error. No VENDORS found $result->setStatus(false); $result->setErrorCode(NO_DATABASE_VENDORS_FOUND); return $result; } else { /// Extract vendors foreach ($data['#']['DATABASE']['0']['#']['VENDOR'] as $vendor) { if (isset($vendor['@']['name']) && isset($vendor['@']['version'])) { $vendors[$vendor['@']['name']] = $vendor['@']['version']; $vendorsxml[$vendor['@']['name']] = $vendor; } } } /// Check we have the mysql vendor version if (empty($vendors['mysql'])) { $result->setStatus(false); $result->setErrorCode(NO_DATABASE_VENDOR_MYSQL_FOUND); return $result; } /// Check we have the postgres vendor version if (empty($vendors['postgres'])) { $result->setStatus(false); $result->setErrorCode(NO_DATABASE_VENDOR_POSTGRES_FOUND); return $result; } /// Now search the version we are using (depending of vendor) $current_vendor = $DB->get_dbfamily(); $dbinfo = $DB->get_server_info(); $current_version = normalize_version($dbinfo['version']); $needed_version = $vendors[$current_vendor]; /// Check we have a needed version if (!$needed_version) { $result->setStatus(false); $result->setErrorCode(NO_DATABASE_VENDOR_VERSION_FOUND); return $result; } /// And finally compare them, saving results if (version_compare($current_version, $needed_version, '>=')) { $result->setStatus(true); } else { $result->setStatus(false); } $result->setLevel($level); $result->setCurrentVersion($current_version); $result->setNeededVersion($needed_version); $result->setInfo($current_vendor); /// Do any actions defined in the XML file. process_environment_result($vendorsxml[$current_vendor], $result); return $result; }
/** * This function verifies if the database has tables using innoDB Antelope row format. * * @param environment_results $result * @return environment_results|null updated results object, or null if no Antelope table has been found. */ function check_database_tables_row_format(environment_results $result) { global $DB; if ($DB->get_dbfamily() == 'mysql') { $generator = $DB->get_manager()->generator; foreach ($DB->get_tables(false) as $table) { $columns = $DB->get_columns($table, false); $size = $generator->guess_antelope_row_size($columns); $format = $DB->get_row_format($table); if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) { continue; } if ($format === 'Compact' or $format === 'Redundant') { $result->setInfo('unsupported_db_table_row_format'); $result->setStatus(false); return $result; } } } return null; }
/** * Checks for up-to-date TLS libraries. * * @param environment_results $result object to update, if relevant. * @return environment_results|null updated results or null if unoconv path is not executable. */ function check_tls_libraries(environment_results $result) { global $CFG; if (!\core\upgrade\util::validate_php_curl_tls(curl_version(), PHP_ZTS)) { $result->setInfo('invalid ssl/tls configuration'); $result->setStatus(false); return $result; } if (!\core\upgrade\util::can_use_tls12(curl_version(), php_uname('r'))) { $result->setInfo('ssl/tls configuration not supported'); $result->setStatus(false); return $result; } return null; }
/** * Check if recommended version of libcurl is installed or not. * * @param environment_results $result object to update, if relevant. * @return environment_results|null updated results or null. */ function check_libcurl_version(environment_results $result) { if (!function_exists('curl_version')) { $result->setInfo('cURL PHP extension is not installed'); $result->setStatus(false); return $result; } // Supported version and version number. $supportedversion = 0x71304; $supportedversionstring = "7.19.4"; // Installed version. $curlinfo = curl_version(); $currentversion = $curlinfo['version_number']; if ($currentversion < $supportedversion) { // Test fail. // Set info, we want to let user know how to resolve the problem. $result->setInfo('Libcurl version check'); $result->setNeededVersion($supportedversionstring); $result->setCurrentVersion($curlinfo['version']); $result->setStatus(false); return $result; } return null; }
/** * Method used to check the installed unoconv version. * * @param environment_results $result object to update, if relevant. * @return environment_results|null updated results or null if unoconv path is not executable. */ function check_unoconv_version(environment_results $result) { global $CFG; if (!during_initial_install() && !empty($CFG->pathtounoconv) && file_is_executable(trim($CFG->pathtounoconv))) { $unoconvbin = \escapeshellarg($CFG->pathtounoconv); $command = "{$unoconvbin} --version"; exec($command, $output); preg_match('/([0-9]+\\.[0-9]+)/', $output[0], $matches); $currentversion = (double) $matches[0]; $supportedversion = 0.7; if ($currentversion < $supportedversion) { $result->setInfo('unoconv version not supported'); $result->setStatus(false); return $result; } } return null; }
/** * Method used to check the installed unoconv version. * * @param environment_results $result object to update, if relevant. * @return environment_results|null updated results or null if unoconv path is not executable. */ function check_unoconv_version(environment_results $result) { global $CFG; if (!during_initial_install() && !empty($CFG->pathtounoconv) && file_is_executable(trim($CFG->pathtounoconv))) { $currentversion = 0; $supportedversion = 0.7; $unoconvbin = \escapeshellarg($CFG->pathtounoconv); $command = "{$unoconvbin} --version"; exec($command, $output); // If the command execution returned some output, then get the unoconv version. if ($output) { foreach ($output as $response) { if (preg_match('/unoconv (\\d+\\.\\d+)/', $response, $matches)) { $currentversion = (double) $matches[1]; } } } if ($currentversion < $supportedversion) { $result->setInfo('unoconv version not supported'); $result->setStatus(false); return $result; } } return null; }