Quantcast
Channel: Issues for Drupal core
Viewing all 297443 articles
Browse latest View live

Fatal error: Uncaught TypeError: Drupal\Core\Extension\ThemeHandler::addTheme()

$
0
0

Problem/Motivation

Error was introduced in the 10.3.6 release of Drupal.

Fatal error: Uncaught TypeError: Drupal\Core\Extension\ThemeHandler::addTheme(): Argument #1 ($theme) must be of type Drupal\Core\Extension\Extension, null given, called in /var/www/html/core/lib/Drupal/Core/Extension/ThemeHandler.php on line 74 and defined in /var/www/html/core/lib/Drupal/Core/Extension/ThemeHandler.php:84

Steps to reproduce

Update drupal to version 10.3.6 using compser
Run drush updb


The entity link label formatter should check URL access

$
0
0

Problem/Motivation

Hi, I'm running into a problem that the `entity_reference_label` formatter does not check the URL access to the entity, but only relies on checking the access to the 'view label' operation and I'm getting invalid links.

Steps to reproduce

This can be reproduced by displaying a link to the user. The user always returns AccessResultAllowed for the 'view label' operation, but the direct view link (the 'view' operation) requires additional permissions.

Proposed resolution

I suggest adding an additional access check to the generated URL and if it is not available, output the label as plain text.

Remaining tasks

See #9.
Code review

User interface changes

API changes

Data model changes

Release notes snippet

Create a readonly storage trait that \Drupal\Core\Config\ReadOnlyStorage and other storages can use

$
0
0

Problem/Motivation

Request from @alexpott in Drupal Slack

Steps to reproduce

Proposed resolution

Move

  • \Drupal\Core\Config\ReadOnlyStorage::deleteAll
  • \Drupal\Core\Config\ReadOnlyStorage::rename
  • \Drupal\Core\Config\ReadOnlyStorage::delete
  • \Drupal\Core\Config\ReadOnlyStorage::write

to a trait and use it in:

  • \Drupal\Core\Config\Checkpoint\CheckpointStorage
  • \Drupal\Core\Config\ReadOnlyStorage
  • \Drupal\Core\Recipe\RecipeConfigStorageWrapper
  • \Drupal\Core\Recipe\RecipeExtensionConfigStorage
  • \Drupal\Core\Recipe\RecipeOverrideConfigStorage

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

YAML discovery does not take theme inheritance into account

$
0
0

Problem/Motivation

This problem occurs for plugin types with YAML discovery.

In Core, there is layout.

In contrib, at least the following modules have the problem in their plugin types:

Steps to reproduce

Have two themes, one is a parent, the other is a child.

Ensure the machine name of the child is alphabetically before the machine name of the parent.

Declare a layout in the parent theme.
Override the layout in the child theme.

Result: the plugin is not overridden.

Proposed resolution

Remaining tasks

Found a solution.

RuntimeException: Adding non-existent permissions to a role is not allowed

$
0
0

Problem/Motivation

Having installed Drupal 10 via composer and migrated content, I attempted to set up ckeditor5.
I have set up 3 text formats (Filtered HTML, Full HTML & Plain Text)

After saving all Formats I noticed that I had forgotten to include the 'align text'-button in the active toolbar.
So I went back to add it. Upon saving I received the following error:
The website encountered an unexpected error. Please try again later.

The Error log shows the following:
RuntimeException: Adding non-existent permissions to a role is not allowed.
The incorrect permissions are "use text format php_code". in Drupal\user\Entity\Role->calculateDependencies() (line 207 of core/modules/user/src/Entity/Role.php).

Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object) (Line: 179)
Drupal\user\Entity\Role->preSave(Object) (Line: 528)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 483)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 253)
Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 608)
Drupal\Core\Config\Entity\ConfigEntityBase->save() (Line: 97)
Drupal\user\Form\RoleSettingsForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('role_settings', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 686)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

1. In Drupal Version 10.0.9's ckeditor5 delete all Formats except Plain Text, Filtered HTML and Full HTML
2. Change the Toolbar configuration under "Full HTML" format.
3. Click Save
(If "Style"-button was moved to the active tool bar, you will get an error - no idea why. Move it back to the Available section and save.)
4. Change the content of an existing Basic Page
5. Back in the Text Forms & Editor configuration, add the 'text alignment' button to the active toolbar.
6. Click save

