Quantcast
Viewing all 296414 articles
Browse latest View live

Remove Modernizr


On the user interface translation page the outline of all four focusable elements in the filter translatable strings fieldset lacks the left border

Problem/Motivation

On admin/config/regional/translate the four focusable elements (string contains, translation language, search in and the filter button) inside the filter translatable string fieldset miss the left border of the focus outline - or maybe it is covered by another element.

Image may be NSFW.
Clik here to view.
string contains field missing the left outline border

Image may be NSFW.
Clik here to view.
translation language selectbox missing the left outline border

Image may be NSFW.
Clik here to view.
search in selectbox missing the left outline border

Image may be NSFW.
Clik here to view.
filter button missing the left outline border

*Tested with Safari 13.1.2 and Firefox 97.0.1 on MacOS 10.13.6

Steps to reproduce

- Install the Language and the Interface Translation module
- Add a second language
- Go to admin/config/regional/translate

[drupalMedia] The CKEditor 4 → 5 upgrade path for the media_embed filter should not forcefully allow the `data-view-mode` attribute on `<drupal-media>`

Problem/Motivation

Discovered while reviewing #3245720: [drupalMedia] Support choosing a view mode for <drupal-media>.

#3245720: [drupalMedia] Support choosing a view mode for <drupal-media> made <drupal-media data-view-mode> an essential part of the media integration.

But in the issue where the MediaEmbed filter was introduced #2940029-97: Add an input filter to display embedded Media entities.

This also explains why SmartDefaultSettingsTest was failing in https://git.drupalcode.org/project/drupal/-/merge_requests/1796/diffs?co... because it did not expect the data-view-mode attribute to be added to the result of the CKEditor 4 → 5 upgrade path.

