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

Moving project telemetry reporting from the update module into core

$
0
0

Problem/Motivation

The update module (packaged with core) provides a lot of functionality:

  • Reports interface to view a list of modules and themes that are out of date
  • Email notifications when there are updates available
  • Update individual modules and themes by uploading a file via the UI
  • Report usage metrics (telemetry) of installed modules and themes back to Drupal.org

For people that run a large number of sites, especially those that share a common codebase (very common in Higher Ed and Government), it's very common to NOT enable this module, because none of the functionality is needed. As a result, Drupal.org misses out on receiving a lot of telemetry data because it's bundled in this with this module.

Proposed resolution

Separate out the telemetry reporting from the update module and instead bring it into core. I briefly scanned thru the code and didn't see an obvious area where this is being reported, so I think what's happening is that when the module gets its list of extensions and asks Drupal.org for the latest versions of those extensions, Drupal.org registers the usage. So there may need to be some work on Drupal.org's end to faciliate this.

Remaining tasks

Decide if it should be opt-in or opt-out. There's some discussion about this in #2940737: Telemetry initiative.

User interface changes

API changes

Data model changes

Release notes snippet

↧

Expand Drupal\Core\Recipe\RecipeDiscovery to allow discovering available recipes, likely for use in Project Browser

$
0
0

Problem/Motivation

The discovery object for recipes is currently limited in scope. Expanding the class to discover recipes only in the currently intended folders will ensure contrib modules or project browser (when it moves to core) won't have to reinvent the discovery process.

Proposed resolution

The RecipeDiscovery will have similar method names to ExtensionDiscovery to help standardize the code.
The discovery object will have a method that returns an array of Recipe objects, as discovered.
Paths and path structure for recipes will currently be quite limited to just core and /recipes, intentionally, but can be easily altered to include other directories if so desired.

User interface changes

NONE

Release notes snippet:

(TBD)

↧
↧

Improved data sharing with d.o

$
0
0

Problem/Motivation

Our current D8, D9 usage stats are not as precise as with D7. One of the reasons is that update module does too much, the reporting functionality is not required any more for many websites.

Personally I did not enable the module on any D8+ websites, as with composer I do not feel the need to enable it any more. I would love to share the usage information with d.o, but I am not doing it, as I do not need to update.module functionality.

And more reasons why update status is not used any more: https://twitter.com/webchick/status/1362569962695446530

Proposed resolution

1. Option to ping back to d.o without enabling update.module, to get better global stats.
- This site is using Drupal version X.
There should be a nicely composed error message on the status page, in case this option is disabled. Core should not provide solution to hide this error message.

2. Have the option to send module/theme/profile usage without update.module reporting.
There should be a warning message on status page, in case this option is disabled. The message can be something like: "This is very important for the future Drupal core improvements, and for your future site updates.". Core should provide a solution to hide this message.
I am not sure if profile name is sent or not, but in case of core profiles this is a very useful information, for example to know why module like RDF is enabled.

3. Send information if the site uses composer or not, as this is not visible from module usage. Additional information, like PHP version would be also very very useful. Users should be able to share operating system and webserver information also.

4. There should be a "Data sharing report" page which:
- explains what data an how is shared with d.o.
- has an option to see what is exactly sent to d.o.
- contains a link to "Data usage policy for data collected from Drupal websites"

There should be a separate module "drupal_org_data_sharing" or something similar which would be a dependency of the update.module.
If the module is enabled the Drupal version info is shared with d.o. The other data sharing options should be module config.

↧

JSON:API should include validation constraint violations in log context

$
0
0

Problem/Motivation

When \Drupal\jsonapi\Exception\UnprocessableHttpEntityExceptions are logged by \Drupal\Core\EventSubscriber\ExceptionLoggingSubscriber, none of the detail about the actual validation errors are captured in the log entry. This can make responding to and fixing these errors more difficult, e.g. when analyzing server logs.

Relates to #3082984: Reduce logging severity/don't log expired tokens/401s in spirit, in so far as we add a custom exception there, and decorate the core exception logging subscriber to do special-casing.

Steps to reproduce

Submit an invalid field value during a PATCH to an entity and observe that the log entry contains none of the validation violations.

Proposed resolution

