core security update

This commit is contained in:
Bachir Soussi Chiadmi
2016-10-13 12:11:14 +02:00
parent 747127f643
commit 1a06561593
306 changed files with 7346 additions and 2431 deletions

View File

@@ -196,6 +196,12 @@ function system_requirements($phase) {
);
}
// Test database-specific multi-byte UTF-8 related requirements.
$charset_requirements = _system_check_db_utf8mb4_requirements($phase);
if (!empty($charset_requirements)) {
$requirements['database_charset'] = $charset_requirements;
}
// Test PHP memory_limit
$memory_limit = ini_get('memory_limit');
$requirements['php_memory_limit'] = array(
@@ -517,6 +523,75 @@ function system_requirements($phase) {
return $requirements;
}
/**
* Checks whether the requirements for multi-byte UTF-8 support are met.
*
* @param string $phase
* The hook_requirements() stage.
*
* @return array
* A requirements array with the result of the charset check.
*/
function _system_check_db_utf8mb4_requirements($phase) {
global $install_state;
// In the requirements check of the installer, skip the utf8mb4 check unless
// the database connection info has been preconfigured by hand with valid
// information before running the installer, as otherwise we cannot get a
// valid database connection object.
if (isset($install_state['settings_verified']) && !$install_state['settings_verified']) {
return array();
}
$connection = Database::getConnection();
$t = get_t();
$requirements['title'] = $t('Database 4 byte UTF-8 support');
$utf8mb4_configurable = $connection->utf8mb4IsConfigurable();
$utf8mb4_active = $connection->utf8mb4IsActive();
$utf8mb4_supported = $connection->utf8mb4IsSupported();
$driver = $connection->driver();
$documentation_url = 'https://www.drupal.org/node/2754539';
if ($utf8mb4_active) {
if ($utf8mb4_supported) {
if ($phase != 'install' && $utf8mb4_configurable && !variable_get('drupal_all_databases_are_utf8mb4', FALSE)) {
// Supported, active, and configurable, but not all database tables
// have been converted yet.
$requirements['value'] = $t('Enabled, but database tables need conversion');
$requirements['description'] = $t('Please convert all database tables to utf8mb4 prior to enabling it in settings.php. See the <a href="@url">documentation on adding 4 byte UTF-8 support</a> for more information.', array('@url' => $documentation_url));
$requirements['severity'] = REQUIREMENT_ERROR;
}
else {
// Supported, active.
$requirements['value'] = $t('Enabled');
$requirements['description'] = $t('4 byte UTF-8 for @driver is enabled.', array('@driver' => $driver));
$requirements['severity'] = REQUIREMENT_OK;
}
}
else {
// Not supported, active.
$requirements['value'] = $t('Not supported');
$requirements['description'] = $t('4 byte UTF-8 for @driver is activated, but not supported on your system. Please turn this off in settings.php, or ensure that all database-related requirements are met. See the <a href="@url">documentation on adding 4 byte UTF-8 support</a> for more information.', array('@driver' => $driver, '@url' => $documentation_url));
$requirements['severity'] = REQUIREMENT_ERROR;
}
}
else {
if ($utf8mb4_supported) {
// Supported, not active.
$requirements['value'] = $t('Not enabled');
$requirements['description'] = $t('4 byte UTF-8 for @driver is not activated, but it is supported on your system. It is recommended that you enable this to allow 4-byte UTF-8 input such as emojis, Asian symbols and mathematical symbols to be stored correctly. See the <a href="@url">documentation on adding 4 byte UTF-8 support</a> for more information.', array('@driver' => $driver, '@url' => $documentation_url));
$requirements['severity'] = REQUIREMENT_INFO;
}
else {
// Not supported, not active.
$requirements['value'] = $t('Disabled');
$requirements['description'] = $t('4 byte UTF-8 for @driver is disabled. See the <a href="@url">documentation on adding 4 byte UTF-8 support</a> for more information.', array('@driver' => $driver, '@url' => $documentation_url));
$requirements['severity'] = REQUIREMENT_INFO;
}
}
return $requirements;
}
/**
* Implements hook_install().
*/
@@ -532,6 +607,9 @@ function system_install() {
module_list(TRUE);
module_implements('', FALSE, TRUE);
// Ensure the schema versions are not based on a previous module list.
drupal_static_reset('drupal_get_schema_versions');
// Load system theme data appropriately.
system_rebuild_theme_data();
@@ -800,6 +878,7 @@ function system_schema() {
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'binary' => TRUE,
),
'type' => array(
'description' => 'The date format type, e.g. medium.',
@@ -2803,6 +2882,16 @@ function system_update_7061(&$sandbox) {
->from($query)
->execute();
// Retrieve a list of duplicate files with the same filepath. Only the
// most-recently uploaded of these will be moved to the new {file_managed}
// table (and all references will be updated to point to it), since
// duplicate file URIs are not allowed in Drupal 7.
// Since the Drupal 6 to 7 upgrade path leaves the {files} table behind
// after it's done, custom or contributed modules which need to migrate
// file references of their own can use a similar query to determine the
// file IDs that duplicate filepaths were mapped to.
$sandbox['duplicate_filepath_fids_to_use'] = db_query("SELECT filepath, MAX(fid) FROM {files} GROUP BY filepath HAVING COUNT(*) > 1")->fetchAllKeyed();
// Initialize batch update information.
$sandbox['progress'] = 0;
$sandbox['last_vid_processed'] = -1;
@@ -2832,6 +2921,16 @@ function system_update_7061(&$sandbox) {
continue;
}
// If this file has a duplicate filepath, replace it with the
// most-recently uploaded file that has the same filepath.
if (isset($sandbox['duplicate_filepath_fids_to_use'][$file['filepath']]) && $record->fid != $sandbox['duplicate_filepath_fids_to_use'][$file['filepath']]) {
$file = db_select('files', 'f')
->fields('f', array('fid', 'uid', 'filename', 'filepath', 'filemime', 'filesize', 'status', 'timestamp'))
->condition('f.fid', $sandbox['duplicate_filepath_fids_to_use'][$file['filepath']])
->execute()
->fetchAssoc();
}
// Add in the file information from the upload table.
$file['description'] = $record->description;
$file['display'] = $record->list;
@@ -3157,6 +3256,35 @@ function system_update_7079() {
db_change_field('file_managed', 'filesize', 'filesize', $spec);
}
/**
* Convert the 'format' column in {date_format_locale} to case sensitive varchar.
*/
function system_update_7080() {
$spec = array(
'description' => 'The date format string.',
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'binary' => TRUE,
);
db_change_field('date_format_locale', 'format', 'format', $spec);
}
/**
* Remove the Drupal 6 default install profile if it is still in the database.
*/
function system_update_7081() {
// Sites which used the default install profile in Drupal 6 and then updated
// to Drupal 7.44 or earlier will still have a record of this install profile
// in the database that needs to be deleted.
db_delete('system')
->condition('filename', 'profiles/default/default.profile')
->condition('type', 'module')
->condition('status', 0)
->condition('schema_version', 0)
->execute();
}
/**
* @} End of "defgroup updates-7.x-extra".
* The next series of updates should start at 8000.