Overridden view block title should be set on the view itself

$
0
0

Problem/Motivation

It's currently impossible to access an overridden view block's title from within the view.

Steps to reproduce

Create a "Text area" footer item on a view that contains the "[view:title]" token. Observe that the title from the view's configuration is displayed instead of the overridden title from the block configuration.

Proposed resolution

Inject the overridden block title into the view using ViewExecutable::setTitle() in ViewBlock.

Remaining tasks

Make the change.

User interface changes

View blocks will now make use of the overridden title, falling back to the title found in the view's configuration as needed.

API changes

None.

Data model changes

None.

Release notes snippet

TBD.

Core security triage 2024-10-17

$
0
0

Attending: per issue credit

Explanation: Some full and provisional members of the Drupal Security Team meet fortnightly to triage and discuss private core security issues. These meetings are essential to core security process and should be credited like other contribution meetings.

Core security triage 2024-10-03

$
0
0

Attending: per issue credit

Explanation: Some full and provisional members of the Drupal Security Team meet fortnightly to triage and discuss private core security issues. These meetings are essential to core security process and should be credited like other contribution meetings.


Reorganize navigation settings to be more consistent

$
0
0

Problem/Motivation

Navigation settings schema is providing all the settings in the format logo_xxx format.
As part of the last module changes, new settings have been added and the number is growing.
Following other similar config schemas like system.theme.global, we are proposing to move it to a mapping where logo is the name and the specific properties are nested there.

Steps to reproduce

Proposed resolution

Use logo.xxx instead of logo_xxx for navigation settings schema.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Deprecated function: dirname(): Passing null to parameter #1 ($path) of type string is deprecated

$
0
0

Problem/Motivation

after upgrade to php 8.1 with core 9.3.7
i've got the following error due to deprecated null input value

Deprecated function: dirname(): Passing null to parameter #1 ($path) of type string is deprecated in Drupal\Core\Extension\ExtensionPathResolver->getPath() (line 85 of /var/www/subsite/web/core/lib/Drupal/Core/Extension/ExtensionPathResolver.php)
#0 /var/www/subsite/web/core/includes/bootstrap.inc(346): _drupal_error_handler_real()
#1 [internal function]: _drupal_error_handler()
#2 /var/www/subsite/web/core/lib/Drupal/Core/Extension/ExtensionPathResolver.php(85): dirname()
#3 /var/www/subsite/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php(123): Drupal\Core\Extension\ExtensionPathResolver->getPath()
#4 /var/www/subsite/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php(87): Drupal\Core\Asset\LibraryDiscoveryParser->buildByExtension()
#5 /var/www/subsite/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php(66): Drupal\Core\Asset\LibraryDiscoveryCollector->getLibraryDefinitions()
#6 /var/www/subsite/web/core/lib/Drupal/Core/Cache/CacheCollector.php(149): Drupal\Core\Asset\LibraryDiscoveryCollector->resolveCacheMiss()
#7 /var/www/subsite/web/core/lib/Drupal/Core/Asset/LibraryDiscovery.php(44): Drupal\Core\Cache\CacheCollector->get()
#8 /var/www/subsite/web/core/lib/Drupal/Core/Asset/LibraryDiscovery.php(58): Drupal\Core\Asset\LibraryDiscovery->getLibrariesByExtension()
#9 /var/www/subsite/web/core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php(68): Drupal\Core\Asset\LibraryDiscovery->getLibraryByName()
#10 /var/www/subsite/web/core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php(70): Drupal\Core\Asset\LibraryDependencyResolver->doGetDependencies()
#11 /var/www/subsite/web/core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php(41): Drupal\Core\Asset\LibraryDependencyResolver->doGetDependencies()
#12 /var/www/subsite/web/core/lib/Drupal/Core/Asset/AssetResolver.php(104): Drupal\Core\Asset\LibraryDependencyResolver->getLibrariesWithDependencies()
#13 /var/www/subsite/web/core/lib/Drupal/Core/Asset/AssetResolver.php(116): Drupal\Core\Asset\AssetResolver->getLibrariesToLoad()
#14 /var/www/subsite/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(312): Drupal\Core\Asset\AssetResolver->getCssAssets()
#15 /var/www/subsite/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(158): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAssetLibraries()
#16 /var/www/subsite/web/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php(45): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments()
#17 [internal function]: Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond()
#18 /var/www/subsite/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
#19 /var/www/subsite/vendor/symfony/http-kernel/HttpKernel.php(191): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#20 /var/www/subsite/vendor/symfony/http-kernel/HttpKernel.php(179): Symfony\Component\HttpKernel\HttpKernel->filterResponse()
#21 /var/www/subsite/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#22 /var/www/subsite/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#23 /var/www/subsite/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#24 /var/www/subsite/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#25 /var/www/subsite/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#26 /var/www/subsite/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#27 /var/www/subsite/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#28 /var/www/subsite/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#29 /var/www/subsite/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle()
#30 /var/www/subsite/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#31 {main}

