Skip to content
Snippets Groups Projects
Unverified Commit 6b6facdc authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3422977 by secretsayan, traviscarden, nexusnovaz, joachim, smustgrave,...

Issue #3422977 by secretsayan, traviscarden, nexusnovaz, joachim, smustgrave, xjm, catch: Rename locale batch operation callbacks to match the API methods they call
parent de542f58
Branches
Tags
13 merge requests!11197Issue #3506427 by eduardo morales alberti: Remove responsive_image.ajax from hook,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!10786Issue #3490579 by shalini_jha, mstrelan: Add void return to all views...,!10210Issue #3487907: Drupal.displace() use getComputedStyle() for hidden chk.,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3478Issue #3337882: Deleted menus are not removed from content type config,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!579Issue #2230909: Simple decimals fail to pass validation
Pipeline #342195 failed
......@@ -571,7 +571,7 @@ function locale_config_batch_update_components(array $options, array $langcodes
* @return array
* The batch definition.
*
* @see locale_config_batch_refresh_name()
* @see locale_config_batch_update_config_translations()
*/
function locale_config_batch_build(array $names, array $langcodes, array $options = [], bool $update_default_config_langcodes = FALSE) {
$options += ['finish_feedback' => TRUE];
......@@ -582,7 +582,7 @@ function locale_config_batch_build(array $names, array $langcodes, array $option
->setErrorMessage(t('Error updating configuration translations'));
if ($update_default_config_langcodes && \Drupal::languageManager()->getDefaultLanguage()->getId() !== 'en') {
$batch_builder->addOperation('locale_config_batch_set_config_langcodes');
$batch_builder->addOperation('locale_config_batch_update_default_config_langcodes');
}
// Chunking the array of names into batches of 20 for better performance.
......@@ -593,7 +593,7 @@ function locale_config_batch_build(array $names, array $langcodes, array $option
// it is very expensive to initialize the \Drupal::config() object on each
// request. We batch a small number of configuration object upgrades
// together to improve the overall performance of the process.
$batch_builder->addOperation('locale_config_batch_refresh_name', [$chunk, $langcodes]);
$batch_builder->addOperation('locale_config_batch_update_config_translations', [$chunk, $langcodes]);
}
if (!empty($options['finish_feedback'])) {
......@@ -610,12 +610,30 @@ function locale_config_batch_build(array $names, array $langcodes, array $option
* @param array|\ArrayAccess $context
* The batch context.
*/
function locale_config_batch_set_config_langcodes(&$context) {
function locale_config_batch_update_default_config_langcodes(&$context): void {
\Drupal::service('locale.config_manager')->updateDefaultConfigLangcodes();
$context['finished'] = 1;
$context['message'] = t('Updated default configuration to %langcode', ['%langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId()]);
}
/**
* Implements callback_batch_operation().
*
* Updates default configuration when new modules or themes are installed.
*
* @param array|\ArrayAccess $context
* The batch context.
*
* @deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use
* locale_config_batch_update_default_config_langcodes(&$context) instead.
*
* @see https://www.drupal.org/node/3475054
*/
function locale_config_batch_set_config_langcodes(&$context): void {
@trigger_error(__METHOD__ . '() is deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use locale_config_batch_update_default_config_langcodes() instead. See https://www.drupal.org/node/3475054', E_USER_DEPRECATED);
locale_config_batch_update_default_config_langcodes($context);
}
/**
* Implements callback_batch_operation().
*
......@@ -630,7 +648,7 @@ function locale_config_batch_set_config_langcodes(&$context) {
*
* @see locale_config_batch_build()
*/
function locale_config_batch_refresh_name(array $names, array $langcodes, &$context) {
function locale_config_batch_update_config_translations(array $names, array $langcodes, &$context): void {
if (!isset($context['results']['stats']['config'])) {
$context['results']['stats']['config'] = 0;
}
......@@ -643,6 +661,28 @@ function locale_config_batch_refresh_name(array $names, array $langcodes, &$cont
$context['finished'] = 1;
}
/**
* Implements callback_batch_operation().
*
* Performs configuration translation refresh.
*
* @param array $names
* An array of names of configuration objects to update.
* @param array $langcodes
* (optional) Array of language codes to update. Defaults to all languages.
* @param array|\ArrayAccess $context
* Contains a list of files imported.
*
* @deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use
* locale_config_batch_update_config_translations($names, $langcodes, $context) instead.
*
* @see https://www.drupal.org/node/3475054
*/
function locale_config_batch_refresh_name(array $names, array $langcodes, &$context): void {
@trigger_error(__METHOD__ . '() is deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use locale_config_batch_update_config_translations() instead. See https://www.drupal.org/node/3475054', E_USER_DEPRECATED);
locale_config_batch_update_config_translations($names, $langcodes, $context);
}
/**
* Implements callback_batch_finished().
*
......
<?php
declare(strict_types=1);
namespace Drupal\Tests\locale\Unit;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\UnitTestCase;
/**
* Tests locale.bulk.inc.
*
* @group locale
*/
class LocaleBulkDeprecationTest extends UnitTestCase {
protected function setUp(): void {
parent::setUp();
$container = new ContainerBuilder();
$container->set('locale.config_manager', $this->createMock('Drupal\locale\LocaleConfigManager'));
$language_manager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager->expects($this->any())
->method('getDefaultLanguage')
->willReturn($this->createMock('Drupal\Core\Language\LanguageInterface'));
$container->set('language_manager', $language_manager);
\Drupal::setContainer($container);
include_once DRUPAL_ROOT . '/core/modules/locale/locale.bulk.inc';
}
/**
* Tests the deprecation of locale_config_batch_refresh_name().
*
* @group legacy
*
* @see locale_config_batch_refresh_name()
*/
public function testDeprecatedLocaleConfigBatchRefreshName(): void {
$this->expectDeprecation('locale_config_batch_refresh_name() is deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use locale_config_batch_update_config_translations() instead. See https://www.drupal.org/node/3475054');
$names = ['English', 'German'];
$langcodes = ['en', 'de'];
locale_config_batch_refresh_name($names, $langcodes, $context);
}
/**
* Tests the deprecation of locale_config_batch_set_config_langcodes().
*
* @group legacy
*
* @see locale_config_batch_set_config_langcodes()
*/
public function testDeprecatedLocaleConfigBatchSetConfigLangcodes(): void {
$this->expectDeprecation('locale_config_batch_set_config_langcodes() is deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use locale_config_batch_update_default_config_langcodes() instead. See https://www.drupal.org/node/3475054');
$context = [];
locale_config_batch_set_config_langcodes($context);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment