Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aczietlow’s picture

Status: Active » Needs review
FileSize
8.84 KB

I used the folowing to find all usages of drupal_html_to_text excluding any usages in a vendor directory.

> git grep --after-context 8 '@deprecated' | grep "drupal_html_to_text" | grep -v 'core/vendor' | rev | cut -c 2- | rev

The depreciated function will still need to be removed in another patch.

JeroenT’s picture

Created issue to remove the function drupal_html_to_text: #2359069: Remove drupal_html_to_text()..

Ec1ipsis’s picture

Updated patch file to fix some commenting code style issues.

Status: Needs review » Needs work

The last submitted patch, 3: remove-uses-of-2358999-3.patch, failed testing.

rpayanm’s picture

Status: Needs work » Needs review
FileSize
8.81 KB

rerolling...

quietone’s picture

Works for me.

Grep doesn't return any "drupal_html_to_text" instances and tests on the changed modules pass.

javivf’s picture

FileSize
56.25 KB

I do a reroll to apply patch

rpayanm queued 7: 2358999-7.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 7: 2358999-7.patch, failed testing.

rpayanm’s picture

Issue tags: +Needs reroll
aczietlow’s picture

@javivf It's unclear to me what this reroll (#7) was for? Should we be removing form_set_cache() or replacing decode_entities() for this?

rpayanm’s picture

Status: Needs work » Needs review
FileSize
8.95 KB

@aczietlow yes It's a strange patch :( let me make a reroll.

quietone’s picture

Patch from #12 works for me.

Grep doesn't return any "drupal_html_to_text" instances, tests passed.

aczietlow’s picture

Confirming that #12 passes all tests and has no usages of drupal_html_to_text().

rpayanm’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll

Then RTBC :D

