Skip to content
Snippets Groups Projects
Commit 16f9ca27 authored by catch's avatar catch
Browse files

Issue #778346 by vsujeetkumar, xjm, dhirendra.mishra, pillarsdotnet,...

Issue #778346 by vsujeetkumar, xjm, dhirendra.mishra, pillarsdotnet, sudiptadas19, cwgordon7, daffie, quietone: system_sort_modules_by_info_name() is misnamed
parent cf237624
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ public function index() { ...@@ -50,7 +50,7 @@ public function index() {
$module_info[$module]->info = $info; $module_info[$module]->info = $info;
} }
uasort($module_info, 'system_sort_modules_by_info_name'); uasort($module_info, 'system_sort_by_info_name');
$menu_items = []; $menu_items = [];
foreach ($module_info as $module => $info) { foreach ($module_info as $module => $info) {
......
...@@ -203,7 +203,7 @@ public function themesPage() { ...@@ -203,7 +203,7 @@ public function themesPage() {
$config = $this->config('system.theme'); $config = $this->config('system.theme');
// Get all available themes. // Get all available themes.
$themes = $this->themeHandler->rebuildThemeData(); $themes = $this->themeHandler->rebuildThemeData();
uasort($themes, 'system_sort_modules_by_info_name'); uasort($themes, 'system_sort_by_info_name');
$theme_default = $config->get('default'); $theme_default = $config->get('default');
$theme_groups = ['installed' => [], 'uninstalled' => []]; $theme_groups = ['installed' => [], 'uninstalled' => []];
......
...@@ -170,7 +170,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ...@@ -170,7 +170,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
// The module list needs to be reset so that it can re-scan and include // The module list needs to be reset so that it can re-scan and include
// any new modules that may have been added directly into the filesystem. // any new modules that may have been added directly into the filesystem.
$modules = $this->moduleExtensionList->reset()->getList(); $modules = $this->moduleExtensionList->reset()->getList();
uasort($modules, 'system_sort_modules_by_info_name'); uasort($modules, 'system_sort_by_info_name');
} }
catch (InfoParserException $e) { catch (InfoParserException $e) {
$this->messenger()->addError($this->t('Modules could not be listed due to an error: %error', ['%error' => $e->getMessage()])); $this->messenger()->addError($this->t('Modules could not be listed due to an error: %error', ['%error' => $e->getMessage()]));
......
...@@ -144,7 +144,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ...@@ -144,7 +144,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
} }
// Sort all modules by their name. // Sort all modules by their name.
uasort($uninstallable, 'system_sort_modules_by_info_name'); uasort($uninstallable, 'system_sort_by_info_name');
$validation_reasons = $this->moduleInstaller->validateUninstall(array_keys($uninstallable)); $validation_reasons = $this->moduleInstaller->validateUninstall(array_keys($uninstallable));
$form['uninstall'] = ['#tree' => TRUE]; $form['uninstall'] = ['#tree' => TRUE];
......
...@@ -893,6 +893,14 @@ function system_region_list($theme, $show = REGIONS_ALL) { ...@@ -893,6 +893,14 @@ function system_region_list($theme, $show = REGIONS_ALL) {
* Array sorting callback; sorts modules by their name. * Array sorting callback; sorts modules by their name.
*/ */
function system_sort_modules_by_info_name($a, $b) { function system_sort_modules_by_info_name($a, $b) {
@trigger_error('system_sort_modules_by_info_name() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Implement system_sort_by_info_name() instead. See https://www.drupal.org/node/3225624', E_USER_DEPRECATED);
return system_sort_by_info_name($a, $b);
}
/**
* Array sorting callback; sorts modules by their name.
*/
function system_sort_by_info_name($a, $b) {
return strcasecmp($a->info['name'], $b->info['name']); return strcasecmp($a->info['name'], $b->info['name']);
} }
...@@ -902,7 +910,7 @@ function system_sort_modules_by_info_name($a, $b) { ...@@ -902,7 +910,7 @@ function system_sort_modules_by_info_name($a, $b) {
* Callback for uasort() within * Callback for uasort() within
* \Drupal\system\Controller\SystemController::themesPage(). * \Drupal\system\Controller\SystemController::themesPage().
* *
* @see system_sort_modules_by_info_name() * @see system_sort_by_info_name()
*/ */
function system_sort_themes($a, $b) { function system_sort_themes($a, $b) {
if ($a->is_default) { if ($a->is_default) {
......
<?php
namespace Drupal\Tests\system\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* @group system
* @group legacy
*/
class SystemDeprecationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['system', 'user'];
/**
* @see system_sort_modules_by_info_name()
*/
public function testSystemSortModulesByInfoName() {
$module_info = [];
foreach (\Drupal::service('extension.list.module')->getAllInstalledInfo() as $module => $info) {
$module_info[$module] = new \stdClass();
$module_info[$module]->info = $info;
}
$this->expectDeprecation('system_sort_modules_by_info_name() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Implement system_sort_by_info_name() instead. See https://www.drupal.org/node/3225624');
uasort($module_info, 'system_sort_modules_by_info_name');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment