Problem/Motivation

There's no usage in core (except hook example) and few in contrib http://codcontrib.hank.vps-private.net/search?text=theme_get_registry&fi...

Steps to reproduce

$ git grep theme_get_registry
core/includes/theme.inc:91:function theme_get_registry($complete = TRUE) {
core/lib/Drupal/Core/Render/theme.api.php:550:    $hooks = theme_get_registry();

Proposed resolution

deprecate the function

Remaining tasks

- file CR https://www.drupal.org/node/3348850
- patch and test
- review/commit

User interface changes

no

API changes

function theme_get_registry() is deprecated

Data model changes

no

Release notes snippet

Comments

andypost created an issue. See original summary.

andypost’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new2.92 KB

Here's a CR and patch

andypost’s picture

StatusFileSize
new618 bytes
new2.93 KB

fix CS

andypost’s picture

Issue tags: +Kill includes
daffie’s picture

Status: Needs review » Reviewed & tested by the community

All code changes look good to me.
Deprecation message testing has been added.
The testbot return green.
The IS and the CR are in order.
For me it is RTBC.

purencool’s picture

StatusFileSize
new2.64 KB

The result of testing patch 3348848-3.patch.

Branch

 git branch                                                                          
  10.0.x
* 10.1.x

Searching references of the theme_get_registry function being called before applying the patch.

 git grep theme_get_registry                                                         
core/includes/theme.inc:function theme_get_registry($complete = TRUE) {
core/lib/Drupal/Core/Render/theme.api.php:    $hooks = theme_get_registry();

When administering the patch the following error occurred. The issue is likely the testLegacyThemeRegistryRebuild() method was added to core.

 git apply --index 3348848-3.patch                                                   
error: patch failed: core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php:256
error: core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php: patch does not apply
@@ -256,4 +256,18 @@ public function testThemeTemplatesRegisteredByModules() {
     $this->assertEquals($expected, array_values($registry['theme_test_registered_by_module']['preprocess functions']));
   }

Using @andypost's original code a refactored patch was created and has been added to the ticket.

www-data@5e92f19c6122:/app/build/core$ ../vendor/bin/phpunit --filter=testLegacyThemeGetRegistry ../core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php                                                                                             
PHPUnit 9.6.5 by Sebastian Bergmann and contributors.

Testing Drupal\KernelTests\Core\Theme\RegistryTest
.                                                                   1 / 1 (100%)

Time: 00:01.550, Memory: 8.00 MB

OK (1 test, 4 assertions)

After the newly created patch the theme_get_registry function seems to be no longer called.

www-data@5e92f19c6122:/app/build$ git grep theme_get_registry                                                                
core/includes/theme.inc:function theme_get_registry($complete = TRUE) {
core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php:   * Tests deprecated theme_get_registry function.
core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php:   * @see theme_get_registry()
core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php:    $this->expectDeprecation('theme_get_registry() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method get() instead. See https://www.drupal.org/node/3348850');
core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php:    $this->assertEquals($registry->get(), theme_get_registry());
core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php:    $this->expectDeprecation('theme_get_registry() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method getRuntime() instead. See https://www.drupal.org/node/3348850');
core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php:    $this->assertEquals($registry->getRuntime(), theme_get_registry(FALSE));
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed 0e8a558 and pushed to 10.1.x. Thanks!

  • lauriii committed 0e8a558b on 10.1.x
    Issue #3348848 by andypost, Purencool, daffie: Deprecate...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.