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

Field locales_source.source is not suitable for long texts and huge config objects

$
0
0

We have a feed import that fails (we have no clue why).
Looking at the "Log" tab did not help much as it crashed. It uses the locale() function to display the (translated) error text which in this case throws an PDOException:

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'source' at row 1: INSERT INTO {locales_source} (location, version, source, context, textgroup) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( ..[very long].. ) ) in locale() (Zeile 714 von /html/drupal/modules/locale/locale.module).

(That is line 714 in /html/drupal/modules/locale/locale.module)

It is the "else" code block "We don't have the source string, cache this as untranslated...." with a call to "db_merge()->execute" which fails.

My dirty patch is to call this "else"-block only for texts with less than 128 Bytes (mb_strlen) and calling $locale_t[$langcode][$context][$string] = TRUE; only otherwise.

It would be better to catch this kind of PDOException with SQLSTATE[22001] and probably just forget it.
The "$locale_t... = TRUE;" is needed here, too, because drupal make calls to locale() over and over otherwise.

Another question is why to try to translate an exception's message as it might hide important details. Nevertheless there'a a bug in the locale() function or the database code used by it.


Dynamically provide action plugins for every moderation state change

$
0
0

Updated #65

Problem/Motivation

  • Install content_moderation
  • Apply the "Editorial" workflow to articles.
  • Create an article node in the published workflow state.
  • Goto /admin/content
  • Use the bulk action "Unpublish content" on the article node.
  • You will see this validation error:

Proposed resolution

  • Remove the publish/unpublish action
  • Provide action plugins for every state
  • Dynamically create/update/delete action instances when workflow settings are changed.
  • Update moderation_content admin view with the state actions.

Remaining tasks

Dynamically create/update/delete action instances when:

  • create/update/delete operation happens on a workflow entity by implementing hook workflow (insert|update|delete).
  • changes to the workflow entity happen during config import.
  • changes to the workflow entity are done hook_update_N.

Update moderation_content admin view with the state actions.
Add functional test for both cases.

User interface changes

moderation_content admin view will have state change actions.

API changes

No API change only addition.
Adds new moderation state change action and deriver.

Data model changes

None.

"Source path has to start with a slash" exception when hitting path prefixed with index.php with RequestPath condition

$
0
0

Problem/Motivation

