In TextfieldWidget::errorElement() there is the following comment.

    // Ignore validation errors for formats if formats may not be changed,
    // i.e. when existing formats become invalid. See filter_process_format().

There isn't any filter_process_format() function, in Drupal 8 or higher.

That isn't the only comment with a reference to filter_process_format(). git grep -n 'filter_process_format()' gives the following list.

  • core/modules/config_translation/src/FormElement/FormElementBase.php:141
       * In the specific case of formatted text this logic is implemented by
       * utilizing a form element of type 'text_format' and its #format and
       * #allowed_formats properties. The access logic explained above is then
       * handled by the 'text_format' element itself, specifically by
       * filter_process_format(). In case such a rich element is not available for
       * translation of complex data, similar access logic must be implemented
       * manually.
      
  • core/modules/config_translation/src/FormElement/FormElementBase.php:156
       * @see \Drupal\config_translation\FormElement\TextFormat
       * @see filter_process_format()
      
  • core/modules/editor/src/Element.php:50
        // filter_process_format() copies properties to the expanded 'value' child
        // element, including the #pre_render property. Skip this text format
        // widget, if it contains no 'format'.
      
  • core/modules/filter/src/Element/TextFormat.php:254
       * To not break form processing and previews if a user does not have access to
       * a stored text format, the expanded form elements in filter_process_format()
       * are forced to take over the stored #default_values for 'value' and
       * 'format'. However, to prevent the unfiltered, original #value from being
       * displayed to the user, we replace it with a friendly notice here.
      
  • core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php:51
          // Ignore validation errors for formats if formats may not be changed,
          // i.e. when existing formats become invalid. See filter_process_format().
      
  • core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php:42
          // Ignore validation errors for formats if formats may not be changed,
          // i.e. when existing formats become invalid. See filter_process_format().
      

The method that replaced filter_process_format() is TextFormat::processFormat().

Some of the comments could also be better written, for example rewritten to the following comment.

      // Ignore validation errors for formats that may not be changed, for
      // example existing formats which became invalid.
      // See TextFormat::processFormat().
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kiamlaluno created an issue. See original summary.

xjm’s picture

Version: 9.0.x-dev » 8.8.x-dev
Issue tags: +Novice

Thanks for the report! This looks like a good novice issue.

Docs fixes are eligible for backport to the production branch. While the function exists in D8, it's deprecated, so it'd make sense to fix this in D8 as well. Actually, according to the IS, it doesn't exist in D8 either. So definitely should be fixed in D8 as well.

himanshu_sindhwani’s picture

Assigned: Unassigned » himanshu_sindhwani
himanshu_sindhwani’s picture

Status: Active » Needs review
FileSize
5.36 KB

Here is a patch replacing filter_process_format() with TextFormat::processFormat() in comments.

apaderno’s picture

Just a small change: Since the sentence got shorter, some of the words that were in the next line can be moved up.

-      // Ignore validation errors for formats if formats may not be changed,
-      // i.e. when existing formats become invalid. See filter_process_format().
+      // Ignore validation errors for formats that may not be changed,
+      // i.e. when existing formats become invalid.
+      // See TextFormat::processFormat().

I would also use as instead of i.e.

himanshu_sindhwani’s picture

Hi @kiamlaluno, thanks for the suggestion but I can not move the words to above as it will be more than 80 words on one line. For me i.e., is making more sense than using 'as'.

Rkumar’s picture

Assigned: himanshu_sindhwani » Unassigned
Status: Needs review » Reviewed & tested by the community

I tested the patch and it works fine.

apaderno’s picture

Status: Reviewed & tested by the community » Needs work

i.e. can be moved on the previous line and the 80-character limit would still be respected. Actually, i.e. would end on column 77.

+      // Ignore validation errors for formats that may not be changed, i.e.
+      // when existing formats become invalid.
+      // See TextFormat::processFormat().

i.e. doesn't make more sense, and it's preferable to avoid it, especially when it's misused. Does the phrase following i.e. explain the previous phrase, or does it just give an example of formats that may not be changed? Are we ready to change the sentence to use e.g. instead of i.e. when the phrase following it is just an example of why a format may not be changed?