Add an exception logging subscriber that specifically handles these exceptions.

Remaining tasks

Code.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

TBD.

↧

Display node title by default when creating link with drupalink, allow configuration.

$
0
0

By default, if you do not select text and use the drupal link wysiwyg plugin, it creates a link with the url as the title. It would be more useful if the link created used the title of the node for the link, and even better if you could customize this in a hook.

↧
↧

[PP-1] `LinkCollection::validKey()` does not properly validate RFC 8288 link relation types

$
0
0

Problem/Motivation

The JSON:API spec states

A link object MAY also contain any of the following members:

  • rel: a string indicating the link’s relation type. The string MUST be a valid link relation type.

The linked RFC 8288 describes a valid extension link relation type:

Applications that don't wish to register a relation type can use an
extension relation type, which is a URI [RFC3986] that uniquely
identifies the relation type.

However, LinkCollection::validKey() validates link relation types using a custom-ish(?) method which disallows colons. Colons are valid in URIs, including URNs.

Steps to reproduce

Attempt to utilize a link relation type with a colon, e.g. urn:kinksters-link:cancel.

Proposed resolution

Validate the link relation type per the ABNF in the HTTP linking RFC.

Remaining tasks

Do the thing, add test coverage for this.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Not necessary?

↧

ModuleHandler skips all hook implementations when invoked before the module files have been loaded

$
0
0

Problem/Motivation

Under certain circumstances the module files are not yet loaded.

This happens for example when invoking a hook inside the constructor of a http_middleware service; theses services are constructed very early as a dependency of http_kernel service.

A more concrete example is a middleware service using the entity_type.manager. Most of the times the entity type information is retrieved from cache (stored in the discovery cache bin). When this cache however is missing, hooks like hook_entity_type_build() and hook_entity_type_alter() need to be invoked at this early stage. The modules files however haven't been loaded yet, making ModuleHanlder::verifyImplementations() skip all the hook implementations (silently!). The entity definition cache is then incomplete resulting in various hard to debug (next to impossible) exceptions like #3031598: The "paragraph" entity type did not specify a translation handler. .

Steps to reproduce

Taken from this comment.

  1. Just uninstalled the dblog module from UI here /admin/modules/uninstall
  2. Then open any menu /admin/structure/menu/manage/[menu-name] and I see an error:
    Uncaught PHP Exception Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: "The "menu" entity type did not specify a "edit" form class." at /core/lib/Drupal/Core/Entity/EntityTypeManager.php line 211
  3. Then click to Flush views cache on another admin page (Flush all caches > Flush views cache via admin menu).
  4. After #3 I can see the error:
    Uncaught PHP Exception Symfony\Component\Routing\Exception\RouteNotFoundException: "Route "entity.path_alias.collection" does not exist." at /core/lib/Drupal/Core/Routing/RouteProvider.php line 206

Why does it happen?

After #3, a lot of items were removed from router table from the database. You have to launch drush cr twice to fix such error.

Proposed resolution

If a hook is invoked before the modules being loaded, load all modules.

Remaining tasks

Update issue summary
Address #12 and #17

↧

When configuring a field on a content type's "manage display" tab the spinner shifts the label and format column

$
0
0

Problem/Motivation

When reviewing the patch in https://www.drupal.org/project/drupal/issues/3291100 I've noticed that as soon as the spinner shows up when opening the field settings in the manage display tab within a content type a shift of the label and format column takes place for a second. See the video. It has to be noted that the issue takes place with and without the patch from #3291100: Nested details element within content type's "manage display" UI changes width when opened applied, but with the patch applied it is more apparent, since it is the only unexpected shift/movement.

Steps to reproduce

1. Go to admin/structure/types/manage/article/display
2. Click the configure cog for the image field

=> you will notice a brief shift of the label and format column because the "Please wait" spinner is shown.

Proposed Solution

Render "Please wait" below the gear icon to prevent shifting.

Remaining tasks

Review
Manual testing of MR

User interface changes

API changes

Data model changes

Release notes snippet

↧

Inline form element colons are incompatible with localization

$
0
0

Problem/Motivation

Followup to #2236789: Styling of inline radios broken: inappropriate trailing colons (breaks EditorImageDialog):