When hitting a site with at least one block configured with a request_path condition on any URL prefixed with index.php (i.e example.com/index.phpfoo, the following error is thrown (truncated stacktrace for brevity)

InvalidArgumentException: Source path foo has to start with a slash. in Drupal\path_alias\AliasManager->getAliasByPath() (line 185 of core/modules/path_alias/src/AliasManager.php).

Drupal\system\Plugin\Condition\RequestPath->evaluate() (Line: 77)
Drupal\Core\Condition\ConditionManager->execute() (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)

Steps to reproduce

  1. Clean Drupal installation
  2. Go to admin/structure/block, edit any (for example: Search) block that appears on the frontpage
  3. Go to pages tab and set /user/* and click "Show for the listed pages"
  4. Go to your.site/index.php.php
  5. There is an exception: InvalidArgumentException: Source path .php has to start with a slash. in Drupal\Core\Path\AliasManager->getAliasByPath() (line 229 of core/lib/Drupal/Core/Path/AliasManager.php).

Proposed resolution

Potentially always prefix $path with a forward slash.

Only send update notification email when there is an email address

$
0
0

Problem/Motivation

After deleting the email listed under (/admin/reports/updates/settings), each time a cron run is started, the following error is created:
Error sending email (from info@website.de to with reply-to not set)

Steps to reproduce

go to: /admin/reports/updates/settings

  1. Empty the list of email addresses
  2. After the system finds a new update, based on your configuration of "Check for updates" and "Email notification threshold"
  3. Run cron

The error disappears after adding back an Email into the notify list. But will reappear if it the email is delated again.


Doing a single export on update.settings.yml results in: 

notification: 
  emails: 
    - ''



On a different website where this error doesn't appear we get: 

notification:
  emails: { }

Here the notification email was never set.

Proposed resolution

Send update email only if there is an email address.

Remaining tasks

None

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Refactor LinkFieldTest, convert some methods to a Kernel test

$
0
0

Problem/Motivation

Several methods from Drupal\Tests\link\Functional\LinkFieldTest can be converted to kernel.
This should improve testing speed.

Proposed resolution

1)::testNoLinkUri() remove this test.
Add <button> to ::doTestURLValidation(). <none><nolink> are already there. This should be enough to remove this test.

2) ::testLinkFormatterQueryParametersDuplication(), ::doTestLinkSeparateFormatter() 2 very similar tests. Convert them to Kernel.

2.1) Create common classDrupal\Tests\link\Kernel\LinkFormatterDisplayTestBase, and then implement tests in separate classes:
::testLinkFormatterQueryParametersDuplication() - class Drupal\Tests\link\Kernel\LinkFormatterDisplayTest
::doTestLinkSeparateFormatter() - class Drupal\Tests\link\Kernel\LinkSeparateFormatterDisplayTest

2.2) Use valid_entries from LinkFieldTest::doTestURLValidation() to class LinkFormatterDisplayTest. To increase test coverage.

2.3) Add new "Complex query" to ::doTestURLValidation() $valid_entries. That were added by method ::getUrlWithComplexQueryInputList() before.
2.4) Remove methods getUrlWithComplexQuery(), getUrlWithComplexQueryInputList().

3) ::doTestLinkTypeOnLinkWidget() convert to Kernel. Create class Drupal\Tests\link\Kernel\LinkFieldWidgetTest.

Remaining tasks

Review.

User interface changes

API changes

Data model changes

Release notes snippet

Add support for enclosure field in Views RssFields row plugin so that posts can include media items

$
0
0

Problem/Motivation

The RSS format has the <enclosure> tag for "attaching" media to an item. It is typically used for the main image of an article or the audio file of a podcast issue.

Views has an RSS Enclosure formatter but it looks like it cannot really be used. Only the fields selected in the RssFields plugin settings form are rendered.

Proposed resolution

Add an optional "Enclosure field" option to RssFields.

Remaining tasks

  • ✅ Write patch as proof of concept for the proposed resolution
  • ✅ Get Views maintainer approval of proposed resolution (see comment #70 and review comment #84)
  • ❌ Create merge request satisfying the approved resolution
  • ❌ Community approval of merge request
  • ❌ Views maintainer approval of merge request
  • ❌ Write automated test coverage.
  • ❌ Merge the request into Drupal core
  • ❌ Celebrate the ability to properly include images in RSS feeds

User interface changes

Adds Image option in RSS fields list in Views.

API changes

Data model changes

Add ability to insert Media inline in CKEditor widget

$
0
0

Problem/Motivation

At now Drupal Media entities can be inserted into CKEditor, using Media Library widget, only as block element. So there are no ways to insert inline image (eg small icon image into text), or document (inline link to download file inside text paragraph).

Proposed resolution

Add "Inline" variant to widget align property, and convert CKEditor widget from block to inline, if selected.

Instead of manual control via the align properties as initially proposed, the current approach in the MR is doing the using the same approach as ckeditor5's image plugin is build upon, see the definition of the inline image and it's counterpart, the block image.

So as the image plugin in ckeditor core, there will be a new model for media which is embedded inline and media which is embedded as block content, which model is used is depending on the parent element of the media. So for example a <div>parent will result in a block model, a <p> parent will cause the editor to use the inline model.

On the rendering side, this needs dedicated templates to ensure that media embedded inline is also being rendered using markup that is based on phrasing content and can be contained inside flow content.
To use these templates view mode, there is also a new view mode ckeditor_inline which enables advanced control over what is rendered in case of media embedded media.

Remaining tasks

Discuss the UX, finish the patch.

User interface changes

Added "Inline" option to media align property.

API changes

  1. Clientside: New element inside the drupalMedia ckeditor plugin
  2. Serverside: New event MediaBuildEmbedEvent that allows altering the media build before it is rendered and embedded. The currently existing'#embed' key in the build is not providing enough context to make advanced changes in the build.

Data model changes

None.

Release notes snippet

TBD

Field column sort of view tables in Format

$
0
0

Hello,

1. The first sort way
This way affects the use of field values because the fields above cannot be obtained from the fields below through Twig, Only the fields below can obtained the values of the fields above. So, it cannot be sorted arbitrarily here, because to obtain the values of other fields, they must be placed on top, and in the front-end table output, it needs to be placed in the last column of the table. This is contradictory, unless in the Format table settings, you can freely drag and drop to control the sorting of columns.

2. The second sort way
I hope can control the sorting of table columns in Format table settings.

1


Cannot modify Editor config via a recipe during site install

$
0
0

When a recipe attempts to modify the config of an Editor during site install, it throws the error

In ExtensionList.php line 347:
  The theme stark does not exist or is not installed. 

To reproduce in D11.x, create the following recipe.yml file within a recipe/editor_test folder:

name: 'Editor Test'
description: 'Test the editor config during install'
type: Editor
recipes:
  - core/recipes/full_html_format_editor
install:
  # Core.
  - ckeditor5
  - editor
  - file
  - filter
config:
  actions:
    editor.editor.full_html:
      addItemToToolbar:
        item_name: '-'

and then install the site using "drush si recipes/editor_test". It should fail with the error mentioned above.

If you first install a site via `drush si` and then add the recipe manually via "php core/scripts/drupal recipe ../recipes/custom/editor_test -v" then it works fine.

This problem also occurs when just using simpleConfigUpdate instead of addItemToToolbar. Although errors in the recipe config are also not reported during install, so be careful what simple config you try to modify.

Use a single per-theme cache tag for block config entities

$
0
0

Problem/Motivation

Drupal sites typically have a lot of blocks and block cache tags (umami frontpage has about 20). They usually rarely change and if you change the block overview, we often save all blocks anyway.

At the same time, if you have multiple themes, changing blocks from one theme wont' change the others, so the global list cache tag doesn't need to be invalidated.

Strangely, there's also a a Block::postSave() that invalidates the block configs cache tag on saving a new one, explaining that it contains the theme, but as far as I see, that's not actually the case, leftover?

The performance impact of this isn't huge. In the umami example, this results in about 20 fewer cache tags in the http header/page cache, but we only save very few queries as block render caches often come with additional unique cache tags (views, block_content:id, menus, ..). But each tag in an IN () condition also costs a tiny bit I suppose.

I also removed the block_view cache tag, I can't think of a scenario where that is needed. I think that was pretty much the first cache tag we ever added, before we had list and per entity cache tags. We could also look into removing those entirely, or alternatively, use them for view displays, because I see another 10 cache tags for view displays (block_content, media and node), we could drop those in favor of the _view cache tag.

Last, the global list cache tag for blocks is still there but not actually invalidated, we should either remove it or add it back.

This will fail a lot of cache tests that expect those tags but hopefully not much else.

Steps to reproduce

Proposed resolution

The current proposal is to just keep the config:block_list cache tag.

* Config entities cache tag invalidation actually happens on the config level and config entities explicitly opt out of invalidating per-entity cache tags on save, only the list cache tag. We have the mechanisms to make that more dynamic, but as now striked-through in the problem description above, \Drupal\block\Plugin\DisplayVariant\BlockPageVariant does add the block_list cache tag, and changing would require a few changes, including updating the injected dependencies and possibly extending BlockRepository that I'm not sure fits into this issue.
* Still removes the block_view cache tag, but that's fairly minor, I'm open to keeping that to reduce the scope of this issue.
* The impact on the performance tests we now have, combined with preloading and other changes is really quite neat and with a handful of additional tweaks, site that care about this will be able to reduce their cache tags to a minimum. And for most scenarios I think this is quite a neat benefit.
* However, there is a tradeoff here. If there are sites out there that frequently update specific block configurations (not content blocks, not menus, just block config entities) then this will now invalidate every single block. I *think* that's not very common, but I have no data on that. There's also been some site building/theming approaches to render block config entities, although they are mostly discouraged now (twig_tweak 8.x-1.x used to embed block config entities, now it's plugins + config, entity reference fields to display blocks and so on)
* There might also be possible API changes from this. Several tests had to be updated because they were directly updating the underlying block configs instead of going through the config entity, but that was always discourages as it bypasses hooks and other things such as the list cache tag. But maybe people invalidated cache tags directly or something.

This could also live in a contrib project but I think it's worth considering for core.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Use comment access handler instead of hardcoding permissions

$
0
0

Problem/Motivation

The comment module comes with a CommentAccessControlHandler which is not really used on crucial places. Instead of using this handler, there are dozens of places, where the permissions provided by the comment module are checked directly (e.g. post comment permission checks instead of $entity->access('create') or access comments permission checks instead of $entity->access('view')).

For example, the $entity->access('create') access check is only used during comment link generation, but not for the comment form itself.

Due to this, it is currently impossible to create a custom access control handler for comment entities, as it would not be used where necessary. When reading through the code, you can also see there is a lot of access-related duplicate code (because the permission checks duplicate the access checks of the access control handler).

These changes will affect other issues as well, when those deal with comment access/permissions, but they are very important to get the comment entity access handling correct.

Proposed resolution

  • Scan through the code and eliminate all permission checks with proper $entity->access() checks. Search for the following permissions:
    • access comments
    • post comments
    • edit own comments

    The <em>administer comments</em> permission has been split in #3180177: [PP-2] Replaces usages of 'administer comments' permission w/ access handler checks in order to limit the scope of this issue.

  • If possible, the commenting status of the parent ID should be taken into account in the access control handler checks. As this status flag affects the entity access for certain operations, its checks should also be centralized in the access control handler
  • On "create access" the commented entity and, on comment replying, the parent comment should be passed as context as they might contain valuable information for a custom comment entity access control handler when making the decision.
  • Comment-related tests should still work as before, because only the access checking behavior is changed, but not the access requirements themselves

Remaining tasks

None.

User interface changes

None.

API changes

The current comments access checks behaviour can be altered by swapping the comment access control handler and implementing a custom access logic.

Data model changes

None.

Disallow saving the current default revision as a non-default revision

$
0
0

Problem/Motivation

It is possible to save the current default revision of an entity as the non-default revision. This results in inconsistent data as it only updates the revision data table but not the data table.

Steps to reproduce

$entity = EntityType::load(1);
$entity->isDefaultRevision(FALSE);
$entity->save();

This is actually actively done in core, see #3485030: MenuTreeStorage shouldn't invalidate cache tags if the menu didn't change, so preventing this should cause tests to fail.

Proposed resolution

isDefaultRevision() must be combined with saving as a new revision when the current revision is the default revision.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Allow other modules to include their own Navigation blocks during installation

$
0
0

Problem/Motivation

Navigation module provides a flexible system to manage the blocks shown in the Navigation Bar. However, it can be confusing for site admins that they have to manually add the Navigation blocks provided by other modules, or even they won't notice that other modules are providing those blocks.

The aim of this issue id to provide a simple system that will allow modules to add Navigation Blocks in a similar way as recipes do in #3478224: Provide Config Action to add new blocks to navigation from recipes. In this way, block are added to the Navigation Bar, and editors afterwards can decide whether the blocks can be moved or removed from the bar.

Dashboard and it's Dashboard block is a good example for this new feature.

Proposed resolution

Create a new hook navigation_deafults that allows to define Navigation blocks that will be added to Navigation when the module providing the logic in installed.

Remaining tasks

Finish definition
Test POC

User interface changes

None

Introduced terminology

None

API changes

Add a new hook defined in Navigation module to declare the default blocks.

Data model changes

Release notes snippet

Fix 'Drupal.Commenting.ClassComment.Missing' in core/tests

Fix 'Drupal.Commenting.ClassComment.Missing' in modules


[meta] Fix 'Drupal.Commenting.ClassComment.Missing' coding standard

$
0
0

Problem/Motivation

This sniff relates to Drupal API documentation standards for classes and namespaces.

Hello this fixes the Drupal.Commenting.ClassComment.Missing standard listed in this parent, #2571965: [meta] Fix PHP coding standards in core.

In the pull request two classes are skipped:
- one is being fixed via the https://www.drupal.org/project/drupal/issues/3105880
- and another one intentionally doesn't include the class doc block due to testing the empty plugin annotations (therefore the adjusted phpcs.xml.dist).

Steps to reproduce

Proposed resolution

Comply with Drupal API documentation standards for classes and namespaces and another relevant part of the Drupal coding standards.

Remaining tasks

Break into child issues for

This issue will enable the sniff and fix any remaining issues. The remaining issues will, at least, include core/lib.

https://git.drupalcode.org/project/drupal/-/merge_requests/1889 is on 11.x

Done

User interface changes

API changes

Data model changes

Release notes snippet

Multiple concurrent current revisions

$
0
0

I don't know if the category is correct but we have a client which currently is somehow able to produce the following error:

He can't save a page because Drupal is telling him that untranslatable fields can't be changed while editing not the current revisions.

I had a look at the revisions and saw what is also on the screenshot. Drupal thinks there are 2 concurrent current revisions.

Clearing the cache solved this problem.
The project is using Redis for all caches. Could this be the problem?
Workflows and content moderation is not used.

We have ~ 20 projects using Redis for caching and none has this problem.

I don't know where to start and look here.

Is there someone which has experienced the same?

Hook ordering across OOP, procedural and with extra types i.e replace hook_module_implements_alter

$
0
0

Problem/Motivation

The ordering of listeners defined by new Hook attributes does not have a modern solution.

We needed to preserve hook_module_implements_alter in it's current form to handle all current ordering scenarios.

#3485659: Remove HookOrder HookOrder was temporarily removed because it does not quite work with extras.
#3484754: Ordering of hooks needs some attention Resolves the BC break (this issue is the followup to address point 3)
#3479141: Implement FormAlter attribute. is related since it is the most common form (lol) of an alter with extra types.

Steps to reproduce

Try to order an OOP implementation of a hook. Observe there's only a very clumsy legacy mechanism.

Proposed resolution

There are CRs to address each piece of hook_module_implements_alter functionality needed to handle hook ordering.
There is also a section in the remaining tasks summarizing the deprecation specifically for framework and release managers.

Ordering own implementation

See this CR for more complete examples: https://www.drupal.org/node/3493962
Add order parameter to the #[Hook] attribute.
The order parameter accepts the following simple ordering options.
Order::First
Order::Last
The order parameter also accepts the following complex ordering options which also accept parameters.
OrderBefore()
OrderAfter()
These can accept the following parameters:
modules: an array of modules to order before or after.
classesAndMethods: an array of arrays of classes and methods to order before or after.
groups: an array of hooks this hook should be grouped with when extra types are involved.

Here is how it works for CKEditor5.

  #[Hook('form_filter_format_form_alter',
    order: new OrderAfter(
      modules: ['editor', 'media'],
      group: ['form_filter_format_add_form_alter', 'form_filter_format_edit_form_alter'],
    )
  )]

OrderAfter specifies this hook should run after the parameters passed.
modules: ['editor', 'media'], specifies this ordering cares about the editor and media modules.
group: ['form_filter_format_add_form_alter', 'form_filter_format_edit_form_alter'], allows ordering relative to MediaHooks::formFilterFormatEditFormAlter and MediaHooks::formFilterFormatAddFormAlter -- these implement a different hook and so a grouping is necessary. This is the most complex case and most of the time group is not necessary.

Removal

See this CR for more details: https://www.drupal.org/node/3496786
Add #[RemoveHook()] attribute.
The #[RemoveHook()] attribute accepts details about the implementation to remove.

#[RemoveHook('help', class: LayoutBuilderHooks::class, method: 'help')]

This will remove the layout builder hook_help implementation.

Ordering other implementations

See this CR for more details: https://www.drupal.org/node/3497308
Add #[ReOrderHook()] attribute.
The #[ReOrderHook()] attribute accepts details about the implementation to reorder.

class WorkspacesHooks {
  #[ReOrderHook('entity_presave',
    class: ContentModerationHooks::class,
    method: 'entityPresave',
    order: new OrderBefore(['workspaces'])
  )]
  public function entityPresave()

This allows the workspaces module to move the entity_presave implementation in content_moderation before the implementation in workspaces.

Remaining tasks

Review
Should the deprecation happen in this issue for release manager review.
HMIA is a special hook, we cannot deprecate it normally.
If we follow standard deprecation processes then a contributed module will remove it which requires them to drop support for Drupal < 11.2 because the ordering functionality here will not be available for older versions of Drupal.
Proposed BC deprecation process.
Deprecate HMIA calls without #[LegacyModuleImplementsAlter]
This allows modules that are on Drupal < 11.2 to still run HMIA ordering and modules newer than 11.2 to use the new functionality here and ignore the legacy ordering.
If we do not use a new attribute and use #[LegacyHook] there is a gap 11.1 - 11.2 where ordering will break since the ordering attributes are not available and LegacyHook will skip hook_module_implements_alter implementations.
Decide if we want to deprecate hmia here or in a follow up
Branch with deprecation and functionality: https://git.drupalcode.org/project/drupal/-/merge_requests/11233
Deprecation patch only: https://www.drupal.org/files/issues/2025-02-17/hmiadeprecationv9.patch

User interface changes

N/A

Introduced terminology

Order
OrderAfter
OrderBefore
RemoveHook
ReOrderHook

API changes

A new enum and two new classes assist with ordering, these replace hook_module_implements_alter:

  • Order
  • OrderAfter
  • OrderBefore

Two new attributes to assist with modifying other hook implementations.
#[RemoveHook()]
#[ReOrderHook()]

Do not delete hook_module_implements_alter until you drop support for Drupal VERSION instead add the #[LegacyModuleImplementsAlter] attribute to hook_module_implements_alter once the module has set up the correct ordering attributes.

Data model changes

N/A

Release notes snippet

N/A

Explore inverting checkForProceduralOnlyHooks to prevent them from being added as listeners.

Make it possible to install dependent modules when installing theme

$
0
0

Problem/Motivation

It became possible to have themes depend on modules in #474684: Allow themes to declare dependencies on modules. In this implementation, the dependee-modules must be enabled in admin/modules before a module-depending theme can be enabled.
Ideally, it would be possible to enable the dependent modules as part of enabling the theme. This was not part of the initial implementation due to the complexities of permissions and confirmation forms when both themes and modules are being enabled.
A partial implementation was added in an earlier iteration of the patch #474684: Allow themes to declare dependencies on modules, once it was apparent that additional validation (including experimental modules) was needed, it was decided that this was better addressed in a followup.

Proposed resolution

Determine how to best implement module-enabling validation in both admin/modules and when enabling module-dependent themes.

Then implement that.

Remaining tasks

Ensure modules that enabled themes depend on cannot be uninstalled.
Handle forms that extend the newly deprecated: ModulesListConfirmForm

User interface changes

...

API changes

...

Data model changes

...

Release notes snippet

...

Viewing all 295674 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>