herom’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php
@@ -35,9 +36,9 @@ public function format(array $message) {
-    $message['body'] = drupal_wrap_mail($message['body']);
+    $message['body'] = MailFormatHelper::htmlToText($message['body']);

We shouldn't change drupal_wrap_mail() here.

rpayanm’s picture

Status: Needs work » Needs review
FileSize
629 bytes
8.85 KB

@herom thank you, nice catch!
fixed!

JeroenT’s picture

Patch looks RTBC!

JeroenT’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 17: 2358999-17.patch, failed testing.

JeroenT’s picture

Issue tags: +Needs reroll
er.pushpinderrana’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
8.82 KB
rpayanm’s picture

Status: Needs review » Needs work
+++ b/core/modules/contact/src/MessageViewBuilder.php
@@ -55,7 +56,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N
+      // @todo Improve \Drupal\Core\Mail\MailFormatHelper::htmlToText() to convert DIVs correctly.
+++ b/core/modules/contact/src/MessageViewBuilder.php
@@ -55,7 +56,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N
+      // @todo Improve \Drupal\Core\Mail\MailFormatHelper::htmlToText() to convert DIVs correctly.
+++ b/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
@@ -37,7 +38,7 @@ protected function stringToHtml($text) {
+   * Helper function for testing \Drupal\Core\Mail\MailFormatHelper::htmlToText().
+++ b/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
@@ -66,7 +67,7 @@ protected function assertHtmlToText($html, $text, $message, $allowed_tags = NULL
+   * Test all supported tags of \Drupal\Core\Mail\MailFormatHelper::htmlToText().
+++ b/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
@@ -161,10 +162,11 @@ public function testTags() {
+   * Test $allowed_tags argument of \Drupal\Core\Mail\MailFormatHelper::htmlToText().

Comments must be <= 80 characters per line.

JeroenT’s picture

Status: Needs work » Needs review
FileSize
8.85 KB
1.83 KB

Made some changes as suggested by rpayanm in #23. Patch attached.

rpayanm’s picture

Status: Needs review » Reviewed & tested by the community

It's nice for me.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
git ac https://www.drupal.org/files/issues/remove_usage_of-2358999-24.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9064  100  9064    0     0  24552      0 --:--:-- --:--:-- --:--:-- 27056
error: patch failed: core/modules/system/src/Tests/Mail/HtmlToTextTest.php:8
error: core/modules/system/src/Tests/Mail/HtmlToTextTest.php: patch does not apply
rpayanm’s picture

Status: Needs work » Needs review
FileSize
8.87 KB

rerolling...

rpayanm’s picture

Issue tags: -Needs reroll
aspilicious’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Please add this issue to the relevant CR

JeroenT’s picture

Status: Needs work » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

One of the deprecated function removal has caused this to need a reroll. The drupal_strtolower() - make sure when reroll to not reintroduce a usage of that function.

git ac https://www.drupal.org/files/issues/2358999-27.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9078  100  9078    0     0   6724      0  0:00:01  0:00:01 --:--:--  9301
error: patch failed: core/modules/system/src/Tests/Mail/HtmlToTextTest.php:48
error: core/modules/system/src/Tests/Mail/HtmlToTextTest.php: patch does not apply
rpayanm’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
8.87 KB
aspilicious’s picture

Status: Needs review » Reviewed & tested by the community
rpayanm’s picture

Referenced this issue on the following change record: [#1992584].

quietone’s picture

Looks good to me. grep only finds the functions drupal_strtolower and drupal_html_to_text.

Though I think the modified change record is actually https://www.drupal.org/node/2309379

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
@@ -38,7 +39,8 @@ protected function stringToHtml($text) {
-   * Helper function for testing drupal_html_to_text().
+   * Helper function for testing
+   * \Drupal\Core\Mail\MailFormatHelper::htmlToText().

@@ -67,7 +70,8 @@ protected function assertHtmlToText($html, $text, $message, $allowed_tags = NULL
-   * Test all supported tags of drupal_html_to_text().
+   * Test all supported tags of
+   * \Drupal\Core\Mail\MailFormatHelper::htmlToText().

@@ -162,10 +166,12 @@ public function testTags() {
-   * Test $allowed_tags argument of drupal_html_to_text().
+   * Test $allowed_tags argument of
+   * \Drupal\Core\Mail\MailFormatHelper::htmlToText().

@@ -331,7 +337,8 @@ public function testDrupalHtmlToTextParagraphs() {
-   * Tests that drupal_html_to_text() wraps before 1000 characters.
+   * Tests that \Drupal\Core\Mail\MailFormatHelper::htmlToText() wraps before
+   * 1000 characters.

All too long. The coding standard is that the first line of a method doc block should fit on one line.

--- a/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
+++ b/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
@@ -39,8 +39,7 @@ protected function stringToHtml($text) {
   }

   /**
-   * Helper function for testing
-   * \Drupal\Core\Mail\MailFormatHelper::htmlToText().
+   * Helper function to test \Drupal\Core\Mail\MailFormatHelper::htmlToText().
    *
    * @param $html
    *   The source HTML string to be converted.
@@ -70,8 +69,7 @@ protected function assertHtmlToText($html, $text, $message, $allowed_tags = NULL
   }

   /**
-   * Test all supported tags of
-   * \Drupal\Core\Mail\MailFormatHelper::htmlToText().
+   * Tests supported tags of \Drupal\Core\Mail\MailFormatHelper::htmlToText().
    */
   public function testTags() {
     global $base_path, $base_url;
@@ -166,8 +164,7 @@ public function testTags() {
   }

   /**
-   * Test $allowed_tags argument of
-   * \Drupal\Core\Mail\MailFormatHelper::htmlToText().
+   * Tests allowing tags in \Drupal\Core\Mail\MailFormatHelper::htmlToText().
    */
   public function testDrupalHtmlToTextArgs() {
     // The second parameter of \Drupal\Core\Mail\MailFormatHelper::htmlToText()
@@ -337,8 +334,7 @@ public function testDrupalHtmlToTextParagraphs() {
   }

   /**
-   * Tests that \Drupal\Core\Mail\MailFormatHelper::htmlToText() wraps before
-   * 1000 characters.
+   * Tests \Drupal\Core\Mail\MailFormatHelper::htmlToText() wrapping.
    *
    * RFC 3676 says, "The Text/Plain media type is the lowest common

Here is a suggestion.

rpayanm’s picture

Status: Needs work » Needs review
FileSize
1.69 KB
8.8 KB

@alexpott thank you, then here the patch.

rpayanm’s picture

Status: Needs review » Reviewed & tested by the community

Minor changes so RTBC...

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue is a prioritized change as per #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase? and it's benefits outweigh any disruption. Committed 5528695 and pushed to 8.0.x. Thanks!

  • alexpott committed 5528695 on 8.0.x
    Issue #2358999 by rpayanm, JeroenT, er.pushpinderrana, javivf, Ec1ipsis...

Status: Fixed » Closed (fixed)

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