Steps to reproduce

upgrade to php 8.1 with core 9.3.7

Proposed resolution

handling dirname function to accept null value or replace null with empty string

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Fix "call to undefined' PHPStan-0 issues in migration system

$
0
0

Problem/Motivation

PHPStan baseline is currently skipping multiple Call to an undefined method errors in the migration system

Proposed resolution

Fix the errors in the following

  • core/modules/migrate/tests/src/Kernel/MigrateTestBase.php
  • core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php
  • core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php
  • core/modules/migrate_drupal/tests/src/Traits/CreateTestContentEntitiesTrait.php
  • core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php
  • core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php

Drupal Usability Meeting 2024-09-27

$
0
0

This meeting takes place every Friday at 14:00 UTC (currently 7:00am PT, 10:00am ET). See Time.is to see what that is in your timezone.

The meetings are held using Zoom, and a link is posted in the #ux Slack channel 10 minutes before the meeting. Agenda is first come, first serve and set by attendees. Use the Needs usability review issue tag for issues that need review and/or suggest issues in comments here.

List of Slack users to ping 10 minutes before the meeting:
@worldlinemine, @lauriii, @AaronMcHale, @anmolgoyal74, @Ravi, @shaal, @ckrina, @simohell, @gauravvv, @Quynh, @yoroy, @andrei.zvonkov, @Regu.pl, @amazingrando

This list gets copied to the issue for the next meeting. If that has already happened, then go to that issue to add/remove yourself to/from the list.

Recording of this week's meeting: TODO

Rough transcript of this week's meeting: Drupal Usability Meeting - 2024-09-27.txt

We discussed the following issue:

NR and RTBC issues marked Needs usability review.

The group is actively tracking progress on these issues:

Remaining tasks

  1. Add issue credits for the participants.
  2. Add the issue(s) we discussed to the issue summary and as related issues.
  3. Add a rough transcript.
  4. Add a link to the recording on YouTube.
  5. Comment on the issue(s) we discussed.

Twig Filter "spaceless" is deprecated

Translations directory not autocreated

$
0
0

Problem/Motivation

In some situations the translations directory (where downloaded translation files get stored; e.g. sites/default/files/translations) is missing. This may happen for example in a development process, where a site is re-created on a dev machine from git and a live DB but without populating the files directory (as you use StageFileProxy).

Simplified steps to reproduce in a normally working site (translations directory = sites/default/files/translations)

$ rm -r sites/default/files/translations
$ drush locale-update

or on browser at admin/config/regional/translate/import and trying to import the .po file.