Proposed resolution

  1. Make <drupal-media data-view-mode> a separate array value in media_media's drupal.elements
  2. Add a configuration UI for the CKEditor 5 media plugin: a checkbox that indicates whether content creators are allowed to override the default view mode
  3. Implement \Drupal\ckeditor5\Plugin\CKEditor5PluginElementsSubsetInterface, to respect the configuration added in step 2, and hence unset the <drupal-media data-view-mode> when that checkbox is not checked
  4. Add a case for media_media to \Drupal\ckeditor5\Plugin\CKEditor4To5Upgrade\Core::computeCKEditor5PluginSubsetConfiguration(), to generate the correct configuration during the upgrade path.
  5. Add an extra test case to SmartDefaultSettingsTest, to test a variation of $basic_html_format_with_media_embed: one that has <drupal-media data-view-mode> allowed as well.
  6. Add a validation constraint (see #7) to ensure that the media_embed's allowed_view_modes setting is in sync with the media_media CKE5 plugin's new setting.

Remaining tasks

See proposed resolution.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A

ValueError: Path cannot be empty in /var/www/consult/core/modules/locale/locale.module on line 1112

Problem/Motivation

Can't update a page without a message "The website encountered an unexpected error. Please try again later."

Steps to reproduce

Try to update any page.

Proposed resolution

None

I join the Apache error log with full trace.

Regards

JP P

Add revert functionality to Config entities

Add a new method to the DrupalConfig class that allows you to revert to the default provided by the module. This basically replaces variable_del from Drupal 7 where variable_del was being used to revert back to the default provided by a variable_get.

Sample usage:

  $config = config('aggregator.admin');
  $config->set('aggregator_fetcher', 'test');
  $config->save();
  $config->revert('aggregator_fetcher');
  $config->save();

This patch requires that a config object / file is named module_name.config_space.xml so that we can work out which module is providing the defaults.

Correct vertical tab does not focus on form validation

When using a Vertical Tab form group with required fields, if a field that is required isn't filled in, or skipped by accident, and another tab is accessed, the tab with the previously unentered required info doesn't focus, which can sometimes lead to confusion.

I've created a patch that will check for the first element it finds that is required and is invalid, and selects the correct tab, focusing it. I've tested this out and it seems to work well for the scenario.

Contact form opt-out line should be excluded from admin-sent and sender-copy e-mails

I just noticed that when an admin sends an email to a user, it has this message:

Brad Landis (site/user/1) has sent you a message via your
contact form (site/user/12/contact) at siteName.

If you don't want to receive such e-mails, you can change your settings at
site/user/12.

Ironically, even if you change the settings, the admin can still contact you, which was the case for this email. If the admin user sends the email, this message should not be included.

LogicException: The database connection is not serializable.

Hi,

Im not sure if anyone else has got this error or not, but when I try to perform a validation $form_state->setErrorI am getting an error 

LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in Drupal\Core\Database\Connection->__sleep()

I will explain a bit more. In my form I have a form element which has an "Add more" functionality. That is, I can add another instance of that field with an incremented index in its name which is working all fine. Now I have added a form validation and want to validate against all the instances of this field. Its a straight forward validation logic

if (empty($field)) {
  $form_state->setError($form['content_bag_container']['bag_wrapper'][$key]['content_bag'], t('Please enter a content bag name.'));
}

Weirdly enough, this validation works for the first instance of the form element which pre-loads with the page itself. But whenever, I create a new instance via ajax, this validation fails and throws this error message in the log.

Can anyone check if this is some problem from my end or a bug in the core, cause I am not sure if an ajax populated field should be validated separately.

Thanks in advance...


Demote routine node and book log entries from "notice" to "info"

Problem/Motivation

Routine content management events, such as creating a node, are logged with the "notice" log level, which is for "normal but significant events." On active sites, these events are not really significant per se, so the lower severity "info" log level, for "interesting events," would be a better fit.

Steps to reproduce

Install node module, create a node, find a notice entry in your database log or syslog.

Proposed resolution

Demote from notice to info:

  • Delete node revision
  • Revert node revision
  • Delete node
  • Create node
  • Update node
  • Update book

Keep as a notice:

  • Create node type

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

When jQuery UI constrains tabbing it does not consider summary elements

Problem/Motivation

initially discovered here: #2977587-120: Improve block listing in Layout Builder by hiding uncommon block plugins

When jQuery UI traps focus inside a dialog, it determines the first and last focusable element, and those become the tabbing constraints.
Unfortunately, it does not identify <details> elements as focusable unless the tag includes a tabindex attribute. This tabindex attribute should not be necessary.

In the dialog, if a <details> element is followed by an element that jQuery UI considers tabbable, then <details> will be tabbable since <details> is between the constraint boundaries.

To reproduce open a dialog with <details>elements that contain no focusable elements.

  • <details>elements that contain no focusable elements
  • No focusable elements appearing after <summary> or <details>

Proposed resolution

I submitted a PR that fixes the issue to jquery-ui https://github.com/jquery/jquery-ui/pull/1885.
If it is desirable to have this addressed before the fix is added to jquery-ui + that update is added to Drupal, this can be done. It would require overriding $.ui.focusable

Remaining tasks

Determine if its better to wait for the jquery-ui fix, or to override $.ui.focusable

User interface changes

Tabbing within a jQuery UI dialog will consistently include <details> without the need for them to be followed by other interactive elements.

API changes

NA

Data model changes

NA

Release notes snippet

NA

Singular variant for plural string must contain @count

All plural APIs recommend write singular value with "1" value instead of "@count".

   * @param string $singular
   *   The string for the singular case. Make sure it is clear this is singular,
   *   to ease translation (e.g. use "1 new comment" instead of "1 new"). Do not
   *   use @count in the singular string.
Do not use @count in the singular string.

This line is misleading and can cause problems.

This recommendation can be found in core:

  1. \Drupal\Core\StringTranslation\PluralTranslatableMarkup::__construct
  2. \Drupal\Core\StringTranslation\TranslationInterface::formatPlural
  3. Drupal.formatPlural (drupal.es6.js)

The problem is that not only "1" can have singular value in different languages.

E.g. in Russian "21", "31", "41" and so on is singular value: "51 товар" (51 products), but not "11".

This is handled by formula "Plural-Forms: nplurals=3; plural=((((n%10)==1)&&((n%100)!=11))?(0):(((((n%10)>=2)&&((n%10)<=4))&&(((n%100)<10)||((n%100)>=20)))?(1):2));\n".

The translation strings is:

msgid "1 product"
msgid_plural "@count products"
msgstr[0] "1 товар"
msgstr[1] "@count товара"
msgstr[2] "@count товаров"

So in that case new PluralTranslatableMarkup(21, '1 product', '@count products') will return "1 товар" (1 product).

The solution is easy — we need use "@count" for singular value as well. In that case problem is not exists. new PluralTranslatableMarkup(21, '@count product', '@count products') will return "21 товар" (21 products).

At least we need to change documentation and suggest to use "@count" for singular value. Also, it will require to change all plural strings.

Files not being deleted from server

Hi guys,

I have a Drupal 9 running on Apache and MySQL on Windows with PHP 7.4, I created a content type that has a File Field in it, everything worked fine until I tried to replace a file in one of the nodes, I hit remove, it showed me that it removed it, I put the new file and it named it as filename_0.pdf I didn't pay too much attention at that time, but them I had to replace it again and it showed as filename_1.pdf, so I checked the folder where files are kept and all the previous files were there, at first I thought this was related to Revisions, so I disabled Revisions on that Content Type and tried to replace the file again, only this time it said it cannot upload file because there was another file with the same name used by a node, which is weird because no other node uses the file, I checked the files section in the content and it showed me all the others files, but it won't let me delete them.

I found that the files are kept as managed files in the database when they are not.

How can I make Drupal to delete files when they are removed from a node?

Thank you.

Migration plugin path_set_translated to support node paths with no leading slash

Problem/Motivation

The migration process plugin path_set_translated only transforms paths that start with a slash (e.g. /node/123). Node paths that do not include a leading slash (e.g. node/123) are left untouched.

Is it possible to support node paths that do not start with a slash ?

Here is my use case: I am trying to migrate redirects from D7 to D9. In D7 redirects are stored without a leading slash:

MySQL [d7]> select rid,type,source,redirect,language from redirect limit 1;
+-----+----------+-----------------------------------------------+----------+----------+
| rid | type     | source                                        | redirect | language |
+-----+----------+-----------------------------------------------+----------+----------+
| 153 | redirect | foo/bar                                       | node/183 | fr       |
+-----+----------+-----------------------------------------------+----------+----------+

I need to get the translated path of node/183, however path_set_translated is unable to do that since it expects the path to start with a slash. I know I can concatenate node/183 with a slash thanks to the plugin concat, but I also need the resulting value to not start with a slash as another process plugin (d7_path_redirect) expects the path to not start with a slash.

Attached is the full migration file for reference (inspired by the d7_path_redirect.yml).

Proposed resolution

Attached is a proposed patch. I have also opened MR !2267 for convenience.

Add type declaration to Html::escape() and FormattableMarkup::placeholderEscape()

Html::escape() and FormattableMarkup::placeholderEscape() needs a type declaration to prevent it from passing invalid values to htmlspecialchars(). This can only be done in Drupal 10 since it requires union types which are only support in PHP 8.1.

Original report:

Problem/Motivation

I had contrib functional tests failing with

htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated.

This is due to FormattableMarkup replacements being null - those go straight as nulls down to Html::escape() and hence to htmlspecialchars(), where PHP 8.1 complains.

This is not happening in core so no core tests were complaining.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Redesign Installer

Problem/Motivation

Recent interviews and research exposed pain points around Drupal's admin experience of looking and feeling dated. With Claro look&feel update the Installer to adapt Seven designs to the new Design System.
Current look:

Image may be NSFW.
Clik here to view.
Seven Installer

Proposed resolution

Redesign the installer and its components according to the new design system and implement it.

Current state: https://www.figma.com/file/OqWgzAluHtsOd5uwm1lubFeH/Drupal-Design-system...

Image may be NSFW.
Clik here to view.
Claro Installer Draft

Remaining tasks

  • Finalise Design
  • Implement the new design

User interface changes

Redesign of the installer

API changes


Create a top level, extendable, "Content" admin menu route that behaves like "Structure"

Problem/Motivation

Now we have Drupal 8 and positively encourage developers to create multiple types of content entity, we need to stop assuming that all content is made from nodes. Even in core drupal, we have node content, comments, files, custom blocks, taxonomy terms and more. As of 8.4 we also have Media.

Proposed resolution

Change the menu admin/content to use the same page layout as admin/structure and then have the current node content view a sub page of that, the comments views another sub page, etc etc.

Remaining tasks

User interface changes

The admin/content routes (and below) will change to more reflect that in admin/structure

API changes

none I am aware of yet!

Data model changes

none

Implement color changing theme settings for Olivero

This is a followup from #3086514: Investigate use of the changing color themes for Olivero.

We want to implement color changing themes within Olivero

Olivero currently has a single blue theme (along with gray colors). We want the user to be able to change this to support their specific branding.

Plan

Theme settings UX

  1. The site builder will navigate to the theme settings page
  2. Will have an option to either 1) Select color via color picker or 2) paste in a hex value
  3. The hex value will be saved to config
  4. config value will be pulled in and processed by PHP to determine hue
  5. Hue will then be output as CSS custom property, which will then be utilized by the CSS.