.container-inline label:after,
.container-inline .label:after {
  content: ':';
}

The above code adds a colon after form item labels. These colons are incompatible with Drupal's localization. For example, in French this would need to be ' : ' instead of ':'; in Hindi, this might need to be localized to :-.

Proposed resolution

Possibly remove the hardcoded colon from CSS and use PHP to add the colons instead, so it can be localized properly.

Remaining tasks

  1. Decide on a solution
  2. Write a patch
  3. Review
  4. Commit

User interface changes

To be determined.

API changes

To be determined.

Data model changes

To be determined.

↧
↧

Update loading icon and use SVG

↧

Messenger creates a session for storing flash messages even when response format isn't HTML/it will never show

$
0
0

Problem/Motivation

If code is called which calls the Messenger service to add a message (e.g., a status update when adding a commerce product to a cart), a session will be written to hold the message data. This is fine in browser contexts, however if not using cookie auth (or, really, not using the html format) you get a session for a message that will never display. This can create WTF conditions when testing non-HTML endpoints (e.g., JSON:API) in clients like Insomnia or Postman, and also calls the cache kill switch unnecessarily.

Steps to reproduce

Make a non-HTML request (e.g., when using Bearer token auth) to a page that calls the messenger. Even though you do not need a cookie session, one is created.

Proposed resolution

No-op on setting messages when the request is not html format. We could in theory also consult the auth method, but I think this is unnecessary mixing of concerns.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

↧

Make drupal.tableheader only use CSS for sticky table headers

$
0
0

Problem/Motivation

The `drupal.tableheader` library provided a way to make table header sticky using JS when IE11 didn't have support for `position:sticky`.
Now that Drupal doesn't support IE11, we can remove the JS workaround and use `position:sticky` instead.

Related issues:

Steps to reproduce

Proposed resolution

  1. βœ… Remove tableheader.js
  2. βœ… Add `sticky-header` class to tables if `#sticky` is `true` for the table.
  3. βœ… Add CSS to set `position:sticky` for `.sticky-header thead`
  4. βœ… Update `drupal.tableheader` to include this css
  5. βœ… Add/update tests

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

↧

Remove usused image core/misc/loading.gif

$
0
0

Problem/Motivation

core/misc/loading.gif is only used in tests and could be removed

Steps to reproduce

Search for core/misc/loading.gif image, you will find this is not used anywhere other than a test.

Proposed resolution

Remove the unused image drupal/core/misc/loading.gif

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

↧
↧

Deprecate file_managed_file_save_upload(), file_save_upload() and _file_save_upload_from_form() and replace with a service

$
0
0

Problem/Motivation

Part of #3221796: [META] Modernise file upload logic. Replace file_managed_file_save_upload(), file_save_upload() and _file_save_upload_from_form with new services to separate the Form API and user-facing messages from API-level services.

Steps to reproduce

Current sequence:

Current sequence diagram

Proposed resolution

BeforeAfterNotes
file_managed_file_save_upload() and _file_save_upload_from_form()\Drupal\file\Upload\FileElementHelper::saveFileUploads()Provides a callback for \Drupal\file\Element\ManagedFile::valueCallback()
Handles setting form errors, including combining error messages, and user-facing messages
file_save_upload()\Drupal\file\Upload\FormFileUploadHandler::saveFileUploads()Loops through multiple uploads for the existing \Drupal\file\Upload\FileUploadHandler::handleFileUpload()
Passes an error handler. Doesn't add any Messenger messages directly

Notes on error handling

In order to decouple adding Messenger error messages in low-level file upload logic, we introduce an error handler that comes in two flavours:

  1. One that simply collects error messages for later retrieval
  2. On that just adds error messages to the Messenger service

In order to display info messages when a file is renamed, we introduced an event handler that handles FileUploadedEvents.

Reasoning:

Currently file_managed_file_save_upload() and _file_save_upload_from_form() have behaviour to combine upload errors and display them in a list, only if there is more than one. It does this by manipulating error messages (removing them, storing them, then re-adding them).

Default behaviour of file_save_upload() is just to add Messenger error messages.

Proposed sequence:

Proposed sequence diagram

Remaining tasks

  • Add tests for new services
  • Add legacy tests for deprecated functions
  • Update mermain diagrams with current architecture
  • Update issue summary