Example error messages:

 [notice] File temporary://filejmiMlj could not be moved/copied because the destination directory translations:// is not configured correctly.
 [error]  Unable to download translation file https://ftp.drupal.org/files/translations/8.x/admin_toolbar/admin_toolbar-8.x-1.24.de.po. 
 [warning] fopen(translations://admin_toolbar-8.x-1.24.de.po): failed to open stream: "Drupal\locale\StreamWrapper\TranslationsStream::stream_open" call failed PoStreamReader.php:154
 [warning] fgets() expects parameter 1 to be resource, boolean given PoStreamReader.php:248
 [notice] Unable to import translations file: translations://admin_toolbar-8.x-1.24.de.po

Screenshot of error message on translation import form:
Error message

Processes that will profit from a fix:

  • Update translation via user interface
  • Upload a translation via the Translation import page
  • Adding a language

Proposed resolution

  • Auto-create the directory if at the start of the batch check/update process.
  • Auto-create the directory when importing a translation via the Translation import page.

Remaining tasks

Find other other processes where the translation directory is yet not auto-created.

User interface changes

none

API changes

none

Data model changes

none

[PP-1] Consider making recipes' comparison with existing config lenient by default

$
0
0

Problem/Motivation

This is a follow-up to #3478332: Recipes' imported config is validated too strictly by default.

That issue made it possible for recipes to opt out of the strict comparison between the recipe's shipped config, and the active config. This is a good thing, because it allows an entire class of bugs to be eliminated/sidestepped. However, it's not yet the default behavior -- we still use the strict checking by default.

Should we change the default behavior to be lenient, and allow recipes to opt into the strict checks?


Add MenuLinkInterface::getAdminLabel()

$
0
0

Problem/Motivation

We currently have hard-coded hacks like this in MenuForm:

        elseif (($url = $link->getUrlObject()) && $url->isRouted() && $url->getRouteName() == 'user.page') {
          $form[$id]['title']['#suffix'] = ' (' . $this->t('logged in users only') . ')';
        }

This means contrib/custom menu links aren't able to do this without some heaving form altering.

See #2503755-86: Switch from user login block to login menu link and search block in standard profile and #2503755-87: Switch from user login block to login menu link and search block in standard profile.2.

Proposed resolution

Allow menu link plugins to specify admin labels.

Remaining tasks

TBD

User interface changes

None.

API changes

API addition.

Data model changes

None.

[policy] Document development dependencies

$
0
0

Problem/Motivation

Drupal has documentation on maintainership, security policies and release and support cycles of its dependencies. However, development dependencies are largely missing on that documentation.

Since this issue was created much of the dependency information is in composer meta data but not all.

Proposed resolution

Change the current text

Issue contributors should update either Current JavaScript dependencies or Current PHP dependencies when a dependency is added or when one is removed.

To

Dependency information links

It is important to know information such as who to contact in a dependency project, it's release cycle and how to file an issue for the dependency. This type information may be provided by the package meta data but not always. So, we keep track of that in the Current JavaScript dependencies and Current PHP dependencies for some dependencies.

The dependencies that this extra information is kept for are those that have a large security or API surface. Others may be added at the discretion of the release managers.

There are three times when the page is altered for a dependency. They are when it is added, when it is deprecated and when it is removed.

  • When a dependency is added, add a new listing
  • When a dependency is deprecated, update the listing to include that it is to be remove in the next major version.
  • When the last Drupal version to require it reaches End of Life (EOL), remove the listing.

The dependency information pages can be updated at any time.

On the Javascript dependency page
Only keep: CKEditor, jQuery, jQuery UI

On the PHP dependency page
Only keep: Symfony, Twig, Autoupdates(TBD)

new tag

dependency evaluation - For issue that include dependency evaluation and contact information.

Use of the new tag is added to Criteria for adding dependencies

Add link to issues with the new tag on the policy page

Remaining tasks

Discuss the future of these pages
Are they still needed?
What dependencies (dev and production) should be listed and why?
Add a new tag to find issue with the dependency information for dependencies that are not maintained on these pages.

Update documentation as required

User interface changes

API changes

Data model changes

Release notes snippet

Drastically improve the linking experience in CKEditor 5

$
0
0

Problem/Motivation

I think it's high time we bring the essential parts of Linkit into Drupal core: no configuration required (but possible! think: which entity types and bundles to provide suggestions for), just linking:

Proposed resolution

Add the essence of Linkit to Drupal core:

  1. while writing content in CKEditor 5, make it easy to link to other content
  2. require the new entity_links filter to be enabled, which is conceptually exactly like \Drupal\editor\Plugin\Filter\EditorFileReference (which handles HTML elements with data-entity-type="file" data-entity-uuid="*" src), but this will instead handle HTML elements with data-entity-type="*" data-entity-uuid="*" href) — this ensures links are always pointing to the latest URL alias 👍
  3. 🚀 improve the responsiveness of the autocomplete by applying the same private client-side caching optimization used by \Drupal\ckeditor5\Controller\CKEditor5MediaController::mediaEntityMetadata() and \Drupal\media\Controller\MediaFilterController::preview().
  4. 🕵️ for every suggestion: automatically list the author if the entity type has one, automatically list the creation datetime if the entity has one, and list both if the entity type has both — this helps remove the need for some of the configuration surface area