Why not use the color module?

The color module (currently) injects values directly into CSS, and is unworkable with CSS variables and the implementation that Olivero is aiming for.

Olivero’s implementation

Olivero will save a single string to config (the hex value). The interface within the theme settings will be made accessible by adding a input[type=”color] that will be kept in sync with the default input[type=”text”] that’s provided from the Form API.

Within preprocess, we extract this string, and parse it with PHP to generate the hue and saturation. These values are injected into the HTML as CSS variables. These variables, in turn, are used to generate the entire color palette.

Why not update the color module?

This is possible, but not within this theme. The Olivero theme is experimenting with these settings, and abstracting out the code with an eye toward inclusion in a new version of the color module. If and when this happens, we will provide an upgrade path.

Followup issues

  • Provide accessibility contrast feedback when selecting colors
  • Implement secondary color option when allowing users to select Olivero color scheme

[meeting] Migrate Meeting 2022-05-05 1400Z

Hello all, it’s time for the weekly migration subsystem meeting. The meeting will take place in slack in various threads
This meeting:
➤ Is for core migrate maintainers and developers and anybody else in the community with an interest in migrations
➤ Usually happens every Thursday and alternates between 1400 and 2100 UTC.
➤ Is done on the #migration channel in Drupal Slack (see www.drupal.org/slack for information).
➤ Happens in threads, which you can follow to be notified of new replies even if you don’t comment in the thread. You may also join the meeting later and participate asynchronously!
➤ Has a public agenda anyone can add to. See the parent issue for an idea of the typical agenda.
➤*Transcript will be exported and posted* to the agenda issue. For anonymous comments, start with a :bust_in_silhouette: emoji. To take a comment or thread off the record, start with a :no_entry_sign: emoji.