User interface changes

API changes

  • file_managed_file_save_upload(), _file_save_upload_from_form and file_save_upload()are deprecated
  • New \Drupal\file\Upload\FileElementHelperand \Drupal\file\Upload\FormFileUploadHandler services are added
  • A new FileUploaded event is dispatched on success of individual file uploads

Data model changes

Release notes snippet

↧

Twig filter Function is getting different entity object instead of null

$
0
0

Problem/Motivation

In custom twig filter function I am getting node object instead of null

Steps to reproduce

  • Create a custom twig filter say "media_is_image" for media entity object to check type of media.
  • In a article content type add a media reference field.
  • Override the node template in custom theme and add custom filter like below:
    {% set media_item = node.field_media.entity %}
    {% if media_item|media_is_image %}
    -----
    ----
    {% endif %}
  • Now if media field is empty then in the function parameter of twig filter I am getting node object instead of null.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

↧

CORS is not reflected in Ajax calls (requests are send as anonymous)

$
0
0

Problem/Motivation

We have multilingual sites setup using a different domainname for each language. We also setup the admin ui so that the translate tab on a node opens up in a modal dialog. When you hit the "edit" for one of the translations, the node edit form is opened also in a modal dialog.
CORS is setup to allow all our domains, supportsCredentials is enabled, methods are POST,GET and OPTIONS. exposedHeaders has the 'X-Drupal-Ajax-Token'.
When the Ajax calls are made to open the node edit forms in the second dialog, the calls are made anonymous. The session token is not send.

Steps to reproduce

Setup multilingual site with at least 2 languages.
Use different domain for each language.
Setup CORS as described above.

Proposed resolution

To solve this, ajax.js needs to configure extra options when doing the requests:
- crossDomain: true
- xhrFields: { withCredentials: true }

Remaining tasks

Check if this has any impact on other Ajax related stuff.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

↧

Add validation constraints to core.entity_view_mode.*.*

$
0
0

Problem/Motivation

View modes have 3 property paths that are not yet validatable:

./vendor/bin/drush config:inspect --filter-keys=core.entity_view_mode.taxonomy_term.full --detail --list-constraints --fields=key,validatability,constraints
➜  πŸ€– Analyzing…

 --------------------------------------------------------------------- ------------- --------------------------------------------------------------------------------------------- 
  Key                                                                   Validatable   Validation constraints                                                                       
 --------------------------------------------------------------------- ------------- --------------------------------------------------------------------------------------------- 
  core.entity_view_mode.taxonomy_term.full                              79%           ValidKeys: '<infer>'                                                                         
   core.entity_view_mode.taxonomy_term.full:                            Validatable   ValidKeys: '<infer>'                                                                         
   core.entity_view_mode.taxonomy_term.full:_core                       Validatable   ValidKeys:                                                                                   
                                                                                        - default_config_hash                                                                      
   core.entity_view_mode.taxonomy_term.full:_core.default_config_hash   Validatable   NotNull: {  }                                                                                
                                                                                      Regex: '/^[a-zA-Z0-9\-_]+$/'                                                                 
                                                                                      Length: 43                                                                                   
                                                                                      ↣ PrimitiveType: {  }                                                                        
   core.entity_view_mode.taxonomy_term.full:cache                       Validatable   ↣ PrimitiveType: {  }                                                                        
   core.entity_view_mode.taxonomy_term.full:dependencies                Validatable   ValidKeys: '<infer>'                                                                         
   core.entity_view_mode.taxonomy_term.full:dependencies.module         NOT           ❌ @todo Add validation constraints to ancestor type: config_dependencies                    
   core.entity_view_mode.taxonomy_term.full:dependencies.module.0       Validatable   NotBlank: {  }                                                                               
                                                                                      ExtensionName: {  }                                                                          
                                                                                      ExtensionExists: module                                                                      
                                                                                      ↣ PrimitiveType: {  }                                                                        
   core.entity_view_mode.taxonomy_term.full:description                 Validatable   Regex:                                                                                       
                                                                                        pattern: '/([^\PC\x09\x0a\x0d])/u'                                                         
                                                                                        match: false                                                                               
                                                                                        message: 'Text is not allowed to contain control characters, only visible characters.'↣ PrimitiveType: {  }                                                                        
   core.entity_view_mode.taxonomy_term.full:id                          NOT           ⚠️  @todo Add validation constraints to config entity type: core.entity_view_mode.*.*        
   core.entity_view_mode.taxonomy_term.full:label                       Validatable   Regex:                                                                                       
                                                                                        pattern: '/([^\PC])/u'                                                                     
                                                                                        match: false                                                                               
                                                                                        message: 'Labels are not allowed to span multiple lines or contain control characters.'    
                                                                                      NotBlank: {  }                                                                               
                                                                                      ↣ PrimitiveType: {  }                                                                        
   core.entity_view_mode.taxonomy_term.full:langcode                    Validatable   NotNull: {  }                                                                                
                                                                                      Choice:                                                                                      
                                                                                        callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'↣ PrimitiveType: {  }                                                                        
   core.entity_view_mode.taxonomy_term.full:status                      Validatable   ↣ PrimitiveType: {  }                                                                        
   core.entity_view_mode.taxonomy_term.full:targetEntityType            NOT           ⚠️  @todo Add validation constraints to config entity type: core.entity_view_mode.*.*        
   core.entity_view_mode.taxonomy_term.full:uuid                        Validatable   Uuid: {  }                                                                                   
                                                                                      ↣ PrimitiveType: {  }                                                                        
 --------------------------------------------------------------------- ------------- --------------------------------------------------------------------------------------------- 