🤔 What does https://www.drupal.org/project/linkit have that this merge request does not?

  1. "substitution" plugins: \Drupal\linkit\SubstitutionInterface (introduced in #2786049: Make entity URL substitutions pluggable to support a wider variety of use cases. and the accompanying data-substitution attribute — I don't think it's necessary in 99% of cases — if you need this advanced feature, just use contrib Linkit 🤓
  2. "matcher" plugins: \Drupal\linkit\MatcherInterface, \Drupal\linkit\ConfigurableMatcherInterface, etc. — just using an entity query to match the entity label is sufficient for ~90% of cases — if you need this advanced feature, just use contrib Linkit 🤓
  3. (optionally) setting the title attribute on links based on the linked entity's label — if you need this advanced feature, just use contrib Linkit 🤓 → furthermore, on this issue this was reported to be problematic for accessibility in #51, #55 and #56

🫣 Which contrib modules does this partially or completely replace?
(Usage stats on March 30, 2023.)

  1. https://www.drupal.org/project/linkit (~128,000)
  2. https://www.drupal.org/project/media_entity_download (~7,000)
  3. https://www.drupal.org/project/ckeditor_entity_link (~5,200)
  4. https://www.drupal.org/project/media_entity_file_redirect (~500)
  5. https://www.drupal.org/project/ckeditor_link (~37,200 — D7-only)
  6. https://www.drupal.org/project/ckeditor_link_file (~2,100 — D7-only)
  7. https://www.drupal.org/project/ckeditor_link_user (~200 — D7-only)

And if this functionality is adopted by a site, then arguably most of the functionality in the following modules becomes obsolete:

  1. https://www.drupal.org/project/pathologic (~46,500) — in combination with the pre-existing editor_file_reference filter in core
  2. https://www.drupal.org/project/insert (~38,000) — in combination with the pre-existing editor_file_reference filter in core

🙏 I want to use this but I'm currently using Linkit, how do I switch?
Glad you asked!

https://www.drupal.org/project/linkit used the same data-entity-type and data-entity-uuid that \Drupal\editor\Plugin\Filter\EditorFileReference introduced >8 years ago. It's specifically designed for portability. And it makes the transition from the contrib module to this core feature trivial:

  1. Disable the linkit filter
  2. Enable the entity_links filter
  3. Configure which suggestions you would like to appear:

Remaining tasks

TBD

User interface changes

The CKEditor 5 linking experience becomes vastly better!

API changes

  1. Addition: new entity_links filter plugin
  2. Addition: new EntityLinkSuggester config entity type
  3. Addition: new ckeditor5_link_entity_suggestions CKEditor 5 plugin
  4. Addition: #type => radios's #options array no longer must be an array of strings, but an array of arrays is accepted too — this allows setting a #description per radio button for example

Data model changes

None.

Release notes snippet

TBD

New twig variable deprecation check should use a service and not the direct class

$
0
0

Problem/Motivation

When the TwigExtension service is overridden, #3270148: Provide a mechanism for deprecation of variables used in twig templates uses the wrong class and throws an exception:

The website encountered an unexpected error. Try again later.

Twig\Error\RuntimeError: The "Drupal\Core\Template\TwigExtension" extension is not enabled in "__string_template__d7d7f1a462505651fc222178924da388" at line 1. in Twig\ExtensionSet->getExtension() (line 73 of /var/www/html/vendor/twig/twig/src/ExtensionSet.php).
Twig\Environment->getExtension('\Drupal\Core\Template\TwigExtension') (Line: 40)

Steps to reproduce

Override the class in a custom module service provider class. Then visit any page that uses twig.

/**
 * Modifies the date_formatter service.
 */
class MyModuleServiceProvider extends ServiceProviderBase {

  /**
   * {@inheritdoc}
   */
  public function alter(ContainerBuilder $container) {
    if ($container->hasDefinition('twig.extension')) {
      $container->getDefinition('twig.extension')
        ->setClass('Drupal\my_module\Template\TwigExtension');
    }
  }

}

The overridden class can be simply defined.

<?php

namespace Drupal\my_module\Template;

use Drupal\Core\Template\TwigExtension as CoreTwigExtension;

/**
 * class TwigExtension.
 */
class TwigExtension extends CoreTwigExtension {
}

Proposed resolution

Class can be simply defined

Remaining tasks

Review/Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Create a ValidConfigName validation constraint

Viewing all 297443 articles
Browse latest View live