Core migration issues

Next video meeting 2022-07-07 2100Z (tentative)

The hope is that most or all of the maintainers will attend. We will try to focus on longer-term goals than in the weekly meeting.

0️⃣ Who is here today? Are you looking forward to Drupal 10? If so, why? Are you helping to make it happen?

mikelutz (he/him)Hello all! My brain is on Drupal 11 at this point. :stuck_out_tongue:
alisonHello, Alison has, just popping by! - CKEditor 5 I guess, but that's bc it's the only thing I know about?

Oo dropping support for IE! -- I think there was an accessibility issue that had to wait until Drupal 10 because of this, but I might be mixing it up... if I'm correct, though, I helped test that issue :laughing: (edited)

benjifisherI am not doing anything for D10, unless you count one migration issue that @quietone and I have been working on, so that user-role migrations do not fail horribly in D10.
heddnI look forward to the PHP 8.1 minimum supported version coming w/ D10.
quietoneI helped on the issues about deprecating and removing modules as well as the getting the process documented the deprecation policies.

1️⃣ What should we talk about today? Suggest topics here and I will add threads. I will also check for comments on the issue for today's meeting.

mikelutz (he/him)#3114887: Error responses are stored when using the Download migration process
quietoneMigrate in D10
benjifisherIt is a little late to open new threads for today's meeting. I will add a note to the issue for next week's meeting.
quietoneI take that to mean that the meeting is open for 24 hours but limited to the discussion threads started by those in attendance during the meeting hour.
benjifisherThat is how I understand it.I guess we can choose how to handle it. we could make it more like a 24-hour meeting.
quietoneNo need to change. I just like to be sure.

2️⃣ Action items. To be added later.

benjifisher Checking the action items from the 2022-04-21 meeting:
benjifisherNo action yet on this suggestion:

Add a regular item to the meetings to look at wiki documentation, maybe once or twice per year.

benjifisherI looked at #2953111: Migrate non-existing permissions to temporary migrate permissions. The test that failed passes when I run it locally, so I set the issue back to RTBC.

3️⃣ Statistics

benjifisherFixed since last week's meeting: 0 (not counting the issue for the meeting).
benjifisherRTBC: 11, 1 of which is Major.
benjifisherNR: 17, including 1 Critical, 2 Major, and 3 that have not been updated in more than one month.
benjifisherGoogle sheet for recording stats: https://docs.google.com/spreadsheets/d/1o0Rjlc1vnnLP5bM5P-SMMyGzqn7258hi... (not yet updated for today)
benjifisherI updated the spreadsheet.

4️⃣ Comment in this thread if you are looking for ways to help. Give us some idea of what you would like to do: documentation, code review, testing, project management, ...

rclemingsRegarding https://www.drupal.org/project/drupal/issues/3052115, I would like to take a swing at updating the issue summary, but I'm unclear on what's needed.