jyotimishra-developer’s picture

Assigned: Unassigned » jyotimishra-developer
himanshu_sindhwani’s picture

himanshu_sindhwani’s picture

Status: Needs work » Needs review
FileSize
42.26 KB

Hi @kiamlaluno, What I see here is the first phrase is an example of the second phrase which is why we are using i.e. and not e.g. here. The second phrase concludes the example given in the first phrase. On shifting i.e. to above line I see more than 80 characters. See the screenshot attached:

characters

himanshu_sindhwani’s picture

Assigned: himanshu_sindhwani » Unassigned
jyotimishra-developer’s picture

Hi, Patch in #4 is working fine. This is RTBC from my side.

apaderno’s picture

Status: Needs review » Needs work
FileSize
16.39 KB

I noticed there are two occurrences of the same text. The change applies to only one of them.

screenshot

apaderno’s picture

himanshu_sindhwani’s picture

Status: Needs review » Reviewed & tested by the community

Seems great!. Marking this to RTBC.

jyotimishra-developer’s picture

Hi, the patch in #15, applied successfully on 8.8.x Drupal instance. Working as expected.
Great!!

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Thanks everyone for fixing this stale documentation.

Just a note for @jyotimishra123: Thank you for reviewing this issue! The automated testing infrastructure tells us whether the patch applies, so we do not need people to review that. It is also not sufficient criteria for the issue to be marked "Reviewed and Tested by the Community". Saying the patch is working as expected also does not give us enough information about what it means. When you do post a review, be sure to describe what you reviewed and how. This helps other reviewers understand why you considered the issue RTBC (and is considered for issue credit). In this issue, that might involve reviewing that all the changes were correct and clear documentation, followed coding standards, and accounted for all the instances in core. Thanks!

One change we need to make in the patch is that we need to se the fully qualified namespace everywhere for TextfieldWidget, which I think is something like \Drupal\text\Plugin\Field\FieldWidget\TextFieldWidget. Thanks!

tdnshah’s picture

Implementing suggestion in #18
thank you

himanshu_sindhwani’s picture

The namespace used in #19 is incorrect, added the correct namespace, and fixed the spacing the issues in #19.

tdnshah’s picture

Ohh thanks for correcting @himanshu_sindhwani

apaderno’s picture

Status: Needs review » Reviewed & tested by the community

The class name is fully qualified and all the points raised in the previous comments has been implemented.

xjm’s picture

Title: Comments make a reference to filter_process_format(), a not existing function » Comments make a reference to filter_process_format(), which no longer exists

Yep thanks @himanshu_sindhwani, and apologies to @tdnshah for not being more clear that I was not sure of the correct namespace and that it would need to be checked before putting it in the patch. :) The namespace can be confirmed in the processFormat() documentation.

+++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php
@@ -48,7 +48,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
+      // such as when existing formats become invalid.
+      // See \Drupal\filter\Element\TextFormat::processFormat().

+++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php
@@ -38,8 +38,9 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
+      // such as when existing formats become invalid.
+      // See \Drupal\filter\Element\TextFormat::processFormat().

The word "See" here could fit on the previous line in both cases, but I suppose it's OK as-is also.

  • xjm committed 648c4aa on 9.1.x
    Issue #3110200 by himanshu_sindhwani, kiamlaluno, tdnshah, xjm: Comments...

  • xjm committed a40a03c on 9.0.x
    Issue #3110200 by himanshu_sindhwani, kiamlaluno, tdnshah, xjm: Comments...

  • xjm committed ebe6e75 on 8.9.x
    Issue #3110200 by himanshu_sindhwani, kiamlaluno, tdnshah, xjm: Comments...

  • xjm committed 1b93541 on 8.8.x
    Issue #3110200 by himanshu_sindhwani, kiamlaluno, tdnshah, xjm: Comments...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

There's also a couple rewordings in there that are slightly out of scope, but I'll commit it in the one patch for now. In general be careful to not introduce changes outside the scope of the issue, since this can make the issue harder to review and commit.

Committed to 9.1.x, and cherry-picked to 9.0.x, 8.9.x, and 8.8.x as a documentation improvement. Thanks!

Status: Fixed » Closed (fixed)

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