Steps to reproduce

  1. Get a local git clone of Drupal core 11.x.
  2. composer require drupal/config_inspectorβ€” or manually install https://www.drupal.org/project/config_inspector/releases/2.1.5 or newer (which supports Drupal 11!)
  3. composer require drush/drush
  4. vendor/bin/drush config:inspect --filter-keys=core.entity_view_mode.taxonomy_term.full --detail --list-constraints

Proposed resolution

Add validation constraints to:

  1. core.entity_view_mode.*.*:dependencies.module
  2. core.entity_view_mode.*.*:id
  3. core.entity_view_mode.*.*:targetEntityType

This requires looking at the existing code and admin UI (if any) to understand which values could be considered valid. Eventually this needs to be reviewed by the relevant subsystem maintainer.

For examples, search *.schema.yml files for the string constraints:😊

Reach out to @borisson_ or @wimleers in the #distributions-and-recipes.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

More validation πŸš€

Release notes snippet

None.

↧
↧

[meta] Themes improperly check renderable arrays when determining visibility

$
0
0

Problem/Motivation

In certain situations regions that contain empty blocks still render.

The original design goal of regions was that the region itself not render when it contains "empty" content.

Determining emptiness is a challenge under the existing Render API implementation.
People expecting a region to dissapear may be surprised to find this feature non-functional.

@Eclipsegc

Dispite the fact that core community members are very aware of this issue, unfortunately there's really very little to be done about it until we decide to really overhaul this particular subsystem (Render API).
There are potentially a lot of people interested in doing that work, it's just a matter of figuring out the right solution, and building consensus.

The message you should take from this is that core developers are generally very aware of this issue, but it's not a simple as building a fix. It's more like we need to revisit the underlying paradigm that drives this section of Drupal.
It'll happen eventually, and until then, we'll all have to limp around this issue together.

Several approaches to solving this have been considered. All of which come with unacceptable drawbacks.

The core issue is that there is no possible way to definitely identify an 'empty' block without first
rendering it.

This is the standard code for detecting empty regions and results in wrapping divs showing regardless of content existing,