As the issue title says, this patch marks an entity as "syncing" when running a migration update, e.g. "drush mim upgrade_d7_node_article --update." That appears to be necessary in order for the patch in https://www.drupal.org/project/drupal/issues/2329253 to work.

Together, those two patches set the entity's "last updated" field to match the source, instead of setting it to the current time. Maybe there are cases when you'd want to set it to the current time, but I don't know what they are. On an initial migration, "last updated" is set to match the source. Why would it be different when doing a migration update? I'd think you'd want to faithfully transfer the source data in either case. As it is, without these two patches, running a migration update resets "last updated" and creates chaos for any views, etc., that use that field for sorting, just as an example.
Also, #3052115 lists #2329253 as a blocker, and I'm unclear why. Can't #3052115 be moved forward anyway, so that it is ready when #2329253 is finished?

So, willing to help, but need some guidance.

benjifisherThanks for looking into this. Updating issue summaries is very helpful, and often overlooked.

I have to get to my day job now, but I will try to answer your questions some time later. Or maybe someone else will help out.

rclemingsHere's a straw man version to start with.

5️⃣ Previous minutes.

benjifisherIs there anything to follow up? Anything need to be changed in those minutes?
benjifisher NR:

Needs transcript:

benjifisher04-14 was the last video meeting. I have a rough transcript.

04-28 was during DrupalCon, and we did not meet.

6️⃣ Announcements

7️⃣ Error responses are stored when using the Download migration process

benjifisher#3114887: Error responses are stored when using the Download migration process
benjifisherThat seems like a bug. What is there to discuss?
mikelutz (he/him)I wanted a second opinion on this. Since download writes directly to the destination file stream, if you get a 404 error, you write the response body content to a .jpg file, for example.
benjifisherFor BC, we could add a new option, and change the behavior to "do not save 404 response as a file" when set.
mikelutz (he/him)I don’t think we need BC, but the reporter put in a patch to delete the file on error, and my gut says we should write to /tmp and move the file to the final destination on success instead, but I’m not confident in my knowledge of how that would affect performance, among other things.
benjifisherI don’t think we need BChttps://xkcd.com/1172/
benjifisher
Every change breaks someone's workflow.

Also, EMACS is evil. :wink: (edited)

mikelutz (he/him)One of my favorites, lol. But practically we don’t make people opt into bugfixes, thankfully, and I do consider this a bug.
benjifisherI would think that moving a file is negligible compared to downloading it.

We also have to think about what happens if there is already a file of the same name. Based on what you said, it would be overwritten and then deleted with the current patch. With your suggestion, it would be untouched.

heddnfile migrate performance is TERRIBLE. and forcing to tmp and assuming that the final destination is on the same FS is a naive assumption. What if the final destination is S3? Or another physical disk. Either one of those options are much slower then movement on the same file mount where the inodes just get rewritten.
heddnI guess I'm less inclined to fix this. could we warn/error and just leave the bad file?
benjifisherMaybe that is a better reason than BC to make the new behavior optional. As you point out, there are too many possibilities, so we should let the developer decide what to do.
mikelutz (he/him)I’d prefer to harden it by default, I feel like the 80% use case is the tmp filesystem being on the same file system as the public file system, but I don’t mind leaving a direct download option in the process plugin.
heddnmany of my migrate problems are related to files migrations (taking too long). what is the problem with storing error responses instead of nothing? what problem are we trying to solve?
benjifisher
  1. You think you have already downloaded the files, but one or more is broken.
  2. Depending on how file_exists is set, you may or may not fix  this by updating the migration.

8️⃣ How do we manage occasional chores?

benjifisherOne of the suggestions at the 04-21 meeting was
Add a regular item to the meetings to look at wiki documentation, maybe once or twice per year.

How do we keep track of that?

benjifisherEvery week, we check on issues (NR, RTBC, Fixed) in the core issue queue. We do not regularly check
  • PMNMI issues (postponed, maintainer needs more info)
  • issues from contrib modules (e.g., migrate_plus).
  • documentation
benjifisherOur usual practice is to clone the issue for this week's meeting in order to create next week's meeting. Then edit it.

Maybe we could add a schedule to the issue description. It will get copied when we clone. Something like this:

  • Tasks for the first meeting of each month:
  • January: review PMNMI issues
  • February: review migrate_plus issues...
quietoneWhat about slackbot reminders? Although that seems more work than adding the occasional items to the agenda.
alison
Maybe we could add a schedule to the issue description. It will get copied when we clone.

That feeeeeeeels like a good option to me, if it doesn't get more complicated than "first of the month" / "monthly chores"?

