updated i18n i10n_update workflwo imachecache_actions

This commit is contained in:
2020-06-23 12:41:21 +02:00
parent 8c39ab6f4a
commit 092758ecb0
134 changed files with 2894 additions and 1205 deletions
@@ -202,7 +202,11 @@ function l10n_update_admin_settings_form($form, &$form_state) {
'#default_value' => variable_get('l10n_update_download_store', ''),
'#description' => t('A path relative to the Drupal installation directory where translation files will be stored, e.g. sites/all/translations. Saved translation files can be reused by other installations. If left empty the downloaded translation will not be saved.'),
);
return system_settings_form($form);
$form = system_settings_form($form);
$form['#submit'][] = 'l10n_update_admin_settings_form_submit';
return $form;
}
/**
@@ -220,6 +224,14 @@ function l10n_update_admin_settings_form_validate($form, &$form_state) {
}
}
/**
* Additional submit handler for update settings.
*/
function l10n_update_admin_settings_form_submit($form, &$form_state) {
// Add .htaccess file to the translations directory.
l10n_update_ensure_htaccess();
}
/**
* Get array of import options.
*
@@ -6,9 +6,8 @@ package = Multilingual
files[] = l10n_update.parser.inc
; Information added by Drupal.org packaging script on 2014-11-10
version = "7.x-1.1"
; Information added by Drupal.org packaging script on 2019-12-16
version = "7.x-1.4"
core = "7.x"
project = "l10n_update"
datestamp = "1415605322"
datestamp = "1576494267"
@@ -15,7 +15,7 @@ function l10n_update_schema() {
'name' => array(
'description' => 'A unique short name to identify the project.',
'type' => 'varchar',
'length' => '50',
'length' => '255',
'not null' => TRUE,
),
'project_type' => array(
@@ -68,7 +68,7 @@ function l10n_update_schema() {
'project' => array(
'description' => 'A unique short name to identify the project.',
'type' => 'varchar',
'length' => '50',
'length' => '255',
'not null' => TRUE,
),
'language' => array(
@@ -207,6 +207,27 @@ function l10n_update_requirements($phase) {
$requirements['l10n_update']['value'] = t('Not enabled');
$requirements['l10n_update']['severity'] = REQUIREMENT_INFO;
}
// Test the contents of the .htaccess file in the translations directory.
$directory = variable_get('l10n_update_download_store', '');
if ($directory) {
l10n_update_ensure_htaccess();
$htaccess_file = $directory . '/.htaccess';
// Check for the string which was added to the recommended .htaccess file
// in the latest security update.
if (!file_exists($htaccess_file) || !($contents = @file_get_contents($htaccess_file)) || strpos($contents, 'Drupal_Security_Do_Not_Remove_See_SA_2013_003') === FALSE) {
$requirements['l10n_update_htaccess'] = array(
'title' => t('Translations directory'),
'value' => t('Not fully protected'),
'severity' => REQUIREMENT_ERROR,
'description' => t('See <a href="@url">@url</a> for information about the recommended .htaccess file which should be added to the %directory directory to help protect against arbitrary code execution.', array(
'@url' => 'http://drupal.org/SA-CORE-2013-003',
'%directory' => $directory
)),
);
}
}
return $requirements;
}
// We must always return array, the installer doesn't use module_invoke_all()
@@ -297,3 +318,36 @@ function l10n_update_update_7005() {
function l10n_update_update_7006() {
registry_rebuild();
}
/**
* Increase the length of the {l10n_update_project}.name column.
*/
function l10n_update_update_7007() {
$schema = l10n_update_schema();
db_change_field('l10n_update_project', 'name', 'name', $schema['l10n_update_project']['fields']['name']);
}
/**
* Increase the length of the {l10n_update_file}.project column.
*/
function l10n_update_update_7008() {
$schema = l10n_update_schema();
db_change_field('l10n_update_file', 'project', 'project', $schema['l10n_update_file']['fields']['project']);
}
/**
* Remove 'headers' field from cache table.
*/
function l10n_update_update_7009() {
if (db_field_exists('cache_l10n_update', 'headers')) {
db_drop_field('cache_l10n_update', 'headers');
}
}
/**
* Add a .htaccess file to the translations directory.
*/
function l10n_update_update_7010() {
module_load_include('module', 'l10n_update');
l10n_update_ensure_htaccess();
}
@@ -494,3 +494,13 @@ function l10n_update_flush_caches() {
}
return array();
}
/**
* Creates a .htaccess file in the translations directory if it is missing.
*/
function l10n_update_ensure_htaccess() {
$directory = variable_get('l10n_update_download_store', '');
if ($directory) {
file_create_htaccess($directory, FALSE);
}
}
@@ -47,42 +47,18 @@ function l10n_update_build_projects($refresh = FALSE) {
$default_server = l10n_update_default_server();
if (module_exists('update')) {
$projects_info = update_get_available(TRUE);
}
foreach ($projects as $name => $data) {
// Force update fetch of project data in cases where Drupal's performance
// optimized approach is missing out on some projects.
// @see http://drupal.org/node/1671570#comment-6216090
if (module_exists('update') && !isset($projects_info[$name])) {
module_load_include('fetch.inc', 'update');
_update_process_fetch_task($data);
$available = _update_get_cached_available_releases();
if (!empty($available[$name])) {
$projects_info[$name] = $available[$name];
// For dev releases, remove the '-dev' part and trust the translation server
// to fall back to the latest stable release for that branch.
if (isset($data['info']['version']) && strpos($data['info']['version'], '-dev')) {
if (preg_match("/^(\d+\.x-\d+\.).*$/", $data['info']['version'], $matches)) {
// Example matches: 7.x-1.x-dev, 7.x-1.0-alpha1+5-dev => 7.x-1.x
$data['info']['version'] = $matches[1] . 'x';
}
}
if (isset($projects_info[$name]['releases']) && $projects_info[$name]['project_status'] != 'not-fetched') {
// Find out if a dev version is installed.
if (preg_match("/^[0-9]+\.x-([0-9]+)\..*-dev$/", $data['info']['version'], $matches)) {
// Find a suitable release to use as alternative translation.
foreach ($projects_info[$name]['releases'] as $project_release) {
// The first release with the same major release number which is not
// a dev release is the one. Releases are sorted the most recent first.
if ($project_release['version_major'] == $matches[1] &&
(!isset($project_release['version_extra']) || $project_release['version_extra'] != 'dev')) {
$release = $project_release;
break;
}
}
elseif (preg_match("/^(\d+\.).*$/", $data['info']['version'], $matches)) {
// Example match: 7.33-dev => 7.x (Drupal core)
$data['info']['version'] = $matches[1] . 'x';
}
if (!empty($release['version'])) {
$data['info']['version'] = $release['version'];
}
unset($release);
}
$data += array(
@@ -228,7 +204,7 @@ function _l10n_update_project_info_list(&$projects, $list, $project_type, $disab
'name' => $project_name,
'info' => $file->info,
'datestamp' => isset($file->info['datestamp']) ? $file->info['datestamp'] : 0,
'includes' => array($file->name => $file->info['name']),
'includes' => array($file->name => isset($file->info['name']) ? $file->info['name'] : $file->name),
'project_type' => $project_name == 'drupal' ? 'core' : $project_type,
);
}