<?php
if ($page['region']) {...
?>

There are a number of symptoms of this issue.

It's a challenge to add class such as "has sidebar" to the body tag when it's impossible to determine if it's empty (there are some is empty() type workarounds in the thread)

Many possible workarounds have been proposed. None of which are suitable for implementation in core.

There are a number of existing child issues about broken layout, and more keep coming.

Considerations

Placeholders

Placeholders only have partially to do with BigPipe - They allow our dynamic page cache to work at all for complex scenarios. It is a pre-requisite for authenticated user caching.

Access

@fabianx

Access is not affected in core right now. If you use block visibility access conditions you are fine => with or without placeholders. (because it happens _before_ any rendering takes place). The only thing that there is, is that there is cache data in the region, so !empty() won't work. A helper function by Wim will filter that there are no renderable children. This needs a helper function, however at least the cacheable meta data needs to be put to the upper level.

We could also for empty regions just remove it and render it on the render stack instead. I think that would be safer, too and is exactly what happens when people using work-arounds to pre-render things.

This would make block visibility condition blocks work nicely - e.g. the user login block and is a really simple fix - just render an empty region before returning.

Empty blocks

@fabianx

Empty blocks happen just after rendering, so we cannot know if the region is empty before rendering it actually. Pre-rendering work-around works, but is ugly especially because it doubles the time to render the region.

Placeholdered blocks

@fabianx

In most cases you are by default not affected by this

Empty blocks happen just after placeholder replacement, with BigPipe even just on the client. => Pre-rendering work-around will not work. A late event subscriber or for BigPipe a JS solution will work.

Accessibility:

@andrewmacpherson

Empty DIVs don't really matter much for a11y, as they don't pollute the semantics at all.

However an empty is a problem for some assistive tech, as it will be included in their "landmark regions" navigation tools. An empty landmark region is potentially confusing. Same goes for header, footer, nav elements.

Proposed resolution

Suggestions

The best solutions that have been suggested over the years this issue has existed just don't get
the job done in an acceptable way.

The ideal result is the ability to add this to a template:

{# D8 #}
{% if region %}
  <div>{{ region }}</div>
{% endif %}

There have been some suggestions of adding twig filters for D8, for example:

{# D8 #}
{% set region = page.region|render %}
{% if region %}
  <div>{{ region }}</div>
{% endif %}

and calling render directly in the twig template:

// D7
if ($region = render($page['region'])):
  <div>$region</div>
endif;

These implementations suffer from the fact that placeholders are not yet replaced in the render array, using
this method will break features such as big pipe.

Design a new architecture for the render system.

It's clear from the existing thread that with the current implementation of the render system that was
introduced with drupal 7 that the issue steps from a fundamental flaw in the render architecture.

@pheneproxima has a good idea:

Render arrays already support a little-known property called #access_callback. If set, it is supposed to contain a callback function (or callable, I believe) which is called before its part of the array is rendered. And if it returns FALSE, that part of the array is skipped by the rendering system.

It would take a pretty large-scale effort across core, but we could take advantage of this property to quickly recurse through a render array and remove parts that should not, according to the access callbacks, be rendered. For example, an empty item_list could have an access callback which returns FALSE if there are no items in the list. A renderable array section that will contain the results of a view could have an access callback which returns FALSE if the view has no results (and there is no empty text). And so forth. Each part of a render array could implement lightweight logic to prevent rendering of that specific part of the array. Basically, we would pre-compute the #access property by recursively calling the lightweight access callbacks.

The downside is that this would still involve recursing through a gigantic renderable array. However...it'd be a great deal faster than rendering out the array and checking if there was any output. Also, we could take advantage of cacheability by returning AccessResult from the access callbacks (if, indeed, that's not what they already return).

Limitations

@markcarver

Simply rendering a variable in Twig does not guarantee the variable will be "empty".

If a render array contains properties for render caching/big pipe/lazy loading, then it can potentially generate placeholder markup.

This placeholder content may or may not be empty, but that will not be determined until it is replaced at a later time in the request... well after said Twig template is invoked, ran through "if empty" statement and subsequently render cached using the incorrect logic.

Known workarounds

// @todo audit the suggested work arounds and update this description.
// There a numerous workarounds and approaches, some general some for specific usecases.

@danbohea

OK, so there's a fourth option for people to consider for a default emptiness definition:

A: Empty means there must be text other than normal whitespace or tags or HTML comments (e.g. render|strip_tags|strip_comments|trim)
B: Empty means that there is no whitespace, but HTML tags or HTML comments are considered non-empty (render|trim)
C: Empty means there is absolutely no content in there not even whitespace (render)
D: (**NEW**) Empty means that there is no whitespace, HTML tags are considered non-empty, HTML comments are ignored and considered empty (I guess that's render|strip_comments|trim ?)
Option D is my preference: it's compatible with Twig debugging and shouldn't accidentally hide non-text HTML (e.g. Only local images are allowed. tags).

assign render output in twig to determine "emptiness"

Add

{% set output = render_var(content) %}

to your twig

Remaining tasks

[ ] Escalate this issue to an plan or initiative
[ ] Audit the workarounds
[ ] Document the known limitations - it doesn't look like this is going away any time soon.

User interface changes

None from an admin perspective.
Sitebuilder's will now have regions with empty blocks not being rendered, as expected.

API changes

[ ] To be determined

Data model changes

// @ todo

Release notes snippet

// @ todo

↧

Add validation constraints to core.entity_form_mode.*.*

$
0
0

Problem/Motivation

Form modes have 3 property paths that are not yet validatable:

vendor/bin/drush config:inspect --filter-keys=core.entity_form_mode.user.register --detail --list-constraints
➜  πŸ€– Analyzing…

 Legend for Data: 
  βœ…β“  β†’ Correct primitive type, detailed validation impossible.
  βœ…βœ…  β†’ Correct primitive type, passed all validation constraints.
 ---------------------------------------------------------------- --------- ------------- ------ --------------------------------------------------------------------------------------------- 
  Key                                                              Status    Validatable   Data   Validation constraints                                                                       
 ---------------------------------------------------------------- --------- ------------- ------ --------------------------------------------------------------------------------------------- 
  core.entity_form_mode.user.register                              Correct   79%           βœ…β“   ValidKeys: '<infer>'                                                                         
   core.entity_form_mode.user.register:                            Correct   Validatable   βœ…βœ…   ValidKeys: '<infer>'                                                                         
   core.entity_form_mode.user.register:_core                       Correct   Validatable   βœ…βœ…   ValidKeys:                                                                                   
                                                                                                    - default_config_hash                                                                      
   core.entity_form_mode.user.register:_core.default_config_hash   Correct   Validatable   βœ…βœ…   NotNull: {  }                                                                                
                                                                                                  Regex: '/^[a-zA-Z0-9\-_]+$/'                                                                 
                                                                                                  Length: 43                                                                                   
                                                                                                  ↣ PrimitiveType: {  }                                                                        
   core.entity_form_mode.user.register:cache                       Correct   Validatable   βœ…βœ…   ↣ PrimitiveType: {  }                                                                        
   core.entity_form_mode.user.register:dependencies                Correct   Validatable   βœ…βœ…   ValidKeys: '<infer>'                                                                         
   core.entity_form_mode.user.register:dependencies.module         Correct   NOT           βœ…β“   ❌ @todo Add validation constraints to ancestor type: config_dependencies                    
   core.entity_form_mode.user.register:dependencies.module.0       Correct   Validatable   βœ…βœ…   NotBlank: {  }                                                                               
                                                                                                  ExtensionName: {  }                                                                          
                                                                                                  ExtensionExists: module                                                                      
                                                                                                  ↣ PrimitiveType: {  }                                                                        
   core.entity_form_mode.user.register:description                 Correct   Validatable   βœ…βœ…   Regex:                                                                                       
                                                                                                    pattern: '/([^\PC\x09\x0a\x0d])/u'                                                         
                                                                                                    match: false                                                                               
                                                                                                    message: 'Text is not allowed to contain control characters, only visible characters.'↣ PrimitiveType: {  }                                                                        
   core.entity_form_mode.user.register:id                          Correct   NOT           βœ…β“   ⚠️  @todo Add validation constraints to config entity type: core.entity_form_mode.*.*        
   core.entity_form_mode.user.register:label                       Correct   Validatable   βœ…βœ…   Regex:                                                                                       
                                                                                                    pattern: '/([^\PC])/u'                                                                     
                                                                                                    match: false                                                                               
                                                                                                    message: 'Labels are not allowed to span multiple lines or contain control characters.'    
                                                                                                  NotBlank: {  }                                                                               
                                                                                                  ↣ PrimitiveType: {  }                                                                        
   core.entity_form_mode.user.register:langcode                    Correct   Validatable   βœ…βœ…   NotNull: {  }                                                                                
                                                                                                  Choice:                                                                                      
                                                                                                    callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'↣ PrimitiveType: {  }                                                                        
   core.entity_form_mode.user.register:status                      Correct   Validatable   βœ…βœ…   ↣ PrimitiveType: {  }                                                                        
   core.entity_form_mode.user.register:targetEntityType            Correct   NOT           βœ…β“   ⚠️  @todo Add validation constraints to config entity type: core.entity_form_mode.*.*        
   core.entity_form_mode.user.register:uuid                        Correct   Validatable   βœ…βœ…   Uuid: {  }                                                                                   
                                                                                                  ↣ PrimitiveType: {  }                                                                        
 ---------------------------------------------------------------- --------- ------------- ------ --------------------------------------------------------------------------------------------- 

Steps to reproduce

  1. Get a local git clone of Drupal core 11.x.
  2. composer require drupal/config_inspectorβ€” or manually install https://www.drupal.org/project/config_inspector/releases/2.1.5 or newer (which supports Drupal 11!)
  3. composer require drush/drush
  4. vendor/bin/drush config:inspect --filter-keys=core.entity_form_mode.user.register --detail --list-constraints

Proposed resolution

Add validation constraints to:

  1. core.entity_form_mode.*.*:dependencies.module
  2. core.entity_form_mode.*.*:id
  3. core.entity_form_mode.*.*:targetEntityType

This requires looking at the existing code and admin UI (if any) to understand which values could be considered valid. Eventually this needs to be reviewed by the relevant subsystem maintainer.

For examples, search *.schema.yml files for the string constraints:😊

Reach out to @borisson_ or @wimleers in the #distributions-and-recipes.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

More validation πŸš€

Release notes snippet

None.

↧

[meta] Add constraints to all config entity types

$
0
0

Problem/Motivation

Sibling issue for simple config: #2952037: [meta] Add constraints to all simple configuration.

Now that we have the possibilities to validate configuration we should do that.
This meta issue is about adding constrains to all config entities, so we can use that in JSON:API as well as in configuration entity forms.

The current list of config entity types in core:

  1. core.base_field_override.*.*.*: #3324140: Convert field_storage_config and field_config's form validation logic to validation constraints
  2. field.field.*.*.*: #3324140: Convert field_storage_config and field_config's form validation logic to validation constraints
  3. βœ… core.date_format.*: #3397491: Add validation constraints to core.date_format.*
  4. core.entity_view_mode.*.*: #3445150: Add validation constraints to core.entity_view_mode.*.*
  5. core.entity_view_display.*.*.*
  6. core.entity_form_mode.*.*:#3448457: Add validation constraints to core.entity_form_mode.*.*
  7. core.entity_form_display.*.*.*
  8. block.block.*: #3379725: Make Block config entities fully validatable
  9. βœ…block_content.type.*: #3397493: Add validation constraints to block_content.type.*
  10. comment.type.*
  11. contact.form.*: #3445976: Add validation constraints to contact.form.*
  12. βœ… editor.editor.*: #3412361: Mark Editor config schema as fully validatable
  13. field.storage.*.*: #3324140: Convert field_storage_config and field_config's form validation logic to validation constraints
  14. filter.format.*: #3421946: [PP-2] Make FilterFormat config entities fully validatable
  15. image.style.*
  16. language.entity.*Not in Standard
  17. language.content_settings.*.*Not in Standard
  18. βœ… node.type.*: #3379091: Make NodeType config entities fully validatable
  19. responsive_image.styles.*Not in Standard
  20. rest.resource.*Not in Standard
  21. search.page.*
  22. βœ… shortcut.set.*β€” see #3324984-35: Create test that reports % of config entity types (and config schema types) that is validatable
  23. βœ… system.menu.*β€” see #3324984-35: Create test that reports % of config entity types (and config schema types) that is validatable
  24. system.action.*
  25. βœ… taxonomy.vocabulary.*: #2002174: Allow vocabularies to be validated via the API, not just during form submissions
  26. user.role.*: #3445215: Add validation constraints to user.role.*
  27. views.view.*
  28. workflows.workflow.*: #2920441: Add config validation for workflow entitiesNot in Standard

Total: 7/28=25%
Standard: 7/23=30%

Last updated: April 30, 2024.

Related issues

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

↧
Viewing all 296707 articles
Browse latest View live


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