But really I would defer to @benjifisher on any meeting agenda template changes.  i.e. if you think the addition of "first of the month" and similar variations won't be a horrible headache for you, I think that sounds like a good option.  (Or, could try and see how it goes for a bit.)

I love the topic, glad it's being discussed! (edited)

alison"Wiki documentation" -- does that refer to d.o guides, or something else?
benjifisherI think so. Mostly https://www.drupal.org/docs/drupal-apis/migrate-api, but also the upgrade guides.
alisonGotcha. Imo that would be too much to review at once, but if you mean broken up, I think that could work!

Does the migrate documentation section have guide manager or something? (edited)

benjifisherYes. I am one of the guide maintainers. I do not actively review the docs, but I can approve new pages. See 2️⃣.

9️⃣ Wrap up

benjifisherThanks for participating! I will update 2️⃣. Please continue to add comments in the threads. In 1-7 days, we will post a transcript for today's meeting.

Mark an entity as 'syncing' during a migration update

Problem/Motivation

There is an unmet need to flag entities as "syncing" when doing migration updates, so that they can be handled differently from ordinary updates.

For example, updating an entity sets the entity's changed time to the current time. This creates an issue when doing migration updates, which update entities on the destination that have been changed on the source since the last migration.

In an initial migration, the entity's changed time is set to match the changed time in the data source. For example, if a node of the page content type has a "changed" timestamp 1651775012 in the source, the node will also have a "changed" timestamp 1651775012 in the destination, regardless of how much time has actually elapsed since then.

This behavior should be the same when the initial migration is updated (via e.g. "drush mim upgrade_d7_node_page --update"). But it's not. Rather, the "changed" timestamp on the destination entity is set to the current time, instead of the value of the "changed" timestamp on the source node. As a result, the migrated data on the destination does not faithfully mirror the source.

Among other side effects, views that include a sort on the entity's changed time may not work correctly on the destination after a migration update.

An additional example of the need for a "syncing" flag can be seen in issue #2803717, concerning updates in content moderation.

Proposed resolution

Multiple patches are involved. This one simply flags an entity as "syncing" during a migration.

The following pending patch looks for the "syncing" flag and skips updating the changed time for entities with that flag:

#2329253: Allow the ChangedItem to skip updating the entity's "changed" timestamp when synchronizing (f.e. when migrating)

This fixed issue uses a "syncing" flag to solve a similar problem in content moderation migrations:

#2803717: Allow 'syncing' content to be updated in content moderation without forcing the creation of a new revision

Blocked on:

None. This patch simply sets the "syncing" flag that can be used to alter the behavior of an entity migration. It is blocking #2329253 and would provide a simpler method to implement #2803717.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

This patch marks entities as "syncing" during migrations, so that other code (including issues #2329253 and #2803717) can alter the handing of migrating changes to entities.

Calling code can not collect bubbled attachments from TextProcessed

Problem/Motivation

TextItem contains a processed property
This property is a computed field built with the TextProcessed class
Calling $entity->text_field->processed will return you the filtered text, i.e. with all filters applied.

At this point if you're using $entity->text_field->processed in a render array, you should also take care to collect its cacheable-metadata. Because TextProcessed implements CacheableDependencyInterface, you can do that like so

$cache = new CacheableMetadata();
$a_render_array = [
  '#theme' => 'biscuits',
  '#cookies' => $entity->text_field->processed,
];
$cache->addCacheableDependency($entity->text_field->processed);
$cache->applyTo($a_render_array);

However a the processed protected property on TextProcessed is an instance of FilterProcessResult, which extends from BubbleableMetadata, not just CacheableMetadata

This means there are #attachments inside it too, not just #cache entries.

There is no way to access those attachments and add them to your render array.

This is minor because you can work around this by doing this instead

$a_render_array = [
  '#theme' => 'biscuits',
  '#cookies' => [
    '#type' => 'processed_text',
    '#text' => $entity->text_field->value,
    '#format' => $entity->text_field->format,
];

Steps to reproduce

Write a filter plugin that adds Javascript or CSS (or any #attached)
Add an input format with that filter plugin enabled
Create an entity with a text field on it
Access the contents of the field for use in a render array using $entity->text_field->processed
Note that your render array won't include the attachments

Proposed resolution

Have TextProcessed also implement AttachmentsInterface

Remaining tasks

Implement the interface
Add a test

User interface changes

API changes

Data model changes

Release notes snippet

Viewing all 296414 articles
Browse latest View live


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